Skip to content

Commit

Permalink
Update rubocop to 1.39.0 (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHawley authored Nov 14, 2022
1 parent 8f43c36 commit af40822
Showing 34 changed files with 278 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ source 'https://rubygems.org'
gem "activesupport", require: false
gem "parser"
gem "pry", require: false
gem "rubocop", "1.36.0", require: false
gem "rubocop", "1.39.0", require: false
gem "rubocop-i18n", require: false
gem "rubocop-graphql", require: false
gem "rubocop-minitest", require: false
42 changes: 21 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -24,49 +24,49 @@ GEM
rack (3.0.0)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.5.0)
regexp_parser (2.6.0)
rexml (3.2.5)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.1)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.0)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.1)
rubocop (1.36.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.39.0)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.20.1, < 2.0)
rubocop-ast (>= 1.23.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.21.0)
rubocop-ast (1.23.0)
parser (>= 3.1.1.0)
rubocop-graphql (0.14.6)
rubocop-graphql (0.18.0)
rubocop (>= 0.87, < 2)
rubocop-i18n (3.0.0)
rubocop (~> 1.0)
rubocop-minitest (0.22.1)
rubocop-minitest (0.23.2)
rubocop (>= 0.90, < 2.0)
rubocop-performance (1.15.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.16.1)
rubocop-rails (2.17.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.13.2)
rubocop-rspec (2.15.0)
rubocop (~> 1.33)
rubocop-sequel (0.3.4)
rubocop (~> 1.0)
@@ -77,7 +77,7 @@ GEM
rubocop-thread_safety (0.4.4)
rubocop (>= 0.53.0)
ruby-progressbar (1.11.0)
test-prof (1.0.10)
test-prof (1.0.11)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
unicode-display_width (2.3.0)
@@ -91,7 +91,7 @@ DEPENDENCIES
pry
rake
rspec
rubocop (= 1.36.0)
rubocop (= 1.39.0)
rubocop-graphql
rubocop-i18n
rubocop-minitest
3 changes: 3 additions & 0 deletions config/contents/layout/space_inside_array_percent_literal.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Checks for unnecessary additional spaces inside array percent literals
(i.e. %i/%w).

Note that blank percent literals (e.g. `%i( )`) are checked by
`Layout/SpaceInsidePercentLiteralDelimiters`.

### Example:

# bad
8 changes: 6 additions & 2 deletions config/contents/layout/space_inside_hash_literal_braces.md
Original file line number Diff line number Diff line change
@@ -41,10 +41,13 @@ surrounding space depending on configuration.
# bad
foo = { }
bar = { }
baz = {
}

# good
foo = {}
bar = {}
baz = {}

### Example: EnforcedStyleForEmptyBraces: space
# The `space` EnforcedStyleForEmptyBraces style enforces that
@@ -55,5 +58,6 @@ surrounding space depending on configuration.

# good
foo = { }
foo = { }
foo = { }
foo = { }
foo = {
}
Original file line number Diff line number Diff line change
@@ -3,11 +3,28 @@ Checks for unnecessary additional spaces inside the delimiters of

### Example:

# bad
%i( foo bar baz )

# good
%i(foo bar baz)

# bad
%w( foo bar baz )

# good
%w(foo bar baz)

# bad
%x( ls -l )

# good
%x(ls -l)

# bad
%x( ls -l )
%w( )
%w(
)

# good
%w()
4 changes: 4 additions & 0 deletions config/contents/layout/space_inside_reference_brackets.md
Original file line number Diff line number Diff line change
@@ -33,6 +33,8 @@ surrounding space depending on configuration.
# bad
foo[ ]
foo[ ]
foo[
]

# good
foo[]
@@ -44,6 +46,8 @@ surrounding space depending on configuration.
# bad
foo[]
foo[ ]
foo[
]

# good
foo[ ]
2 changes: 1 addition & 1 deletion config/contents/lint/ambiguous_block_association.md
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ By default, there are no methods to allowed.
# bad
expect { do_something }.to change { object.attribute }

### Example: AllowedPatterns: [/change/]
### Example: AllowedPatterns: ['change']

# good
expect { do_something }.to change { object.attribute }
21 changes: 21 additions & 0 deletions config/contents/lint/duplicate_magic_comment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Checks for duplicated magic comments.

### Example:

# bad

# encoding: ascii
# encoding: ascii

# good

# encoding: ascii

# bad

# frozen_string_literal: true
# frozen_string_literal: true

# good

# frozen_string_literal: true
41 changes: 40 additions & 1 deletion config/contents/lint/nested_method_definition.md
Original file line number Diff line number Diff line change
@@ -25,6 +25,9 @@ Checks for nested method definitions.

# good

# `class_eval`, `instance_eval`, `module_eval`, `class_exec`, `instance_exec`, and
# `module_exec` blocks are allowed by default.

def foo
self.class.class_eval do
def bar
@@ -48,4 +51,40 @@ Checks for nested method definitions.
def bar
end
end
end
end

### Example: AllowedMethods: [] (default)
# bad
def do_something
has_many :articles do
def find_or_create_by_name(name)
end
end
end

### Example: AllowedMethods: ['has_many']
# bad
def do_something
has_many :articles do
def find_or_create_by_name(name)
end
end
end

### Example: AllowedPatterns: [] (default)
# bad
def foo(obj)
obj.do_baz do
def bar
end
end
end

