Skip to content

Commit db5b8f3

Browse files
authored
Update rubocop to 1.23.0 (#306)
[Fixes #305]
1 parent 08bb168 commit db5b8f3

File tree

12 files changed

+210
-15
lines changed

12 files changed

+210
-15
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ gem "activesupport", require: false
66
gem "mry", require: false
77
gem "parser"
88
gem "pry", require: false
9-
gem "rubocop", "1.22.3", require: false
9+
gem "rubocop", "1.23.0", require: false
1010
gem "rubocop-i18n", require: false
1111
gem "rubocop-graphql", require: false
1212
gem "rubocop-minitest", require: false

Gemfile.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ GEM
1818
mry (0.78.0.0)
1919
rubocop (>= 0.41.0)
2020
parallel (1.21.0)
21-
parser (3.0.2.0)
21+
parser (3.0.3.1)
2222
ast (~> 2.4.1)
2323
pry (0.14.1)
2424
coderay (~> 1.1)
2525
method_source (~> 1.0)
2626
rack (2.2.3)
2727
rainbow (3.0.0)
2828
rake (13.0.6)
29-
regexp_parser (2.1.1)
29+
regexp_parser (2.2.0)
3030
rexml (3.2.5)
3131
rspec (3.10.0)
3232
rspec-core (~> 3.10.0)
@@ -41,7 +41,7 @@ GEM
4141
diff-lcs (>= 1.2.0, < 2.0)
4242
rspec-support (~> 3.10.0)
4343
rspec-support (3.10.3)
44-
rubocop (1.22.3)
44+
rubocop (1.23.0)
4545
parallel (~> 1.10)
4646
parser (>= 3.0.0.0)
4747
rainbow (>= 2.2.2, < 4.0)
@@ -50,13 +50,13 @@ GEM
5050
rubocop-ast (>= 1.12.0, < 2.0)
5151
ruby-progressbar (~> 1.7)
5252
unicode-display_width (>= 1.4.0, < 3.0)
53-
rubocop-ast (1.12.0)
53+
rubocop-ast (1.14.0)
5454
parser (>= 3.0.1.1)
55-
rubocop-graphql (0.10.2)
55+
rubocop-graphql (0.11.2)
5656
rubocop (>= 0.87, < 2)
5757
rubocop-i18n (3.0.0)
5858
rubocop (~> 1.0)
59-
rubocop-minitest (0.15.2)
59+
rubocop-minitest (0.17.0)
6060
rubocop (>= 0.90, < 2.0)
6161
rubocop-performance (1.12.0)
6262
rubocop (>= 1.7.0, < 2.0)
@@ -67,12 +67,12 @@ GEM
6767
rubocop (>= 1.7.0, < 2.0)
6868
rubocop-rake (0.6.0)
6969
rubocop (~> 1.0)
70-
rubocop-rspec (2.5.0)
70+
rubocop-rspec (2.6.0)
7171
rubocop (~> 1.19)
7272
rubocop-sequel (0.3.3)
7373
rubocop (~> 1.0)
74-
rubocop-sorbet (0.6.2)
75-
rubocop
74+
rubocop-sorbet (0.6.3)
75+
rubocop (>= 0.90.0)
7676
rubocop-thread_safety (0.4.4)
7777
rubocop (>= 0.53.0)
7878
ruby-progressbar (1.11.0)
@@ -93,7 +93,7 @@ DEPENDENCIES
9393
pry
9494
rake
9595
rspec
96-
rubocop (= 1.22.3)
96+
rubocop (= 1.23.0)
9797
rubocop-graphql
9898
rubocop-i18n
9999
rubocop-minitest
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Requires a gemspec to have `rubygems_mfa_required` metadata set.
2+
3+
This setting tells RubyGems that MFA is required for accounts to
4+
be able perform any of these privileged operations:
5+
6+
* gem push
7+
* gem yank
8+
* gem owner --add/remove
9+
* adding or removing owners using gem ownership page
10+
11+
This helps make your gem more secure, as users can be more
12+
confident that gem updates were pushed by maintainers.
13+
14+
### Example:
15+
16+
# bad
17+
Gem::Specification.new do |spec|
18+
# no `rubygems_mfa_required` metadata specified
19+
end
20+
21+
# good
22+
Gem::Specification.new do |spec|
23+
spec.metadata = {
24+
'rubygems_mfa_required' => 'true'
25+
}
26+
end
27+
28+
# good
29+
Gem::Specification.new do |spec|
30+
spec.metadata['rubygems_mfa_required'] = 'true'
31+
end
32+
33+
# bad
34+
Gem::Specification.new do |spec|
35+
spec.metadata = {
36+
'rubygems_mfa_required' => 'false'
37+
}
38+
end
39+
40+
# good
41+
Gem::Specification.new do |spec|
42+
spec.metadata = {
43+
'rubygems_mfa_required' => 'true'
44+
}
45+
end
46+
47+
# bad
48+
Gem::Specification.new do |spec|
49+
spec.metadata['rubygems_mfa_required'] = 'false'
50+
end
51+
52+
# good
53+
Gem::Specification.new do |spec|
54+
spec.metadata['rubygems_mfa_required'] = 'true'
55+
end

config/contents/layout/empty_line_between_defs.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,30 @@ one-line definitions are considered an offense.
7272
def b
7373
end
7474

75-
### Example: AllowAdjacentOneLineDefs: true
75+
### Example: AllowAdjacentOneLineDefs: true (default)
7676

7777
# good
7878
class ErrorA < BaseError; end
7979
class ErrorB < BaseError; end
8080
class ErrorC < BaseError; end
81+
82+
# good
83+
class ErrorA < BaseError; end
84+
85+
class ErrorB < BaseError; end
86+
87+
class ErrorC < BaseError; end
88+
89+
### Example: AllowAdjacentOneLineDefs: false
90+
91+
# bad
92+
class ErrorA < BaseError; end
93+
class ErrorB < BaseError; end
94+
class ErrorC < BaseError; end
95+
96+
# good
97+
class ErrorA < BaseError; end
98+
99+
class ErrorB < BaseError; end
100+
101+
class ErrorC < BaseError; end

config/contents/lint/ambiguous_range.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ This cop checks for ambiguous ranges.
33
Ranges have quite low precedence, which leads to unexpected behaviour when
44
using a range with other operators. This cop avoids that by making ranges
55
explicit by requiring parenthesis around complex range boundaries (anything
6-
that is not a basic literal: numerics, strings, symbols, etc.).
6+
that is not a literal: numerics, strings, symbols, etc.).
77

88
This cop can be configured with `RequireParenthesesForMethodChains` in order to
99
specify whether method chains (including `self.foo`) should be wrapped in parens

config/contents/lint/number_conversion.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ input if it is not a standard class.
2626
'10'.to_i
2727
'10.2'.to_f
2828
'10'.to_c
29+
'1/3'.to_r
2930
['1', '2', '3'].map(&:to_i)
3031
foo.try(:to_f)
3132
bar.send(:to_c)
@@ -35,6 +36,7 @@ input if it is not a standard class.
3536
Integer('10', 10)
3637
Float('10.2')
3738
Complex('10')
39+
Rational('1/3')
3840
['1', '2', '3'].map { |i| Integer(i, 10) }
3941
foo.try { |i| Float(i) }
4042
bar.send { |i| Complex(i) }
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
This cop looks for `ruby2_keywords` calls for methods that do not need it.
2+
3+
`ruby2_keywords` should only be called on methods that accept an argument splat
4+
(`*args`) but do not explicit keyword arguments (`k:` or `k: true`) or
5+
a keyword splat (`**kwargs`).
6+
7+
### Example:
8+
# good (splat argument without keyword arguments)
9+
ruby2_keywords def foo(*args); end
10+
11+
# bad (no arguments)
12+
ruby2_keywords def foo; end
13+
14+
# good
15+
def foo; end
16+
17+
# bad (positional argument)
18+
ruby2_keywords def foo(arg); end
19+
20+
# good
21+
def foo(arg); end
22+
23+
# bad (double splatted argument)
24+
ruby2_keywords def foo(**args); end
25+
26+
# good
27+
def foo(**args); end
28+
29+
# bad (keyword arguments)
30+
ruby2_keywords def foo(i:, j:); end
31+
32+
# good
33+
def foo(i:, j:); end
34+
35+
# bad (splat argument with keyword arguments)
36+
ruby2_keywords def foo(*args, i:, j:); end
37+
38+
# good
39+
def foo(*args, i:, j:); end
40+
41+
# bad (splat argument with double splat)
42+
ruby2_keywords def foo(*args, **kwargs); end
43+
44+
# good
45+
def foo(*args, **kwargs); end
46+
47+
# bad (ruby2_keywords given a symbol)
48+
def foo; end
49+
ruby2_keywords :foo
50+
51+
# good
52+
def foo; end
53+
54+
# bad (ruby2_keywords with dynamic method)
55+
define_method(:foo) { |arg| }
56+
ruby2_keywords :foo
57+
58+
# good
59+
define_method(:foo) { |arg| }

config/contents/metrics/parameter_lists.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Keyword arguments can optionally be excluded from the total count,
55
as they add less complexity than positional or optional parameters.
66

77
NOTE: Explicit block argument `&block` is not counted to prevent
8-
erroneous change that is avoided by making block argument implicit.
8+
erroneous change that is avoided by making block argument implicit.
99

1010
### Example: Max: 3
1111
# good

config/contents/naming/file_name.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ recommends using dashes to separate namespaces in nested gems
77
(i.e. `bundler-console` becomes `Bundler::Console`). As such, the
88
gemspec is supposed to be named `bundler-console.gemspec`.
99

10+
When `ExpectMatchingDefinition` (default: `false`) is `true`, the cop requires
11+
each file to have a class, module or `Struct` defined in it that matches
12+
the filename. This can be further configured using
13+
`CheckDefinitionPathHierarchy` (default: `true`) to determine whether the
14+
path should match the namespace of the above definition.
15+
16+
When `IgnoreExecutableScripts` (default: `true`) is `true`, files that start
17+
with a shebang line are not considered by the cop.
18+
19+
When `Regex` is set, the cop will flag any filename that does not match
20+
the regular expression.
21+
1022
### Example:
1123
# bad
1224
lib/layoutManager.rb

config/contents/style/empty_method.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ line (compact style), but it can be configured to enforce the `end`
44
to go on its own line (expanded style).
55

66
NOTE: A method definition is not considered empty if it contains
7-
comments.
7+
comments.
88

99
### Example: EnforcedStyle: compact (default)
1010
# bad

0 commit comments

Comments
 (0)