Skip to content

Update rubocop to 1.28.1 #313

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
Apr 28, 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 @@ -6,7 +6,7 @@ gem "activesupport", require: false
gem "mry", require: false
gem "parser"
gem "pry", require: false
gem "rubocop", "1.25.1", require: false
gem "rubocop", "1.28.1", require: false
gem "rubocop-i18n", require: false
gem "rubocop-graphql", require: false
gem "rubocop-minitest", require: false
Expand Down
62 changes: 31 additions & 31 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.1)
activesupport (7.0.2.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
coderay (1.1.3)
concurrent-ruby (1.1.9)
concurrent-ruby (1.1.10)
diff-lcs (1.5.0)
i18n (1.9.1)
i18n (1.10.0)
concurrent-ruby (~> 1.0)
method_source (1.0.0)
minitest (5.15.0)
mry (0.78.0.0)
rubocop (>= 0.41.0)
parallel (1.21.0)
parser (3.1.0.0)
parallel (1.22.1)
parser (3.1.2.0)
ast (~> 2.4.1)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
rack (2.2.3)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.2.0)
regexp_parser (2.3.0)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.2)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.2)
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.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.3)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.3)
rubocop (1.25.1)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
rubocop (1.28.1)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.15.1, < 2.0)
rubocop-ast (>= 1.17.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.15.1)
parser (>= 3.0.1.1)
rubocop-graphql (0.12.3)
rubocop-ast (1.17.0)
parser (>= 3.1.1.0)
rubocop-graphql (0.14.2)
rubocop (>= 0.87, < 2)
rubocop-i18n (3.0.0)
rubocop (~> 1.0)
rubocop-minitest (0.17.1)
rubocop-minitest (0.19.1)
rubocop (>= 0.90, < 2.0)
rubocop-performance (1.13.2)
rubocop-performance (1.13.3)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.13.2)
rubocop-rails (2.14.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.8.0)
rubocop-rspec (2.10.0)
rubocop (~> 1.19)
rubocop-sequel (0.3.3)
rubocop (~> 1.0)
rubocop-shopify (2.4.0)
rubocop (~> 1.24)
rubocop-sorbet (0.6.5)
rubocop-shopify (2.5.0)
rubocop (~> 1.25)
rubocop-sorbet (0.6.7)
rubocop (>= 0.90.0)
rubocop-thread_safety (0.4.4)
rubocop (>= 0.53.0)
ruby-progressbar (1.11.0)
safe_yaml (1.0.5)
test-prof (1.0.7)
test-prof (1.0.8)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (2.1.0)
Expand All @@ -93,7 +93,7 @@ DEPENDENCIES
pry
rake
rspec
rubocop (= 1.25.1)
rubocop (= 1.28.1)
rubocop-graphql
rubocop-i18n
rubocop-minitest
Expand Down
4 changes: 2 additions & 2 deletions config/contents/gemspec/date_assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ It is set automatically when the gem is packaged.

# bad
Gem::Specification.new do |spec|
s.name = 'your_cool_gem_name'
spec.name = 'your_cool_gem_name'
spec.date = Time.now.strftime('%Y-%m-%d')
end

# good
Gem::Specification.new do |spec|
s.name = 'your_cool_gem_name'
spec.name = 'your_cool_gem_name'
end
7 changes: 4 additions & 3 deletions config/contents/gemspec/require_mfa.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Requires a gemspec to have `rubygems_mfa_required` metadata set.

