Skip to content

Commit 983a318

Browse files
committed
Update rubocop to 1.64.1
- General bundle update. - Update the docs too. - Add rubocop-capybara, rubocop-factory_bot, and rubocop-rspec_rails, because their cops have been moved out of rubocop-rspec. - Add `require "ostruct"` to a couple test files using OpenStruct.
1 parent d26ca0f commit 983a318

18 files changed

+293
-76
lines changed

Diff for: Gemfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ source 'https://rubygems.org'
55
gem "activesupport", require: false
66
gem "parser"
77
gem "pry", require: false
8-
gem "rubocop", "1.62.1", require: false
8+
gem "rubocop", "1.64.1", require: false
9+
gem "rubocop-capybara", require: false
10+
gem "rubocop-factory_bot", require: false
911
gem "rubocop-graphql", require: false
1012
gem "rubocop-i18n", require: false
1113
gem "rubocop-minitest", require: false
1214
gem "rubocop-performance", require: false
1315
gem "rubocop-rails", require: false
1416
gem "rubocop-rake", require: false
1517
gem "rubocop-rspec", require: false
18+
gem "rubocop-rspec_rails", require: false
1619
gem "rubocop-sequel", require: false
1720
gem "rubocop-shopify", require: false
1821
gem "rubocop-sorbet", require: false

Diff for: Gemfile.lock

+39-33
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
activesupport (7.1.3.2)
4+
activesupport (7.1.3.4)
55
base64
66
bigdecimal
77
concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -13,46 +13,47 @@ GEM
1313
tzinfo (~> 2.0)
1414
ast (2.4.2)
1515
base64 (0.2.0)
16-
bigdecimal (3.1.7)
16+
bigdecimal (3.1.8)
1717
coderay (1.1.3)
18-
concurrent-ruby (1.2.3)
18+
concurrent-ruby (1.3.3)
1919
connection_pool (2.4.1)
2020
diff-lcs (1.5.1)
2121
drb (2.2.1)
22-
i18n (1.14.4)
22+
i18n (1.14.5)
2323
concurrent-ruby (~> 1.0)
24-
json (2.7.1)
24+
json (2.7.2)
2525
language_server-protocol (3.17.0.3)
26-
method_source (1.0.0)
27-
minitest (5.22.3)
26+
method_source (1.1.0)
27+
minitest (5.23.1)
2828
mutex_m (0.2.0)
29-
parallel (1.24.0)
30-
parser (3.3.0.5)
29+
parallel (1.25.1)
30+
parser (3.3.3.0)
3131
ast (~> 2.4.1)
3232
racc
3333
pry (0.14.2)
3434
coderay (~> 1.1)
3535
method_source (~> 1.0)
36-
racc (1.7.3)
37-
rack (3.0.9.1)
36+
racc (1.8.0)
37+
rack (3.1.3)
3838
rainbow (3.1.1)
39-
rake (13.1.0)
40-
regexp_parser (2.9.0)
41-
rexml (3.2.6)
39+
rake (13.2.1)
40+
regexp_parser (2.9.2)
41+
rexml (3.3.0)
42+
strscan
4243
rspec (3.13.0)
4344
rspec-core (~> 3.13.0)
4445
rspec-expectations (~> 3.13.0)
4546
rspec-mocks (~> 3.13.0)
4647
rspec-core (3.13.0)
4748
rspec-support (~> 3.13.0)
48-
rspec-expectations (3.13.0)
49+
rspec-expectations (3.13.1)
4950
diff-lcs (>= 1.2.0, < 2.0)
5051
rspec-support (~> 3.13.0)
51-
rspec-mocks (3.13.0)
52+
rspec-mocks (3.13.1)
5253
diff-lcs (>= 1.2.0, < 2.0)
5354
rspec-support (~> 3.13.0)
5455
rspec-support (3.13.1)
55-
rubocop (1.62.1)
56+
rubocop (1.64.1)
5657
json (~> 2.3)
5758
language_server-protocol (>= 3.17.0)
5859
parallel (~> 1.10)
@@ -63,43 +64,45 @@ GEM
6364
rubocop-ast (>= 1.31.1, < 2.0)
6465
ruby-progressbar (~> 1.7)
6566
unicode-display_width (>= 2.4.0, < 3.0)
66-
rubocop-ast (1.31.2)
67-
parser (>= 3.3.0.4)
68-
rubocop-capybara (2.20.0)
67+
rubocop-ast (1.31.3)
68+
parser (>= 3.3.1.0)
69+
rubocop-capybara (2.21.0)
6970
rubocop (~> 1.41)
70-
rubocop-factory_bot (2.25.1)
71-
rubocop (~> 1.41)
72-
rubocop-graphql (1.5.0)
71+
rubocop-factory_bot (2.26.1)
72+
rubocop (~> 1.61)
73+
rubocop-graphql (1.5.2)
7374
rubocop (>= 0.90, < 2)
7475
rubocop-i18n (3.0.0)
7576
rubocop (~> 1.0)
7677
rubocop-minitest (0.35.0)
7778
rubocop (>= 1.61, < 2.0)
7879
rubocop-ast (>= 1.31.1, < 2.0)
79-
rubocop-performance (1.20.2)
80+
rubocop-performance (1.21.1)
8081
rubocop (>= 1.48.1, < 2.0)
81-
rubocop-ast (>= 1.30.0, < 2.0)
82-
rubocop-rails (2.24.0)
82+
rubocop-ast (>= 1.31.1, < 2.0)
83+
rubocop-rails (2.25.0)
8384
activesupport (>= 4.2.0)
8485
rack (>= 1.1)
8586
rubocop (>= 1.33.0, < 2.0)
8687
rubocop-ast (>= 1.31.1, < 2.0)
8788
rubocop-rake (0.6.0)
8889
rubocop (~> 1.0)
89-
rubocop-rspec (2.27.1)
90-
rubocop (~> 1.40)
91-
rubocop-capybara (~> 2.17)
92-
rubocop-factory_bot (~> 2.22)
90+
rubocop-rspec (3.0.1)
91+
rubocop (~> 1.61)
92+
rubocop-rspec_rails (2.30.0)
93+
rubocop (~> 1.61)
94+
rubocop-rspec (~> 3, >= 3.0.1)
9395
rubocop-sequel (0.3.4)
9496
rubocop (~> 1.0)
9597
rubocop-shopify (2.15.1)
9698
rubocop (~> 1.51)
97-
rubocop-sorbet (0.7.8)
99+
rubocop-sorbet (0.8.3)
98100
rubocop (>= 0.90.0)
99101
rubocop-thread_safety (0.5.1)
100102
rubocop (>= 0.90.0)
101103
ruby-progressbar (1.13.0)
102-
test-prof (1.3.2)
104+
strscan (3.1.0)
105+
test-prof (1.3.3)
103106
tzinfo (2.0.6)
104107
concurrent-ruby (~> 1.0)
105108
unicode-display_width (2.5.0)
@@ -113,14 +116,17 @@ DEPENDENCIES
113116
pry
114117
rake
115118
rspec
116-
rubocop (= 1.62.1)
119+
rubocop (= 1.64.1)
120+
rubocop-capybara
121+
rubocop-factory_bot
117122
rubocop-graphql
118123
rubocop-i18n
119124
rubocop-minitest
120125
rubocop-performance
121126
rubocop-rails
122127
rubocop-rake
123128
rubocop-rspec
129+
rubocop-rspec_rails
124130
rubocop-sequel
125131
rubocop-shopify
126132
rubocop-sorbet

