Skip to content

Commit 7358f16

Browse files
authored
Updated channel and documentation to Rubocop v1.8.1 (#269)
Bumps the 'rubocop' dependency to v1.8.1, updates the scraped documentation, and fixes the config-upgrader spec by adding the new cops to the config-upgrader fixture.
1 parent c263849 commit 7358f16

12 files changed

+139
-18
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.7.0", require: false
9+
gem "rubocop", "1.8.1", require: false
1010
gem "rubocop-i18n", require: false
1111
gem "rubocop-minitest", require: false
1212
gem "rubocop-performance", require: false

Gemfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ GEM
4141
diff-lcs (>= 1.2.0, < 2.0)
4242
rspec-support (~> 3.9.0)
4343
rspec-support (3.9.3)
44-
rubocop (1.7.0)
44+
rubocop (1.8.1)
4545
parallel (~> 1.10)
46-
parser (>= 2.7.1.5)
46+
parser (>= 3.0.0.0)
4747
rainbow (>= 2.2.2, < 4.0)
4848
regexp_parser (>= 1.8, < 3.0)
4949
rexml
5050
rubocop-ast (>= 1.2.0, < 2.0)
5151
ruby-progressbar (~> 1.7)
52-
unicode-display_width (>= 1.4.0, < 2.0)
52+
unicode-display_width (>= 1.4.0, < 3.0)
5353
rubocop-ast (1.4.0)
5454
parser (>= 2.7.1.5)
5555
rubocop-i18n (3.0.0)
@@ -78,7 +78,7 @@ GEM
7878
thread_safe (0.3.6)
7979
tzinfo (1.2.7)
8080
thread_safe (~> 0.1)
81-
unicode-display_width (1.7.0)
81+
unicode-display_width (2.0.0)
8282
zeitwerk (2.3.1)
8383

8484
PLATFORMS
@@ -91,7 +91,7 @@ DEPENDENCIES
9191
pry
9292
rake
9393
rspec
94-
rubocop (= 1.7.0)
94+
rubocop (= 1.8.1)
9595
rubocop-i18n
9696
rubocop-minitest
9797
rubocop-performance

config/contents/layout/multiline_operation_indentation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ style.
1111
if a +
1212
b
1313
something &&
14-
something_else
14+
something_else
1515
end
1616

1717
# good
1818
if a +
1919
b
2020
something &&
21-
something_else
21+
something_else
2222
end
2323

2424
### Example: EnforcedStyle: indented

config/contents/layout/space_before_brackets.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
Checks for space between the name of a receiver and a left
22
brackets.
33

4-
This cop is marked as unsafe because it can occur false positives
5-
for `do_something [this_is_an_array_literal_argument]` that take
6-
an array without parentheses as an argument.
7-
84
### Example:
95

106
# bad
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
This cop checks for deprecated constants.
2+
3+
It has `DeprecatedConstants` config. If there is an alternative method, you can set
4+
alternative value as `Alternative`. And you can set the deprecated version as
5+
`DeprecatedVersion`. These options can be omitted if they are not needed.
6+
7+
DeprecatedConstants:
8+
'DEPRECATED_CONSTANT':
9+
Alternative: 'alternative_value'
10+
DeprecatedVersion: 'deprecated_version'
11+
12+
By default, `NIL`, `TRUE`, `FALSE` and `Random::DEFAULT` are configured.
13+
14+
### Example:
15+
16+
# bad
17+
NIL
18+
TRUE
19+
FALSE
20+
Random::DEFAULT # Return value of Ruby 2 is `Random` instance, Ruby 3.0 is `Random` class.
21+
22+
# good
23+
nil
24+
true
25+
false
26+
Random.new # `::DEFAULT` has been deprecated in Ruby 3, `.new` is compatible with Ruby 2.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
This cop checks uses of lambda without a literal block.
2+
It emulates the following warning in Ruby 3.0:
3+
4+
% ruby -vwe 'lambda(&proc {})'
5+
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
6+
-e:1: warning: lambda without a literal block is deprecated; use the proc without
7+
lambda instead
8+
9+
This way, proc object is never converted to lambda.
10+
Auto-correction replaces with compatible proc argument.
11+
12+
### Example:
13+
14+
# bad
15+
lambda(&proc { do_something })
16+
lambda(&Proc.new { do_something })
17+
18+
# good
19+
proc { do_something }
20+
Proc.new { do_something }
21+
lambda { do_something } # If you use lambda.

config/contents/lint/non_deterministic_require_order.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ such as requiring files, can lead to intermittent failures
66
that are hard to debug. To ensure this doesn't happen,
77
always sort the list.
88

9+
`Dir.glob` and `Dir[]` sort globbed results by default in Ruby 3.0.
10+
So all bad cases are acceptable when Ruby 3.0 or higher are used.
11+
12+
This cop will be deprecated and removed when supporting only Ruby 3.0 and higher.
13+
914
### Example:
1015

1116
# bad
@@ -18,8 +23,6 @@ always sort the list.
1823
require file
1924
end
2025

21-
### Example:
22-
2326
# bad
2427
Dir.glob(Rails.root.join(__dir__, 'test', '*.rb')) do |file|
2528
require file
@@ -30,18 +33,17 @@ always sort the list.
3033
require file
3134
end
3235

33-
### Example:
34-
3536
# bad
3637
Dir['./lib/**/*.rb'].each(&method(:require))
3738

3839
# good
3940
Dir['./lib/**/*.rb'].sort.each(&method(:require))
4041

41-
### Example:
42-
4342
# bad
4443
Dir.glob(Rails.root.join('test', '*.rb'), &method(:require))
4544

4645
# good
4746
Dir.glob(Rails.root.join('test', '*.rb')).sort.each(&method(:require))
47+
48+
# good - Respect intent if `sort` keyword option is specified in Ruby 3.0 or higher.
49+
Dir.glob(Rails.root.join(__dir__, 'test', '*.rb'), sort: false).each(&method(:require))
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Sort globbed results by default in Ruby 3.0.
2+
This cop checks for redundant `sort` method to `Dir.glob` and `Dir[]`.
3+
4+
### Example:
5+
6+
# bad
7+
Dir.glob('./lib/**/*.rb').sort.each do |file|
8+
end
9+
10+
Dir['./lib/**/*.rb'].sort.each do |file|
11+
end
12+
13+
# good
14+
Dir.glob('./lib/**/*.rb').each do |file|
15+
end
16+
17+
Dir['./lib/**/*.rb'].each do |file|
18+
end
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
This cop checks for endless methods.
2+
3+
It can enforce either the use of endless methods definitions
4+
for single-lined method bodies, or disallow endless methods.
5+
6+
Other method definition types are not considered by this cop.
7+
8+
The supported styles are:
9+
* allow_single_line (default) - only single line endless method definitions are allowed.
10+
* allow_always - all endless method definitions are allowed.
11+
* disallow - all endless method definitions are disallowed.
12+
13+
NOTE: Incorrect endless method definitions will always be
14+
corrected to a multi-line definition.
15+
16+
### Example: EnforcedStyle: allow_single_line (default)
17+
# good
18+
def my_method() = x
19+
20+
# bad, multi-line endless method
21+
def my_method() = x.foo
22+
.bar
23+
.baz
24+
25+
### Example: EnforcedStyle: allow_always
26+
# good
27+
def my_method() = x
28+
29+
# good
30+
def my_method() = x.foo
31+
.bar
32+
.baz
33+
34+
### Example: EnforcedStyle: disallow
35+
# bad
36+
def my_method; x end
37+
38+
# bad
39+
def my_method() = x.foo
40+
.bar
41+
.baz

config/contents/style/explicit_block_argument.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
This cop enforces the use of explicit block argument to avoid writing
22
block literal that just passes its arguments to another block.
33

4+
NOTE: This cop only registers an offense if the block args match the
5+
yield args exactly.
6+
47
### Example:
58
# bad
69
def with_tmp_dir

0 commit comments

Comments
 (0)