Skip to content

Commit d560604

Browse files
committed
Update rubocop to 1.63.5
- General bundle update. - Update the docs too. - Add `require "ostruct"` to a couple test files using OpenStruct.
1 parent d26ca0f commit d560604

File tree

10 files changed

+99
-39
lines changed

10 files changed

+99
-39
lines changed

Gemfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ 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.63.5", require: false
99
gem "rubocop-graphql", require: false
1010
gem "rubocop-i18n", require: false
1111
gem "rubocop-minitest", require: false
1212
gem "rubocop-performance", require: false
1313
gem "rubocop-rails", require: false
1414
gem "rubocop-rake", require: false
1515
gem "rubocop-rspec", require: false
16+
gem "rubocop-rspec_rails", require: false
1617
gem "rubocop-sequel", require: false
1718
gem "rubocop-shopify", require: false
1819
gem "rubocop-sorbet", require: false

Gemfile.lock

+24-20
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,31 @@ 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)
1818
concurrent-ruby (1.2.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)
26+
method_source (1.1.0)
2727
minitest (5.22.3)
2828
mutex_m (0.2.0)
2929
parallel (1.24.0)
30-
parser (3.3.0.5)
30+
parser (3.3.1.0)
3131
ast (~> 2.4.1)
3232
racc
3333
pry (0.14.2)
3434
coderay (~> 1.1)
3535
method_source (~> 1.0)
3636
racc (1.7.3)
37-
rack (3.0.9.1)
37+
rack (3.0.11)
3838
rainbow (3.1.1)
39-
rake (13.1.0)
40-
regexp_parser (2.9.0)
39+
rake (13.2.1)
40+
regexp_parser (2.9.1)
4141
rexml (3.2.6)
4242
rspec (3.13.0)
4343
rspec-core (~> 3.13.0)
@@ -48,11 +48,11 @@ GEM
4848
rspec-expectations (3.13.0)
4949
diff-lcs (>= 1.2.0, < 2.0)
5050
rspec-support (~> 3.13.0)
51-
rspec-mocks (3.13.0)
51+
rspec-mocks (3.13.1)
5252
diff-lcs (>= 1.2.0, < 2.0)
5353
rspec-support (~> 3.13.0)
5454
rspec-support (3.13.1)
55-
rubocop (1.62.1)
55+
rubocop (1.63.5)
5656
json (~> 2.3)
5757
language_server-protocol (>= 3.17.0)
5858
parallel (~> 1.10)
@@ -63,43 +63,46 @@ GEM
6363
rubocop-ast (>= 1.31.1, < 2.0)
6464
ruby-progressbar (~> 1.7)
6565
unicode-display_width (>= 2.4.0, < 3.0)
66-
rubocop-ast (1.31.2)
67-
parser (>= 3.3.0.4)
66+
rubocop-ast (1.31.3)
67+
parser (>= 3.3.1.0)
6868
rubocop-capybara (2.20.0)
6969
rubocop (~> 1.41)
7070
rubocop-factory_bot (2.25.1)
7171
rubocop (~> 1.41)
72-
rubocop-graphql (1.5.0)
72+
rubocop-graphql (1.5.1)
7373
rubocop (>= 0.90, < 2)
7474
rubocop-i18n (3.0.0)
7575
rubocop (~> 1.0)
7676
rubocop-minitest (0.35.0)
7777
rubocop (>= 1.61, < 2.0)
7878
rubocop-ast (>= 1.31.1, < 2.0)
79-
rubocop-performance (1.20.2)
79+
rubocop-performance (1.21.0)
8080
rubocop (>= 1.48.1, < 2.0)
81-
rubocop-ast (>= 1.30.0, < 2.0)
82-
rubocop-rails (2.24.0)
81+
rubocop-ast (>= 1.31.1, < 2.0)
82+
rubocop-rails (2.24.1)
8383
activesupport (>= 4.2.0)
8484
rack (>= 1.1)
8585
rubocop (>= 1.33.0, < 2.0)
8686
rubocop-ast (>= 1.31.1, < 2.0)
8787
rubocop-rake (0.6.0)
8888
rubocop (~> 1.0)
89-
rubocop-rspec (2.27.1)
89+
rubocop-rspec (2.29.2)
9090
rubocop (~> 1.40)
9191
rubocop-capybara (~> 2.17)
9292
rubocop-factory_bot (~> 2.22)
93+
rubocop-rspec_rails (~> 2.28)
94+
rubocop-rspec_rails (2.28.3)
95+
rubocop (~> 1.40)
9396
rubocop-sequel (0.3.4)
9497
rubocop (~> 1.0)
9598
rubocop-shopify (2.15.1)
9699
rubocop (~> 1.51)
97-
rubocop-sorbet (0.7.8)
100+
rubocop-sorbet (0.8.3)
98101
rubocop (>= 0.90.0)
99102
rubocop-thread_safety (0.5.1)
100103
rubocop (>= 0.90.0)
101104
ruby-progressbar (1.13.0)
102-
test-prof (1.3.2)
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,15 @@ DEPENDENCIES
113116
pry
114117
rake
115118
rspec
116-
rubocop (= 1.62.1)
119+
rubocop (= 1.63.5)
117120
rubocop-graphql
118121
rubocop-i18n
119122
rubocop-minitest
120123
rubocop-performance
121124
rubocop-rails
122125
rubocop-rake
123126
rubocop-rspec
127+
rubocop-rspec_rails
124128
rubocop-sequel
125129
rubocop-shopify
126130
rubocop-sorbet

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'

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

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'
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Checks for usages of `each` with `<<`, `push`, or `append` which
2+
can be replaced by `map`.
3+
4+
If `PreferredMethods` is configured for `map` in `Style/CollectionMethods`,
5+
this cop uses the specified method for replacement.
6+
7+
NOTE: The return value of `Enumerable#each` is `self`, whereas the
8+
return value of `Enumerable#map` is an `Array`. They are not autocorrected
9+
when a return value could be used because these types differ.
10+
11+
NOTE: It only detects when the mapping destination is a local variable
12+
initialized as an empty array and referred to only by the pushing operation.
13+
This is because, if not, it's challenging to statically guarantee that the
14+
mapping destination variable remains an empty array:
15+
16+
```ruby
17+
ret = []
18+
src.each { |e| ret << e * 2 } # `<<` method may mutate `ret`
19+
20+
dest = []
21+
src.each { |e| dest << transform(e, dest) } # `transform` method may mutate `dest`
22+
```
23+
24+
### Safety:
25+
26+
This cop is unsafe because not all objects that have an `each`
27+
method also have a `map` method (e.g. `ENV`). Additionally, for calls
28+
with a block, not all objects that have a `map` method return an array
29+
(e.g. `Enumerator::Lazy`).
30+
31+
### Example:
32+
# bad
33+
dest = []
34+
src.each { |e| dest << e * 2 }
35+
dest
36+
37+
# good
38+
dest = src.map { |e| e * 2 }
39+
40+
# good - contains another operation
41+
dest = []
42+
src.each { |e| dest << e * 2; puts e }
43+
dest

config/contents/style/send.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ Checks for the use of the send method.
22

33
### Example:
44
# bad
5-
Foo.send(:bar)
6-
quuz.send(:fred)
5+
Foo.send(bar)
6+
quuz.send(fred)
77

88
# good
9-
Foo.__send__(:bar)
10-
quuz.public_send(:fred)
9+
Foo.__send__(bar)
10+
quuz.public_send(fred)

config/contents/style/special_global_vars.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ true, replacing perl-style variables with english variables will break.
5454

5555
### Example: EnforcedStyle: use_builtin_english_names
5656

57-
Like `use_perl_names` but allows builtin global vars.
58-
5957
# good
58+
# Like `use_perl_names` but allows builtin global vars.
6059
puts $LOAD_PATH
6160
puts $LOADED_FEATURES
6261
puts $PROGRAM_NAME

spec/cc/engine/issue_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require "spec_helper"
22
require "cc/engine/issue"
3+
require "ostruct"
34

45
module CC::Engine
56
describe Issue do

spec/cc/engine/rubocop_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require "spec_helper"
22
require "cc/engine/rubocop"
3+
require "ostruct"
34
require "tmpdir"
45

56
module CC::Engine

0 commit comments

Comments
 (0)