Skip to content

Commit 8281645

Browse files
committed
Add rubocop 0.51.0 updates from upstream
github#17
1 parent 21f1d11 commit 8281645

12 files changed

+113
-116
lines changed

config/default.yml

Lines changed: 69 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,57 @@ Bundler/DuplicatedGem:
99
Bundler/OrderedGems:
1010
Enabled: true
1111

12+
Layout/BlockEndNewline:
13+
Enabled: true
14+
15+
Layout/EndOfLine:
16+
Enabled: true
17+
18+
Layout/InitialIndentation:
19+
Enabled: true
20+
21+
Layout/SpaceAfterColon:
22+
Enabled: true
23+
24+
Layout/SpaceAfterComma:
25+
Enabled: true
26+
27+
Layout/SpaceAfterMethodName:
28+
Enabled: true
29+
30+
Layout/SpaceAfterNot:
31+
Enabled: true
32+
33+
Layout/SpaceAfterSemicolon:
34+
Enabled: true
35+
36+
Layout/SpaceAroundBlockParameters:
37+
Enabled: true
38+
39+
Layout/SpaceAroundEqualsInParameterDefault:
40+
Enabled: true
41+
42+
Layout/SpaceInsideArrayPercentLiteral:
43+
Enabled: true
44+
45+
Layout/SpaceInsideBrackets:
46+
Enabled: true
47+
48+
Layout/SpaceInsideParens:
49+
Enabled: true
50+
51+
Layout/SpaceInsideRangeLiteral:
52+
Enabled: true
53+
54+
Layout/Tab:
55+
Enabled: true
56+
57+
Layout/TrailingBlankLines:
58+
Enabled: true
59+
60+
Layout/TrailingWhitespace:
61+
Enabled: true
62+
1263
Lint/BlockAlignment:
1364
Enabled: true
1465

@@ -42,15 +93,15 @@ Lint/ElseLayout:
4293
Lint/EmptyEnsure:
4394
Enabled: true
4495

45-
Lint/EndInMethod:
46-
Enabled: true
47-
4896
Lint/EmptyInterpolation:
4997
Enabled: true
5098

5199
Lint/EndAlignment:
52100
Enabled: false
53101

102+
Lint/EndInMethod:
103+
Enabled: true
104+
54105
Lint/EnsureReturn:
55106
Enabled: true
56107

@@ -60,14 +111,7 @@ Lint/FloatOutOfRange:
60111
Lint/FormatParameterMismatch:
61112
Enabled: true
62113

63-
Style/HashSyntax:
64-
Enabled: true
65-
EnforcedStyle: ruby19
66-
67-
Lint/InvalidCharacterLiteral:
68-
Enabled: true
69-
70-
Lint/LiteralInCondition:
114+
Lint/LiteralAsCondition:
71115
Enabled: true
72116

73117
Lint/LiteralInInterpolation:
@@ -142,6 +186,18 @@ Metrics/ParameterLists:
142186
Metrics/PerceivedComplexity:
143187
Enabled: false
144188

189+
Naming/AsciiIdentifiers:
190+
Enabled: true
191+
192+
Naming/ClassAndModuleCamelCase:
193+
Enabled: true
194+
195+
Naming/FileName:
196+
Enabled: true
197+
198+
Naming/MethodName:
199+
Enabled: true
200+
145201
Performance/CaseWhenSplat:
146202
Enabled: false
147203

@@ -197,27 +253,18 @@ Security/Eval:
197253
Style/ArrayJoin:
198254
Enabled: true
199255

200-
Style/AsciiIdentifiers:
201-
Enabled: true
202-
203256
Style/BeginBlock:
204257
Enabled: true
205258

206259
Style/BlockComments:
207260
Enabled: true
208261

209-
Layout/BlockEndNewline:
210-
Enabled: true
211-
212262
Style/CaseEquality:
213263
Enabled: true
214264

215265
Style/CharacterLiteral:
216266
Enabled: true
217267

218-
Style/ClassAndModuleCamelCase:
219-
Enabled: true
220-
221268
Style/ClassMethods:
222269
Enabled: true
223270

@@ -230,12 +277,6 @@ Style/DefWithParentheses:
230277
Style/EndBlock:
231278
Enabled: true
232279