Diff for: config/contents/lint/debugger.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ Lint/Debugger:
2222
MyDebugger.debug_this
2323
```
2424
25+
Some gems also ship files that will start a debugging session when required,
26+
for example `require 'debug/start'` from `ruby/debug`. These requires can
27+
be configured through `DebuggerRequires`. It has the same structure as
28+
`DebuggerMethods`, which you can read about above.
29+
2530
### Example:
2631

2732
# bad (ok during development)
@@ -56,4 +61,10 @@ Lint/Debugger:
5661

5762
def some_method
5863
my_debugger
59-
end
64+
end
65+
66+
### Example: DebuggerRequires: [my_debugger/start]
67+
68+
# bad (ok during development)
69+
70+
require 'my_debugger/start'

Diff for: config/contents/style/access_modifier_declarations.md

+39
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ or inline before each method, depending on configuration.
33
EnforcedStyle config covers only method definitions.
44
Applications of visibility methods to symbols can be controlled
55
using AllowModifiersOnSymbols config.
6+
Also, the visibility of `attr*` methods can be controlled using
7+
AllowModifiersOnAttrs config.
8+
9+
In Ruby 3.0, `attr*` methods now return an array of defined method names
10+
as symbols. So we can write the modifier and `attr*` in inline style.
11+
AllowModifiersOnAttrs config allows `attr*` methods to be written in
12+
inline style without modifying applications that have been maintained
13+
for a long time in group style. Furthermore, developers who are not very
14+
familiar with Ruby may know that the modifier applies to `def`, but they
15+
may not know that it also applies to `attr*` methods. It would be easier
16+
to understand if we could write `attr*` methods in inline style.
617

718
### Safety:
819

@@ -62,4 +73,32 @@ the group access modifier.
6273

6374
private :bar, :baz
6475

76+
end
77+
78+
### Example: AllowModifiersOnAttrs: true (default)
79+
# good
80+
class Foo
81+
82+
public attr_reader :bar
83+
protected attr_writer :baz
84+
private attr_accessor :qux
85+
private attr :quux
86+
87+
def public_method; end
88+
89+
private
90+
91+
def private_method; end
92+
93+
end
94+
95+
### Example: AllowModifiersOnAttrs: false
96+
# bad
97+
class Foo
98+
99+
public attr_reader :bar
100+
protected attr_writer :baz
101+
private attr_accessor :qux
102+
private attr :quux
103+
65104
end

Diff for: config/contents/style/arguments_forwarding.md

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ e.g., `*args`, `**options`, `&block`, and so on.
2424

2525
Names not on this list are likely to be meaningful and are allowed by default.
2626

27+
This cop handles not only method forwarding but also forwarding to `super`.
28+
2729
### Example:
2830
# bad
2931
def foo(*args, &block)

Diff for: config/contents/style/collection_compact.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ when the receiver is a hash object.
1515
### Example:
1616
# bad
1717
array.reject(&:nil?)
18-
array.delete_if(&:nil?)
1918
array.reject { |e| e.nil? }
20-
array.delete_if { |e| e.nil? }
2119
array.select { |e| !e.nil? }
2220
array.grep_v(nil)
2321
array.grep_v(NilClass)
@@ -27,7 +25,9 @@ when the receiver is a hash object.
2725

2826
# bad
2927
hash.reject!(&:nil?)
28+
array.delete_if(&:nil?)
3029
hash.reject! { |k, v| v.nil? }
30+
array.delete_if { |e| e.nil? }
3131
hash.select! { |k, v| !v.nil? }
3232

3333
# good

Diff for: config/contents/style/documentation.md

+24-24
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,36 @@ same for all its children.
2424
end
2525

2626
# allowed
27-
# Class without body
27+
# Class without body
28+
class Person
29+
end
30+
31+
# Namespace - A namespace can be a class or a module
32+
# Containing a class
33+
module Namespace
34+
# Description/Explanation of Person class
2835
class Person
36+
# ...
2937
end
38+
end
3039

31-
# Namespace - A namespace can be a class or a module
32-
# Containing a class
33-
module Namespace
34-
# Description/Explanation of Person class
35-
class Person
36-
# ...
37-
end
40+
# Containing constant visibility declaration
41+
module Namespace
42+
class Private
3843
end
3944

40-
# Containing constant visibility declaration
41-
module Namespace
42-
class Private
43-
end
44-
45-
private_constant :Private
46-
end
45+
private_constant :Private
46+
end
4747

48-
# Containing constant definition
49-
module Namespace
50-
Public = Class.new
51-
end
48+
# Containing constant definition
49+
module Namespace
50+
Public = Class.new
51+
end
5252

53-
# Macro calls
54-
module Namespace
55-
extend Foo
56-
end
53+
# Macro calls
54+
module Namespace
55+
extend Foo
56+
end
5757

5858
### Example: AllowedConstants: ['ClassMethods']
5959

@@ -62,4 +62,4 @@ same for all its children.
6262
module ClassMethods
6363
# ...
6464
end
65-
end
65+
end

Diff for: config/contents/style/documentation_method.md

+11
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,14 @@ they are called constructor to distinguish it from method.
8989
def do_something
9090
end
9191
end
92+
93+
### Example: AllowedMethods: ['method_missing', 'respond_to_missing?']
94+
95+
# good
96+
class Foo
97+
def method_missing(name, *args)
98+
end
99+
100+
def respond_to_missing?(symbol, include_private)
101+
end
102+
end

Diff for: config/contents/style/format_string.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@ format('%s', [1, 2, 3]) #=> '[1, 2, 3]'
1919

2020
### Example: EnforcedStyle: format (default)
2121
# bad
22-
puts sprintf('%10s', 'hoge')
23-
puts '%10s' % 'hoge'
22+
puts sprintf('%10s', 'foo')
23+
puts '%10s' % 'foo'
2424

2525
# good
26-
puts format('%10s', 'hoge')
26+
puts format('%10s', 'foo')
2727

2828
### Example: EnforcedStyle: sprintf
2929
# bad
30-
puts format('%10s', 'hoge')
31-
puts '%10s' % 'hoge'
30+
puts format('%10s', 'foo')
31+
puts '%10s' % 'foo'
3232

3333
# good
34-
puts sprintf('%10s', 'hoge')
34+
puts sprintf('%10s', 'foo')
3535

3636
### Example: EnforcedStyle: percent
3737
# bad
38-
puts format('%10s', 'hoge')
39-
puts sprintf('%10s', 'hoge')
38+
puts format('%10s', 'foo')
39+
puts sprintf('%10s', 'foo')
4040

4141
# good
42-
puts '%10s' % 'hoge'
42+
puts '%10s' % 'foo'

0 commit comments

Comments
 (0)