This setting tells RubyGems that MFA is required for accounts to
be able perform privileged operations, such as (see
RubyGems' documentation for the full list of privileged operations):
This setting tells RubyGems that MFA (Multi-Factor Authentication) is
required for accounts to be able perform privileged operations, such as
(see RubyGems' documentation for the full list of privileged
operations):

* `gem push`
* `gem yank`
Expand Down
2 changes: 1 addition & 1 deletion config/contents/layout/case_indentation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This cop checks how the `when` and `in`s of a `case` expression
This cop checks how the `when` and ``in``s of a `case` expression
are indented in relation to its `case` or `end` keyword.

It will register a separate offense for each misaligned `when` and `in`.
Expand Down
2 changes: 1 addition & 1 deletion config/contents/layout/indentation_width.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ one.
end
end

### Example: IgnoredPatterns: ['^\s*module']
### Example: AllowedPatterns: ['^\s*module']
# bad
module A
class B
Expand Down
15 changes: 7 additions & 8 deletions config/contents/layout/multiline_operation_indentation.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
This cop checks the indentation of the right hand side operand in
binary operations that span more than one line.
This cop checks the indentation of the right hand side operand in binary operations that
span more than one line.

The `aligned` style checks that operators are aligned if they are part
of an `if` or `while` condition, a `return` statement, etc. In other
contexts, the second operand should be indented regardless of enforced
style.
The `aligned` style checks that operators are aligned if they are part of an `if` or `while`
condition, an explicit `return` statement, etc. In other contexts, the second operand should
be indented regardless of enforced style.

### Example: EnforcedStyle: aligned (default)
# bad
if a +
b
something &&
something_else
something_else
end

# good
if a +
b
something &&
something_else
something_else
end

### Example: EnforcedStyle: indented
Expand Down
5 changes: 5 additions & 0 deletions config/contents/lint/duplicate_require.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
This cop checks for duplicate `require`s and `require_relative`s.

### Safety:

This cop's autocorrection is unsafe because it may break the dependency order
of `require`.

### Example:
# bad
require 'foo'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@

This cop checks for `IO.select` that is incompatible with Fiber Scheduler since Ruby 3.0.

NOTE: When the method is successful the return value of `IO.select` is `[[IO]]`,
and the return value of `io.wait_readable` and `io.wait_writable` are `self`.
They are not auto-corrected when assigning a return value because these types are different.
It's up to user how to handle the return value.

### Safety:

This cop's autocorrection is unsafe because `NoMethodError` occurs
if `require 'io/wait'` is not called.

### Example:

# bad
Expand All @@ -14,8 +24,3 @@ This cop checks for `IO.select` that is incompatible with Fiber Scheduler since

# good
io.wait_writable(timeout)

### Safety:

This cop's autocorrection is unsafe because `NoMethodError` occurs
if `require 'io/wait'` is not called.
25 changes: 15 additions & 10 deletions config/contents/lint/inherit_exception.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
This cop looks for error classes inheriting from `Exception`
and its standard library subclasses, excluding subclasses of
`StandardError`. It is configurable to suggest using either
`RuntimeError` (default) or `StandardError` instead.
This cop looks for error classes inheriting from `Exception`.
It is configurable to suggest using either `StandardError` (default) or
`RuntimeError` instead.

### Example: EnforcedStyle: runtime_error (default)
### Safety:

This cop's autocorrection is unsafe because `rescue` that omit
exception class handle `StandardError` and its subclasses,
but not `Exception` and its subclasses.

### Example: EnforcedStyle: standard_error (default)
# bad

class C < Exception; end
Expand All @@ -12,11 +17,11 @@ and its standard library subclasses, excluding subclasses of

# good

class C < RuntimeError; end
class C < StandardError; end

C = Class.new(RuntimeError)
C = Class.new(StandardError)

### Example: EnforcedStyle: standard_error
### Example: EnforcedStyle: runtime_error
# bad

class C < Exception; end
Expand All @@ -25,6 +30,6 @@ and its standard library subclasses, excluding subclasses of

# good

class C < StandardError; end
class C < RuntimeError; end

C = Class.new(StandardError)
C = Class.new(RuntimeError)
6 changes: 6 additions & 0 deletions config/contents/lint/redundant_dir_glob_sort.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Sort globbed results by default in Ruby 3.0.
This cop checks for redundant `sort` method to `Dir.glob` and `Dir[]`.

### Safety:

This cop is unsafe, in case of having a file and a directory with
identical names, since directory will be loaded before the file, which
will break `exe/files.rb` that rely on `exe.rb` file.

### Example:

# bad
Expand Down
28 changes: 28 additions & 0 deletions config/contents/lint/refinement_import_methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
This cop checks if `include` or `prepend` is called in `refine` block.
These methods are deprecated and should be replaced with `Refinement#import_methods`.

It emulates deprecation warnings in Ruby 3.1.

### Safety:

This cop's autocorrection is unsafe because `include M` will affect the included class
if any changes are made to module `M`.
On the other hand, `import_methods M` uses a snapshot of method definitions,
thus it will not be affected if module `M` changes.

### Example:

# bad
refine Foo do
include Bar
end

# bad
refine Foo do
prepend Bar
end

# good
refine Foo do
import_methods Bar
end
4 changes: 2 additions & 2 deletions config/contents/lint/unreachable_loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ the code should be refactored to use `if` conditionals.

NOTE: Block methods that are used with `Enumerable`s are considered to be loops.

`IgnoredPatterns` can be used to match against the block receiver in order to allow
`AllowedPatterns` can be used to match against the block receiver in order to allow
code that would otherwise be registered as an offense (eg. `times` used not in an
`Enumerable` context).

Expand Down 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: IgnoredPatterns: [/(exactly|at_least|at_most)\(\d+\)\.times/] (default)
### Example: AllowedPatterns: [/(exactly|at_least|at_most)\(\d+\)\.times/] (default)

# good
exactly(2).times { raise StandardError }
4 changes: 2 additions & 2 deletions config/contents/naming/method_name.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
This cop makes sure that all methods use the configured style,
snake_case or camelCase, for their names.

This cop has `IgnoredPatterns` configuration option.
This cop has `AllowedPatterns` configuration option.

Naming/MethodName:
IgnoredPatterns:
AllowedPatterns:
- '\A\s*onSelectionBulkChange\s*'
- '\A\s*onSelectionCleared\s*'

Expand Down
24 changes: 24 additions & 0 deletions config/contents/security/compound_hash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This cop checks for implementations of the `hash` method which combine
values using custom logic instead of delegating to `Array#hash`.

Manually combining hashes is error prone and hard to follow, especially
when there are many values. Poor implementations may also introduce
performance or security concerns if they are prone to collisions.
Delegating to `Array#hash` is clearer, faster, and safer.

### Safety:

This cop may be unsafe if the application logic depends on the hash
value, however this is inadvisable anyway.

### Example:

# bad
def hash
@foo ^ @bar
end

# good
def hash
[@foo, @bar].hash
end
Loading