### Example: AllowedPatterns: ['baz']
# good
def foo(obj)
obj.do_baz do
def bar
end
end
end
2 changes: 1 addition & 1 deletion config/contents/lint/number_conversion.md
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ input if it is not a standard class.
# bad
10.minutes.to_i

### Example: AllowedPatterns: [/min*/]
### Example: AllowedPatterns: ['min*']

# good
10.minutes.to_i
4 changes: 4 additions & 0 deletions config/contents/lint/ordered_magic_comments.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,10 @@
Checks the proper ordering of magic comments and whether
a magic comment is not placed before a shebang.

### Safety:

This cop's autocorrection is unsafe because file encoding may change.

### Example:
# bad

2 changes: 1 addition & 1 deletion config/contents/lint/out_of_range_regexp_ref.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This cops looks for references of Regexp captures that are out of range
Looks for references of Regexp captures that are out of range
and thus always returns nil.

### Safety:
14 changes: 12 additions & 2 deletions config/contents/lint/redundant_require_statement.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
Checks for unnecessary `require` statement.

The following features are unnecessary `require` statement because
they are already loaded.
they are already loaded. e.g. Ruby 2.2:

ruby -ve 'p $LOADED_FEATURES.reject { |feature| %r|/| =~ feature }'
ruby 2.2.8p477 (2017-09-14 revision 59906) [x86_64-darwin13]
["enumerator.so", "rational.so", "complex.so", "thread.rb"]

This cop targets Ruby 2.2 or higher containing these 4 features.
Below are the features that each `TargetRubyVersion` targets.

* 2.0+ ... `enumerator`
* 2.1+ ... `thread`
* 2.2+ ... Add `rational` and `complex` above
* 2.5+ ... Add `pp` above
* 2.7+ ... Add `ruby2_keywords` above
* 3.1+ ... Add `fiber` above
* 3.2+ ... `set`

This cop target those features.

### Example:
# bad
2 changes: 2 additions & 0 deletions config/contents/lint/shadowing_outer_local_variable.md
Original file line number Diff line number Diff line change
@@ -7,9 +7,11 @@ NOTE: Shadowing of variables in block passed to `Ractor.new` is allowed
because `Ractor` should not access outer variables.
eg. following style is encouraged:

```ruby
worker_id, pipe = env
Ractor.new(worker_id, pipe) do |worker_id, pipe|
end
```

### Example:

2 changes: 1 addition & 1 deletion config/contents/lint/unreachable_loop.md
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ code that would otherwise be registered as an offense (eg. `times` used not in a
# bad
2.times { raise ArgumentError }

### Example: AllowedPatterns: [/(exactly|at_least|at_most)\(\d+\)\.times/] (default)
### Example: AllowedPatterns: ['(exactly|at_least|at_most)\(\d+\)\.times'] (default)

# good
exactly(2).times { raise StandardError }
2 changes: 1 addition & 1 deletion config/contents/metrics/abc_size.md
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ is meant to distinguish actual `attr_reader` from other methods.

### Example: CountRepeatedAttributes: false (default is true)

# `model` and `current_user`, refenced 3 times each,
# `model` and `current_user`, referenced 3 times each,
# are each counted as only 1 branch each if
# `CountRepeatedAttributes` is set to 'false'

2 changes: 1 addition & 1 deletion config/contents/naming/inclusive_language.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This cops recommends the use of inclusive language instead of problematic terms.
Recommends the use of inclusive language instead of problematic terms.
The cop can check the following locations for offenses:
- identifiers
- constants
2 changes: 1 addition & 1 deletion config/contents/style/block_delimiters.md
Original file line number Diff line number Diff line change
@@ -151,7 +151,7 @@ Additional methods can be added to the `AllowedMethods`.
process(something)
}

### Example: AllowedPatterns: [/map/]
### Example: AllowedPatterns: ['map']

# good
things.map { |thing|
2 changes: 1 addition & 1 deletion config/contents/style/class_equality_comparison.md
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ These are customizable with `AllowedMethods` option.
var.class.eql?(Date)
var.class.name == 'Date'

### Example: AllowedPatterns: [`/eq/`]
### Example: AllowedPatterns: ['eq']
# good
var.instance_of?(Date)
var.class.equal?(Date)
4 changes: 3 additions & 1 deletion config/contents/style/collection_compact.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,9 @@ and hashes can be replaced with `{Array,Hash}#{compact,compact!}`.
### Safety:

It is unsafe by default because false positives may occur in the
`nil` check of block arguments to the receiver object.
`nil` check of block arguments to the receiver object. Additionally,
we can't know the type of the receiver object for sure, which may
result in false positives as well.

For example, `[[1, 2], [3, nil]].reject { |first, second| second.nil? }`
and `[[1, 2], [3, nil]].compact` are not compatible. This will work fine
2 changes: 1 addition & 1 deletion config/contents/style/endless_method.md
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ corrected to a multi-line definition.

### Example: EnforcedStyle: disallow
# bad
def my_method; x end
def my_method() = x

# bad
def my_method() = x.foo
2 changes: 1 addition & 1 deletion config/contents/style/format_string_token.md
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ if the number of them is less than or equals to
# bad
redirect('foo/%{bar_id}')

### Example: AllowedPatterns: [/redirect/]
### Example: AllowedPatterns: ['redirect']

# good
redirect('foo/%{bar_id}')
Loading
Oops, something went wrong.

0 comments on commit af40822

Please sign in to comment.