Skip to content

Commit 4c5154e

Browse files
authored
Update rubocop to 1.24.1 (#309)
- General bundle update for Ruby 3.1 compatibility. - Update the docs too. - Fix a constant resolution issue with active_support 7.
1 parent 51b2d1f commit 4c5154e

19 files changed

+221
-29
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.23.0", require: false
9+
gem "rubocop", "1.24.1", require: false
1010
gem "rubocop-i18n", require: false
1111
gem "rubocop-graphql", require: false
1212
gem "rubocop-minitest", require: false

Gemfile.lock

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
activesupport (6.1.4.1)
4+
activesupport (7.0.0)
55
concurrent-ruby (~> 1.0, >= 1.0.2)
66
i18n (>= 1.6, < 2)
77
minitest (>= 5.1)
88
tzinfo (~> 2.0)
9-
zeitwerk (~> 2.3)
109
ast (2.4.2)
1110
coderay (1.1.3)
1211
concurrent-ruby (1.1.9)
13-
diff-lcs (1.4.4)
12+
diff-lcs (1.5.0)
1413
i18n (1.8.11)
1514
concurrent-ruby (~> 1.0)
1615
method_source (1.0.0)
17-
minitest (5.14.4)
16+
minitest (5.15.0)
1817
mry (0.78.0.0)
1918
rubocop (>= 0.41.0)
2019
parallel (1.21.0)
21-
parser (3.0.3.1)
20+
parser (3.1.0.0)
2221
ast (~> 2.4.1)
2322
pry (0.14.1)
2423
coderay (~> 1.1)
@@ -41,37 +40,39 @@ GEM
4140
diff-lcs (>= 1.2.0, < 2.0)
4241
rspec-support (~> 3.10.0)
4342
rspec-support (3.10.3)
44-
rubocop (1.23.0)
43+
rubocop (1.24.1)
4544
parallel (~> 1.10)
4645
parser (>= 3.0.0.0)
4746
rainbow (>= 2.2.2, < 4.0)
4847
regexp_parser (>= 1.8, < 3.0)
4948
rexml
50-
rubocop-ast (>= 1.12.0, < 2.0)
49+
rubocop-ast (>= 1.15.1, < 2.0)
5150
ruby-progressbar (~> 1.7)
5251
unicode-display_width (>= 1.4.0, < 3.0)
53-
rubocop-ast (1.14.0)
52+
rubocop-ast (1.15.1)
5453
parser (>= 3.0.1.1)
55-
rubocop-graphql (0.11.2)
54+
rubocop-graphql (0.12.0)
5655
rubocop (>= 0.87, < 2)
5756
rubocop-i18n (3.0.0)
5857
rubocop (~> 1.0)
5958
rubocop-minitest (0.17.0)
6059
rubocop (>= 0.90, < 2.0)
61-
rubocop-performance (1.12.0)
60+
rubocop-performance (1.13.1)
6261
rubocop (>= 1.7.0, < 2.0)
6362
rubocop-ast (>= 0.4.0)
64-
rubocop-rails (2.12.4)
63+
rubocop-rails (2.13.0)
6564
activesupport (>= 4.2.0)
6665
rack (>= 1.1)
6766
rubocop (>= 1.7.0, < 2.0)
6867
rubocop-rake (0.6.0)
6968
rubocop (~> 1.0)
70-
rubocop-rspec (2.6.0)
69+
rubocop-rspec (2.7.0)
7170
rubocop (~> 1.19)
7271
rubocop-sequel (0.3.3)
7372
rubocop (~> 1.0)
74-
rubocop-sorbet (0.6.3)
73+
rubocop-shopify (2.3.0)
74+
rubocop (~> 1.22)
75+
rubocop-sorbet (0.6.5)
7576
rubocop (>= 0.90.0)
7677
rubocop-thread_safety (0.4.4)
7778
rubocop (>= 0.53.0)
@@ -81,7 +82,6 @@ GEM
8182
tzinfo (2.0.4)
8283
concurrent-ruby (~> 1.0)
8384
unicode-display_width (2.1.0)
84-
zeitwerk (2.5.1)
8585

8686
PLATFORMS
8787
ruby
@@ -93,7 +93,7 @@ DEPENDENCIES
9393
pry
9494
rake
9595
rspec
96-
rubocop (= 1.23.0)
96+
rubocop (= 1.24.1)
9797
rubocop-graphql
9898
rubocop-i18n
9999
rubocop-minitest
@@ -102,6 +102,7 @@ DEPENDENCIES
102102
rubocop-rake
103103
rubocop-rspec
104104
rubocop-sequel
105+
rubocop-shopify
105106
rubocop-sorbet
106107
rubocop-thread_safety
107108
safe_yaml

config/contents/gemspec/require_mfa.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
Requires a gemspec to have `rubygems_mfa_required` metadata set.
22

33
This setting tells RubyGems that MFA is required for accounts to
4-
be able perform any of these privileged operations:
4+
be able perform privileged operations, such as (see
5+
RubyGems' documentation for the full list of privileged operations):
56

6-
* gem push
7-
* gem yank
8-
* gem owner --add/remove
7+
* `gem push`
8+
* `gem yank`
9+
* `gem owner --add/remove`
910
* adding or removing owners using gem ownership page
1011

1112
This helps make your gem more secure, as users can be more
1213
confident that gem updates were pushed by maintainers.
1314

1415
### Example:
15-
1616
# bad
1717
Gem::Specification.new do |spec|
1818
# no `rubygems_mfa_required` metadata specified

config/contents/layout/comment_indentation.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,17 @@ This cop checks the indentation of comments.
2626
if true
2727
true
2828
end
29+
30+
### Example: AllowForAlignment: false (default)
31+
# bad
32+
a = 1 # A really long comment
33+
# spanning two lines.
34+
35+
# good
36+
# A really long comment spanning one line.
37+
a = 1
38+
39+
### Example: AllowForAlignment: true
40+
# good
41+
a = 1 # A really long comment
42+
# spanning two lines.

config/contents/lint/deprecated_class_methods.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This cop checks for uses of the deprecated class method usages.
77
File.exists?(some_path)
88
Dir.exists?(some_path)
99
iterator?
10+
ENV.freeze # Calling `Env.freeze` raises `TypeError` since Ruby 2.7.
1011
Socket.gethostbyname(host)
1112
Socket.gethostbyaddr(host)
1213

@@ -17,5 +18,6 @@ This cop checks for uses of the deprecated class method usages.
1718
File.exist?(some_path)
1819
Dir.exist?(some_path)
1920
block_given?
21+
ENV # `ENV.freeze` cannot prohibit changes to environment variables.
2022
Addrinfo.getaddrinfo(nodename, service)
2123
Addrinfo.tcp(host, port).getnameinfo

config/contents/lint/incompatible_io_select_with_fiber_scheduler.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ This cop checks for `IO.select` that is incompatible with Fiber Scheduler since
1414

1515
# good
1616
io.wait_writable(timeout)
17+
18+
### Safety:
19+
20+
This cop's autocorrection is unsafe because `NoMethodError` occurs
21+
if `require 'io/wait'` is not called.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
In Ruby 3.1, anonymous block forwarding has been added.
2+
3+
This cop identifies places where `do_something(&block)` can be replaced
4+
by `do_something(&)`.
5+
6+
It also supports the opposite style by alternative `explicit` option.
7+
8+
### Example: EnforcedStyle: anonymous (default)
9+
10+
# bad
11+
def foo(&block)
12+
bar(&block)
13+
end
14+
15+
# good
16+
def foo(&)
17+
bar(&)
18+
end
19+
20+
### Example: EnforcedStyle: explicit
21+
22+
# bad
23+
def foo(&)
24+
bar(&)
25+
end
26+
27+
# good
28+
def foo(&block)
29+
bar(&block)
30+
end

config/contents/security/open.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
This cop checks for the use of `Kernel#open` and `URI.open`.
1+
This cop checks for the use of `Kernel#open` and `URI.open` with dynamic
2+
data.
23

34
`Kernel#open` and `URI.open` enable not only file access but also process
45
invocation by prefixing a pipe symbol (e.g., `open("| ls")`).
56
So, it may lead to a serious security risk by using variable input to
67
the argument of `Kernel#open` and `URI.open`. It would be better to use
78
`File.open`, `IO.popen` or `URI.parse#open` explicitly.
89

10+
NOTE: `open` and `URI.open` with literal strings are not flagged by this
11+
cop.
12+
913
### Safety:
1014

1115
This cop could register false positives if `open` is redefined
@@ -14,9 +18,15 @@ in a class and then used without a receiver in that class.
1418
### Example:
1519
# bad
1620
open(something)
21+
open("| #{something}")
1722
URI.open(something)
1823

1924
# good
2025
File.open(something)
2126
IO.popen(something)
22-
URI.parse(something).open
27+
URI.parse(something).open
28+
29+
# good (literal strings)
30+
open("foo.text")
31+
open("| foo")
32+
URI.open("http://example.com")
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
Checks for uses of the character literal ?x.
2+
Starting with Ruby 1.9 character literals are
3+
essentially one-character strings, so this syntax
4+
is mostly redundant at this point.
5+
6+
? character literal can be used to express meta and control character.
7+
That's a good use case of ? literal so it doesn't count it as an offense.
28

39
### Example:
410
# bad
@@ -7,5 +13,6 @@ Checks for uses of the character literal ?x.
713
# good
814
'x'
915

10-
# good
11-
?\C-\M-d
16+
# good - control & meta escapes
17+
?\C-\M-d
18+
"\C-\M-d" # same as above

config/contents/style/collection_compact.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ when the receiver is a hash object.
1212

1313
### Example:
1414
# bad
15+
array.reject(&:nil?)
1516
array.reject { |e| e.nil? }
1617
array.select { |e| !e.nil? }
1718

1819
# good
1920
array.compact
2021

2122
# bad
23+
hash.reject!(&:nil?)
2224
hash.reject! { |k, v| v.nil? }
2325
hash.select! { |k, v| !v.nil? }
2426

0 commit comments

Comments
 (0)