233-
Layout/EndOfLine:
234-
Enabled: true
235-
236-
Style/FileName:
237-
Enabled: true
238-
239280
Style/FlipFlop:
240281
Enabled: true
241282

@@ -245,8 +286,9 @@ Style/For:
245286
Style/FrozenStringLiteralComment:
246287
Enabled: true
247288

248-
Layout/InitialIndentation:
289+
Style/HashSyntax:
249290
Enabled: true
291+
EnforcedStyle: ruby19
250292

251293
Style/LambdaCall:
252294
Enabled: true
@@ -257,9 +299,6 @@ Style/MethodCallWithoutArgsParentheses:
257299
Style/MethodDefParentheses:
258300
Enabled: true
259301

260-
Style/MethodName:
261-
Enabled: true
262-
263302
Style/MultilineIfThen:
264303
Enabled: true
265304

@@ -272,51 +311,9 @@ Style/Not:
272311
Style/OneLineConditional:
273312
Enabled: true
274313

275-
Layout/SpaceAfterMethodName:
276-
Enabled: true
277-
278-
Layout/SpaceAfterColon:
279-
Enabled: true
280-
281-
Layout/SpaceAfterComma:
282-
Enabled: true
283-
284-
Layout/SpaceAfterNot:
285-
Enabled: true
286-
287-
Layout/SpaceAfterSemicolon:
288-
Enabled: true
289-
290-
Layout/SpaceAroundBlockParameters:
291-
Enabled: true
292-
293-
Layout/SpaceAroundEqualsInParameterDefault:
294-
Enabled: true
295-
296-
Layout/SpaceInsideArrayPercentLiteral:
297-
Enabled: true
298-
299-
Layout/SpaceInsideBrackets:
300-
Enabled: true
301-
302-
Layout/SpaceInsideParens:
303-
Enabled: true
304-
305-
Layout/SpaceInsideRangeLiteral:
306-
Enabled: true
307-
308314
Style/StabbyLambdaParentheses:
309315
Enabled: true
310316

311317
Style/StringLiterals:
312318
Enabled: true
313319
EnforcedStyle: double_quotes
314-
315-
Layout/Tab:
316-
Enabled: true
317-
318-
Layout/TrailingBlankLines:
319-
Enabled: true
320-
321-
Layout/TrailingWhitespace:
322-
Enabled: true

lib/rubocop/cop/github/rails_application_record.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ class RailsApplicationRecord < Cop
99
MSG = "Models should subclass from ApplicationRecord"
1010

1111
def_node_matcher :active_record_base_const?, <<-PATTERN
12-
(const (const nil :ActiveRecord) :Base)
12+
(const (const nil? :ActiveRecord) :Base)
1313
PATTERN
1414

1515
def_node_matcher :application_record_const?, <<-PATTERN
16-
(const nil :ApplicationRecord)
16+
(const nil? :ApplicationRecord)
1717
PATTERN
1818

1919
def on_class(node)
2020
klass, superclass, _ = *node
2121

2222
if active_record_base_const?(superclass) && !(application_record_const?(klass))
23-
add_offense(superclass, :expression)
23+
add_offense(superclass, location: :expression)
2424
end
2525
end
2626
end

lib/rubocop/cop/github/rails_controller_render_action_symbol.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ class RailsControllerRenderActionSymbol < Cop
99
MSG = "Prefer `render` with string instead of symbol"
1010

1111
def_node_matcher :render_sym?, <<-PATTERN
12-
(send nil :render $(sym _))
12+
(send nil? :render $(sym _))
1313
PATTERN
1414

1515
def_node_matcher :render_with_options?, <<-PATTERN
16-
(send nil :render (hash $...))
16+
(send nil? :render (hash $...))
1717
PATTERN
1818

1919
def_node_matcher :action_key?, <<-PATTERN
@@ -22,11 +22,11 @@ class RailsControllerRenderActionSymbol < Cop
2222

2323
def on_send(node)
2424
if sym_node = render_sym?(node)
25-
add_offense(sym_node, :expression)
25+
add_offense(sym_node, location: :expression)
2626
elsif option_pairs = render_with_options?(node)
2727
option_pairs.each do |pair|
2828
if sym_node = action_key?(pair)
29-
add_offense(sym_node, :expression)
29+
add_offense(sym_node, location: :expression)
3030
end
3131
end
3232
end

