Skip to content

Commit

Permalink
Upgrade Rubocop to 1.45.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Feb 16, 2023
1 parent bae131f commit c10e392
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- { ruby: '2.7', faraday: '0.9.0' }
- { ruby: '2.7', faraday: '0.17.0' }
- { ruby: '2.7', faraday: '~> 1.0' }
- { ruby: 'jruby-9.2.21.0' }
- { ruby: 'jruby-9.3' }
- { ruby: 'ruby-head', allowed-failure: true }
- { ruby: 'jruby-head', allowed-failure: true }
name: test (${{ matrix.entry.ruby }}, ${{ matrix.entry.faraday || 'default' }})
Expand Down
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
inherit_from: .rubocop_todo.yml

require:
- rubocop-rake
- rubocop-minitest

AllCops:
NewCops: enable
TargetRubyVersion: 2.3

Metrics:
Expand Down
62 changes: 33 additions & 29 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,51 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-12-03 14:08:14 -0500 using RuboCop version 0.81.0.
# on 2023-02-16 15:23:43 UTC using RuboCop version 1.45.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'hyperclient.gemspec'

# Offense count: 1
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
- 'test/hyperclient/entry_point_test.rb'

# Offense count: 4
Lint/MissingSuper:
Exclude:
- 'lib/hyperclient/attributes.rb'
- 'lib/hyperclient/entry_point.rb'
- 'lib/hyperclient/link_collection.rb'
- 'lib/hyperclient/resource_collection.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedMethods.
# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?
Lint/RedundantSafeNavigation:
Exclude:
- 'lib/hyperclient/link.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'features/steps/api_navigation.rb'
- 'features/steps/default_config.rb'

# Offense count: 4
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
Expand All @@ -24,29 +54,3 @@ Style/Documentation:
- 'features/steps/default_config.rb'
- 'features/support/api.rb'
- 'features/support/fixtures.rb'

# Offense count: 2
Style/DoubleNegation:
Exclude:
- 'lib/hyperclient/curie.rb'
- 'lib/hyperclient/link.rb'

# Offense count: 3
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Exclude:
- 'lib/hyperclient/link_collection.rb'
- 'lib/hyperclient/resource.rb'
- 'lib/hyperclient/resource_collection.rb'

# Offense count: 1
Style/MethodMissingSuper:
Exclude:
- 'lib/hyperclient/collection.rb'

# Offense count: 101
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 147
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* [#268](https://github.com/codegram/hyperclient/pull/268): Replace Travis-CI with GHA - [@dblock](https://github.com/dblock).
* [#269](https://github.com/codegram/hyperclient/pull/269): Re-add code coverage - [@dblock](https://github.com/dblock).
* [#270](https://github.com/codegram/hyperclient/pull/270): Upgrade Rubocop to 1.45 - [@dblock](https://github.com/dblock).
* Your contribution here.

### 1.0.1 (2021/01/02)
Expand Down
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ end

group :development, :test do
gem 'rake'
gem 'rubocop', '0.81.0', require: false
gem 'rubocop', '~> 1.45.1', require: false
gem 'rubocop-minitest', require: false
gem 'rubocop-rake', require: false
gem 'simplecov', require: false
gem 'simplecov-lcov', require: false
end
Expand Down
33 changes: 22 additions & 11 deletions features/support/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,28 @@ module API
before do
WebMock::Config.instance.query_values_notation = :flat_array

stub_request(:any, /api.example.org*/).to_return(body: root_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org').to_return(body: root_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/authors').to_return(body: authors_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts').to_return(body: posts_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts?page=2').to_return(body: posts_page2_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts?page=3').to_return(body: posts_page3_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts/1').to_return(body: post1_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts/2').to_return(body: post2_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts/3').to_return(body: post3_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/page2').to_return(body: page2_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/page3').to_return(body: page3_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:any, /api.example.org*/).to_return(body: root_response,
headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org').to_return(body: root_response,
headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/authors').to_return(body: authors_response,
headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts').to_return(body: posts_response,
headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts?page=2').to_return(body: posts_page2_response,
headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts?page=3').to_return(body: posts_page3_response,
headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts/1').to_return(body: post1_response,
headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts/2').to_return(body: post2_response,
headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts/3').to_return(body: post3_response,
headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/page2').to_return(body: page2_response,
headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/page3').to_return(body: page3_response,
headers: { 'Content-Type' => 'application/hal+json' })
end

def api
Expand Down
2 changes: 1 addition & 1 deletion hyperclient.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Gem::Specification.new do |gem|
gem.homepage = 'https://github.com/codegram/hyperclient/'
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.name = 'hyperclient'
gem.require_paths = ['lib']
gem.version = Hyperclient::VERSION
Expand All @@ -17,4 +16,5 @@ Gem::Specification.new do |gem|
gem.add_dependency 'faraday', '>= 0.9.0'
gem.add_dependency 'faraday_hal_middleware'
gem.add_dependency 'faraday_middleware'
gem.metadata['rubygems_mfa_required'] = 'true'
end
4 changes: 1 addition & 3 deletions lib/hyperclient/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ def method_missing(method, *args, &block)
elsif !Array.method_defined?(method)
%i[_attributes _embedded _links].each do |target|
target = send(target)
if target.respond_to?(method.to_s)
return target.send(method, *args, &block)
end
return target.send(method, *args, &block) if target.respond_to?(method.to_s)
end
super
end
Expand Down
4 changes: 1 addition & 3 deletions lib/hyperclient/resource_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def initialize(collection, entry_point)
private

def build_resource(representation)
if representation.is_a?(Array)
return representation.map(&method(:build_resource))
end
return representation.map(&method(:build_resource)) if representation.is_a?(Array)

Resource.new(representation, @entry_point)
end
Expand Down
3 changes: 2 additions & 1 deletion test/hyperclient/resource_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ module Hyperclient

describe '_links' do
it '_expand' do
resource = Resource.new({ '_links' => { 'orders' => { 'href' => '/orders/{id}', 'templated' => true } } }, entry_point)
resource = Resource.new({ '_links' => { 'orders' => { 'href' => '/orders/{id}', 'templated' => true } } },
entry_point)
_(resource._links.orders._expand(id: 1)._url).must_equal '/orders/1'
_(resource.orders._expand(id: 1)._url).must_equal '/orders/1'
_(resource.orders(id: 1)._url).must_equal '/orders/1'
Expand Down

0 comments on commit c10e392

Please sign in to comment.