Skip to content

Commit 676e368

Browse files
authored
Add channel/rubocop-1-20-0 (#299)
* Update rubocop to 1.20.0 * Update scraped documentation * Fix specs
1 parent f8084d4 commit 676e368

23 files changed

+228
-21
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.18.3", require: false
9+
gem "rubocop", "1.20.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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ GEM
1818
mry (0.78.0.0)
1919
rubocop (>= 0.41.0)
2020
parallel (1.20.1)
21-
parser (3.0.1.1)
21+
parser (3.0.2.0)
2222
ast (~> 2.4.1)
2323
pry (0.14.1)
2424
coderay (~> 1.1)
@@ -41,16 +41,16 @@ GEM
4141
diff-lcs (>= 1.2.0, < 2.0)
4242
rspec-support (~> 3.10.0)
4343
rspec-support (3.10.2)
44-
rubocop (1.18.3)
44+
rubocop (1.20.0)
4545
parallel (~> 1.10)
4646
parser (>= 3.0.0.0)
4747
rainbow (>= 2.2.2, < 4.0)
4848
regexp_parser (>= 1.8, < 3.0)
4949
rexml
50-
rubocop-ast (>= 1.7.0, < 2.0)
50+
rubocop-ast (>= 1.9.1, < 2.0)
5151
ruby-progressbar (~> 1.7)
5252
unicode-display_width (>= 1.4.0, < 3.0)
53-
rubocop-ast (1.7.0)
53+
rubocop-ast (1.11.0)
5454
parser (>= 3.0.1.1)
5555
rubocop-graphql (0.9.0)
5656
rubocop (>= 0.87, < 2)
@@ -94,7 +94,7 @@ DEPENDENCIES
9494
pry
9595
rake
9696
rspec
97-
rubocop (= 1.18.3)
97+
rubocop (= 1.20.0)
9898
rubocop-graphql
9999
rubocop-i18n
100100
rubocop-minitest
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
This cop verifies that a project contains Gemfile or gems.rb file and correct
2+
associated lock file based on the configuration.
3+
4+
### Example: EnforcedStyle: Gemfile (default)
5+
# bad
6+
Project contains gems.rb and gems.locked files
7+
8+
# bad
9+
Project contains Gemfile and gems.locked file
10+
11+
# good
12+
Project contains Gemfile and Gemfile.lock
13+
14+
### Example: EnforcedStyle: gems.rb
15+
# bad
16+
Project contains Gemfile and Gemfile.lock files
17+
18+
# bad
19+
Project contains gems.rb and Gemfile.lock file
20+
21+
# good
22+
Project contains gems.rb and gems.locked files

config/contents/layout/line_end_string_concatenation_indentation.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ first part. There are some exceptions, such as implicit return values, where the
66
concatenated string parts shall be indented regardless of `EnforcedStyle` configuration.
77

88
If `EnforcedStyle: indented` is set, it's the second line that shall be indented one step
9-
more than the first line. Lines 3 and forward shall be aligned with line 2. Here too there
10-
are exceptions. Values in a hash literal are always aligned.
9+
more than the first line. Lines 3 and forward shall be aligned with line 2.
1110

1211
### Example:
1312
# bad
@@ -29,25 +28,40 @@ are exceptions. Values in a hash literal are always aligned.
2928
'z'
3029
end
3130

32-
my_hash = {
33-
first: 'a message' \
34-
'in two parts'
35-
}
36-
3731
### Example: EnforcedStyle: aligned (default)
3832
# bad
3933
puts 'x' \
4034
'y'
4135

36+
my_hash = {
37+
first: 'a message' \
38+
'in two parts'
39+
}
40+
4241
# good
4342
puts 'x' \
4443
'y'
4544

45+
my_hash = {
46+
first: 'a message' \
47+
'in two parts'
48+
}
49+
4650
### Example: EnforcedStyle: indented
4751
# bad
4852
result = 'x' \
4953
'y'
5054

55+
my_hash = {
56+
first: 'a message' \
57+
'in two parts'
58+
}
59+
5160
# good
5261
result = 'x' \
5362
'y'
63+
64+
my_hash = {
65+
first: 'a message' \
66+
'in two parts'
67+
}

config/contents/layout/multiline_method_argument_line_breaks.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
This cop ensures that each argument in a multi-line method call
22
starts on a separate line.
33

4+
NOTE: this cop does not move the first argument, if you want that to
5+
be on a separate line, see `Layout/FirstMethodArgumentLineBreak`.
6+
47
### Example:
58

69
# bad
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
This cop checks for ambiguous ranges.
2+
3+
Ranges have quite low precedence, which leads to unexpected behaviour when
4+
using a range with other operators. This cop avoids that by making ranges
5+
explicit by requiring parenthesis around complex range boundaries (anything
6+
that is not a basic literal: numerics, strings, symbols, etc.).
7+
8+
NOTE: The cop auto-corrects by wrapping the entire boundary in parentheses, which
9+
makes the outcome more explicit but is possible to not be the intention of the
10+
programmer. For this reason, this cop's auto-correct is marked as unsafe (it
11+
will not change the behaviour of the code, but will not necessarily match the
12+
intent of the program).
13+
14+
This cop can be configured with `RequireParenthesesForMethodChains` in order to
15+
specify whether method chains (including `self.foo`) should be wrapped in parens
16+
by this cop.
17+
18+
NOTE: Regardless of this configuration, if a method receiver is a basic literal
19+
value, it will be wrapped in order to prevent the ambiguity of `1..2.to_a`.
20+
21+
### Example:
22+
# bad
23+
x || 1..2
24+
(x || 1..2)
25+
1..2.to_a
26+
27+
# good, unambiguous
28+
1..2
29+
'a'..'z'
30+
:bar..:baz
31+
MyClass::MIN..MyClass::MAX
32+
@min..@max
33+
a..b
34+
-a..b
35+
36+
# good, ambiguity removed
37+
x || (1..2)
38+
(x || 1)..2
39+
(x || 1)..(y || 2)
40+
(1..2).to_a
41+
42+
### Example: RequireParenthesesForMethodChains: false (default)
43+
# good
44+
a.foo..b.bar
45+
(a.foo)..(b.bar)
46+
47+
### Example: RequireParenthesesForMethodChains: true
48+
# bad
49+
a.foo..b.bar
50+
51+
# good
52+
(a.foo)..(b.bar)