lib/rubocop/cop/github/rails_controller_render_literal.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ class RailsControllerRenderLiteral < Cop
99
MSG = "render must be used with a string literal"
1010

1111
def_node_matcher :literal?, <<-PATTERN
12-
({str sym true false nil} ...)
12+
({str sym true false nil?} ...)
1313
PATTERN
1414

1515
def_node_matcher :render?, <<-PATTERN
16-
(send nil :render ...)
16+
(send nil? :render ...)
1717
PATTERN
1818

1919
def_node_matcher :render_literal?, <<-PATTERN
20-
(send nil :render ({str sym} $_) $...)
20+
(send nil? :render ({str sym} $_) $...)
2121
PATTERN
2222

2323
def_node_matcher :render_with_options?, <<-PATTERN
24-
(send nil :render (hash $...))
24+
(send nil? :render (hash $...))
2525
PATTERN
2626

2727
def_node_matcher :ignore_key?, <<-PATTERN
@@ -73,19 +73,19 @@ def on_send(node)
7373

7474
if template_node = option_pairs.map { |pair| template_key?(pair) }.compact.first
7575
if !literal?(template_node)
76-
add_offense(node, :expression)
76+
add_offense(node, location: :expression)
7777
end
7878
else
79-
add_offense(node, :expression)
79+
add_offense(node, location: :expression)
8080
end
8181

8282
if layout_node = option_pairs.map { |pair| layout_key?(pair) }.compact.first
8383
if !literal?(layout_node)
84-
add_offense(node, :expression)
84+
add_offense(node, location: :expression)
8585
end
8686
end
8787
else
88-
add_offense(node, :expression)
88+
add_offense(node, location: :expression)
8989
end
9090
end
9191
end

lib/rubocop/cop/github/rails_controller_render_paths_exist.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ module Cop
77
module GitHub
88
class RailsControllerRenderPathsExist < Cop
99
def_node_matcher :render?, <<-PATTERN
10-
(send nil :render $...)
10+
(send nil? :render $...)
1111
PATTERN
1212

1313
def_node_matcher :render_str?, <<-PATTERN
14-
(send nil :render $({str sym} $_) ...)
14+
(send nil? :render $({str sym} $_) ...)
1515
PATTERN
1616

1717
def_node_matcher :render_options?, <<-PATTERN
18-
(send nil :render (hash $...))
18+
(send nil? :render (hash $...))
1919
PATTERN
2020

2121
def_node_matcher :render_key?, <<-PATTERN
@@ -28,7 +28,7 @@ def on_send(node)
2828
if args = render_str?(node)
2929
node, path = args
3030
unless resolve_template(path.to_s)
31-
add_offense(node, :expression, "Template could not be found")
31+
add_offense(node, location: :expression, message: "Template could not be found")
3232
end
3333
elsif pairs = render_options?(node)
3434
if pair = pairs.detect { |p| render_key?(p) }
@@ -37,11 +37,11 @@ def on_send(node)
3737
case key
3838
when :action, :template
3939
unless resolve_template(path.to_s)
40-
add_offense(node, :expression, "Template could not be found")
40+
add_offense(node, location: :expression, message: "Template could not be found")
4141
end
4242
when :partial
4343
unless resolve_partial(path.to_s)
44-
add_offense(node, :expression, "Partial template could not be found")
44+
add_offense(node, location: :expression, message: "Partial template could not be found")
4545
end
4646
end
4747
end

lib/rubocop/cop/github/rails_controller_render_shorthand.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class RailsControllerRenderShorthand < Cop
99
MSG = "Prefer `render` template shorthand"
1010

1111
def_node_matcher :render_with_options?, <<-PATTERN
12-
(send nil :render (hash $...))
12+
(send nil? :render (hash $...))
1313
PATTERN
1414

1515
def_node_matcher :action_key?, <<-PATTERN
@@ -40,7 +40,7 @@ def on_send(node)
4040
@autocorrect[node] = lambda do |corrector|
4141
corrector.replace(node.source_range, corrected_source)
4242
end
43-
add_offense(node, :expression, "Use `#{corrected_source}` instead")
43+
add_offense(node, location: :expression, message: "Use `#{corrected_source}` instead")
4444
end
4545
end
4646
end

0 commit comments

Comments
 (0)