Skip to content

Update rubocop to 1.39.0 #337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 21 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -91,7 +91,7 @@ DEPENDENCIES
pry
rake
rspec
rubocop (= 1.36.0)
rubocop (= 1.39.0)
rubocop-graphql
rubocop-i18n
rubocop-minitest
Expand Down
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
Expand Down
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
Expand Up @@ -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
Expand All @@ -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
Expand Up @@ -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
Expand Up @@ -33,6 +33,8 @@ surrounding space depending on configuration.
# bad
foo[ ]
foo[ ]
foo[
]

# good
foo[]
Expand All @@ -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
Expand Up @@ -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 }
Expand Down
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
Expand Up @@ -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
Expand All @@ -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
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions config/contents/lint/ordered_magic_comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
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:
Expand Down
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
Expand Down
2 changes: 2 additions & 0 deletions config/contents/lint/shadowing_outer_local_variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion config/contents/lint/unreachable_loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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'

Expand Down
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
Expand Down
2 changes: 1 addition & 1 deletion config/contents/style/block_delimiters.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Additional methods can be added to the `AllowedMethods`.
process(something)
}

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

# good
things.map { |thing|
Expand Down
2 changes: 1 addition & 1 deletion config/contents/style/class_equality_comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion config/contents/style/collection_compact.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/contents/style/endless_method.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/contents/style/format_string_token.md
Original file line number Diff line number Diff line change
Expand Up @@ -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