config/contents/lint/debugger.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ This cop checks for debug calls (such as `debugger` or `binding.pry`) that shoul
22
not be kept for production code.
33

44
The cop can be configured using `DebuggerMethods`. By default, a number of gems
5-
debug entrypoints are configured (`Kernel`, `Byebug`, `Capybara`, `Pry`, `Rails`,
6-
and `WebConsole`). Additional methods can be added.
5+
debug entrypoints are configured (`Kernel`, `Byebug`, `Capybara`, `debug.rb`,
6+
`Pry`, `Rails`, `RubyJard`, and `WebConsole`). Additional methods can be added.
77

88
Specific default groups can be disabled if necessary:
99

config/contents/lint/duplicate_branch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
This cop checks that there are no repeated bodies
2-
within `if/unless`, `case-when` and `rescue` constructs.
2+
within `if/unless`, `case-when`, `case-in` and `rescue` constructs.
33

44
With `IgnoreLiteralBranches: true`, branches are not registered
55
as offenses if they return a basic literal value (string, symbol,

config/contents/naming/inclusive_language.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Flagged terms are configurable for the cop. For each flagged term an optional
1414
Regex can be specified to identify offenses. Suggestions for replacing a flagged term can
1515
be configured and will be displayed as part of the offense message.
1616
An AllowedRegex can be specified for a flagged term to exempt allowed uses of the term.
17+
`WholeWord: true` can be set on a flagged term to indicate the cop should only match when
18+
a term matches the whole word (partial matches will not be offenses).
1719

1820
### Example: FlaggedTerms: { whitelist: { Suggestions: ['allowlist'] } }
1921
# Suggest replacing identifier whitelist with allowlist
@@ -50,3 +52,12 @@ An AllowedRegex can be specified for a flagged term to exempt allowed uses of th
5052

5153
# good
5254
# They had a master's degree
55+
56+
### Example: FlaggedTerms: { slave: { WholeWord: true } }
57+
# Specify that only terms that are full matches will be flagged.
58+
59+
# bad
60+
Slave
61+
62+
# good (won't be flagged despite containing `slave`)
63+
TeslaVehicle

config/contents/style/block_delimiters.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Check for uses of braces or do/end around single line or
22
multi-line blocks.
33

4+
Methods that can be either procedural or functional and cannot be
5+
categorised from their usage alone is ignored.
6+
`lambda`, `proc`, and `it` are their defaults.
7+
Additional methods can be added to the `IgnoredMethods`.
8+
49
### Example: EnforcedStyle: line_count_based (default)
510
# bad - single line block
611
items.each do |item| item / 5 end
@@ -126,3 +131,14 @@ multi-line blocks.
126131
def bar(foo)
127132
puts foo
128133
end
134+
135+
### Example: IgnoredMethods: ['lambda', 'proc', 'it' ] (default)
136+
137+
# good
138+
foo = lambda do |x|
139+
puts "Hello, #{x}"
140+
end
141+
142+
foo = lambda do |x|
143+
x * 100
144+
end

0 commit comments

Comments
 (0)