rubocop-github 0.16.1 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -22
- data/STYLEGUIDE.md +16 -16
- data/config/default.yml +334 -2
- data/config/rails.yml +127 -2
- data/lib/rubocop/cop/github/insecure_hash_algorithm.rb +1 -1
- data/lib/rubocop/cop/github/rails_application_record.rb +2 -2
- data/lib/rubocop/cop/github/rails_controller_render_action_symbol.rb +11 -5
- data/lib/rubocop/cop/github/rails_controller_render_literal.rb +7 -7
- data/lib/rubocop/cop/github/rails_controller_render_paths_exist.rb +4 -4
- data/lib/rubocop/cop/github/rails_controller_render_shorthand.rb +4 -11
- data/lib/rubocop/cop/github/rails_render_inline.rb +2 -2
- data/lib/rubocop/cop/github/rails_render_object_collection.rb +3 -3
- data/lib/rubocop/cop/github/rails_view_render_literal.rb +6 -6
- data/lib/rubocop/cop/github/rails_view_render_paths_exist.rb +3 -3
- data/lib/rubocop/cop/github/rails_view_render_shorthand.rb +3 -3
- data/lib/rubocop/cop/github/render_literal_helpers.rb +6 -5
- metadata +27 -33
- data/config/_default_shared.yml +0 -329
- data/config/_rails_shared.yml +0 -120
- data/config/default_deprecated.yml +0 -4
- data/config/default_edge.yml +0 -4
- data/config/rails_deprecated.yml +0 -7
- data/config/rails_edge.yml +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5aac9faf8fd07df225b66910c710065d8d69fd889bd424778c3802374691d95
|
4
|
+
data.tar.gz: fc3548902e7759613503804188cd2e71e45ff0e4c6464c7544c6f3a62d9addd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5850a48c2665aff47ca0d0505b20869d0e573e4bb4018a79132a78e64c3b7fd3fe9c27c0c472966a1ce1e9bcaf9969a61d9241d919f899769a6b73f308fd48a
|
7
|
+
data.tar.gz: d451981724e1d7bc407f7bf0f5fb2078f97eb9779f83fa3168241e25b28beffebb06d55805bc8e7fee8eceb1621e8cc28ce0308f389e1ebe30edd4ef023108b5
|
data/README.md
CHANGED
@@ -4,28 +4,6 @@ This repository provides recommended RuboCop configuration and additional Cops f
|
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
7
|
-
Rubocop 0.68 removed performance cops and 0.72 removed Rails cops. However, upgrading `rubocop-github` without modification will almost definitely create very many new offenses. The current version of this gem exposes the "legacy" configuration under `config/default.yml` and `config/rails.yml` which should be used *if and only if* the version of rubocop is locked to `< 0.68` in your project (which it should be unless you `bundle update rubocop`). It also exposes an "edge" configuration under `config/default_edge.yml` and `config/rails_edge.yml` so that the changes can be tested without introducing breaking changes.
|
8
|
-
|
9
|
-
### Legacy usage
|
10
|
-
|
11
|
-
**Gemfile**
|
12
|
-
|
13
|
-
``` ruby
|
14
|
-
gem "rubocop", "< 0.68"
|
15
|
-
gem "rubocop-github"
|
16
|
-
```
|
17
|
-
|
18
|
-
**.rubocop.yml**
|
19
|
-
|
20
|
-
``` yaml
|
21
|
-
inherit_gem:
|
22
|
-
rubocop-github:
|
23
|
-
- config/default.yml
|
24
|
-
- config/rails.yml
|
25
|
-
```
|
26
|
-
|
27
|
-
### Edge usage
|
28
|
-
|
29
7
|
**Gemfile**
|
30
8
|
|
31
9
|
``` ruby
|
@@ -43,6 +21,11 @@ inherit_gem:
|
|
43
21
|
- config/rails_edge.yml
|
44
22
|
```
|
45
23
|
|
24
|
+
### Legacy usage
|
25
|
+
|
26
|
+
If you are using a rubocop version < 1.0.0, you can use rubocop-github version
|
27
|
+
0.16.2 (see the README from that version for more details).
|
28
|
+
|
46
29
|
## Testing
|
47
30
|
|
48
31
|
`bundle install`
|
data/STYLEGUIDE.md
CHANGED
@@ -308,44 +308,43 @@ end
|
|
308
308
|
Use the Ruby 1.9 syntax for hash literals when all the keys are symbols:
|
309
309
|
|
310
310
|
``` ruby
|
311
|
-
# good
|
312
|
-
user = {
|
313
|
-
login: "defunkt",
|
314
|
-
name: "Chris Wanstrath"
|
315
|
-
}
|
316
|
-
|
317
311
|
# bad
|
318
312
|
user = {
|
319
313
|
:login => "defunkt",
|
320
314
|
:name => "Chris Wanstrath"
|
321
315
|
}
|
322
316
|
|
317
|
+
# good
|
318
|
+
user = {
|
319
|
+
login: "defunkt",
|
320
|
+
name: "Chris Wanstrath"
|
321
|
+
}
|
323
322
|
```
|
324
323
|
|
325
324
|
Use the 1.9 syntax when calling a method with Hash options arguments or named arguments:
|
326
325
|
|
327
326
|
``` ruby
|
328
|
-
# good
|
329
|
-
user = User.create(login: "jane")
|
330
|
-
link_to("Account", controller: "users", action: "show", id: user)
|
331
|
-
|
332
327
|
# bad
|
333
328
|
user = User.create(:login => "jane")
|
334
329
|
link_to("Account", :controller => "users", :action => "show", :id => user)
|
330
|
+
|
331
|
+
# good
|
332
|
+
user = User.create(login: "jane")
|
333
|
+
link_to("Account", controller: "users", action: "show", id: user)
|
335
334
|
```
|
336
335
|
|
337
336
|
If you have a hash with mixed key types, use the legacy hashrocket style to avoid mixing styles within the same hash:
|
338
337
|
|
339
338
|
``` ruby
|
340
|
-
#
|
339
|
+
# bad
|
341
340
|
hsh = {
|
342
|
-
:
|
341
|
+
user_id: 55,
|
343
342
|
"followers-count" => 1000
|
344
343
|
}
|
345
344
|
|
346
|
-
#
|
345
|
+
# good
|
347
346
|
hsh = {
|
348
|
-
user_id
|
347
|
+
:user_id => 55,
|
349
348
|
"followers-count" => 1000
|
350
349
|
}
|
351
350
|
```
|
@@ -371,7 +370,7 @@ def remove_member(user, skip_membership_check: false)
|
|
371
370
|
end
|
372
371
|
|
373
372
|
# Elsewhere, now with more clarity:
|
374
|
-
remove_member
|
373
|
+
remove_member(user, skip_membership_check: true)
|
375
374
|
```
|
376
375
|
|
377
376
|
## Naming
|
@@ -388,7 +387,8 @@ remove_member user, skip_membership_check: true
|
|
388
387
|
|
389
388
|
* The names of potentially "dangerous" methods (i.e. methods that modify `self` or the
|
390
389
|
arguments, `exit!`, etc.) should end with an exclamation mark. Bang methods
|
391
|
-
should only exist if a non-bang method
|
390
|
+
should only exist if a non-bang counterpart (method name which does NOT end with !)
|
391
|
+
also exists.
|
392
392
|
|
393
393
|
## Percent Literals
|
394
394
|
|
data/config/default.yml
CHANGED
@@ -1,2 +1,334 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require:
|
2
|
+
- rubocop/cop/github
|
3
|
+
- rubocop-performance
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
DisabledByDefault: true
|
7
|
+
|
8
|
+
Bundler/DuplicatedGem:
|
9
|
+
Enabled: true
|
10
|
+
|
11
|
+
Bundler/OrderedGems:
|
12
|
+
Enabled: true
|
13
|
+
|
14
|
+
GitHub/InsecureHashAlgorithm:
|
15
|
+
Enabled: true
|
16
|
+
|
17
|
+
Layout/BlockAlignment:
|
18
|
+
Enabled: true
|
19
|
+
|
20
|
+
Layout/BlockEndNewline:
|
21
|
+
Enabled: true
|
22
|
+
|
23
|
+
Layout/ConditionPosition:
|
24
|
+
Enabled: true
|
25
|
+
|
26
|
+
Layout/DefEndAlignment:
|
27
|
+
Enabled: true
|
28
|
+
|
29
|
+
Layout/EndAlignment:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Layout/EndOfLine:
|
33
|
+
Enabled: true
|
34
|
+
|
35
|
+
Layout/IndentationStyle:
|
36
|
+
Enabled: true
|
37
|
+
EnforcedStyle: spaces
|
38
|
+
IndentationWidth: 2
|
39
|
+
|
40
|
+
Layout/IndentationWidth:
|
41
|
+
Enabled: true
|
42
|
+
Width: 2
|
43
|
+
|
44
|
+
Layout/InitialIndentation:
|
45
|
+
Enabled: true
|
46
|
+
|
47
|
+
Layout/LineLength:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
Layout/SpaceAfterColon:
|
51
|
+
Enabled: true
|
52
|
+
|
53
|
+
Layout/SpaceAfterComma:
|
54
|
+
Enabled: true
|
55
|
+
|
56
|
+
Layout/SpaceAfterMethodName:
|
57
|
+
Enabled: true
|
58
|
+
|
59
|
+
Layout/SpaceAfterNot:
|
60
|
+
Enabled: true
|
61
|
+
|
62
|
+
Layout/SpaceAfterSemicolon:
|
63
|
+
Enabled: true
|
64
|
+
|
65
|
+
Layout/SpaceAroundBlockParameters:
|
66
|
+
Enabled: true
|
67
|
+
|
68
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
69
|
+
Enabled: true
|
70
|
+
|
71
|
+
Layout/SpaceBeforeBlockBraces:
|
72
|
+
Enabled: true
|
73
|
+
|
74
|
+
Layout/SpaceInsideArrayLiteralBrackets:
|
75
|
+
Enabled: true
|
76
|
+
EnforcedStyle: no_space
|
77
|
+
|
78
|
+
Layout/SpaceInsideArrayPercentLiteral:
|
79
|
+
Enabled: true
|
80
|
+
|
81
|
+
Layout/SpaceInsideBlockBraces:
|
82
|
+
Enabled: true
|
83
|
+
|
84
|
+
Layout/SpaceInsideParens:
|
85
|
+
Enabled: true
|
86
|
+
|
87
|
+
Layout/SpaceInsideRangeLiteral:
|
88
|
+
Enabled: true
|
89
|
+
|
90
|
+
Layout/SpaceInsideReferenceBrackets:
|
91
|
+
Enabled: true
|
92
|
+
|
93
|
+
Layout/TrailingEmptyLines:
|
94
|
+
Enabled: true
|
95
|
+
|
96
|
+
Layout/TrailingWhitespace:
|
97
|
+
Enabled: true
|
98
|
+
|
99
|
+
Lint/CircularArgumentReference:
|
100
|
+
Enabled: true
|
101
|
+
|
102
|
+
Lint/Debugger:
|
103
|
+
Enabled: true
|
104
|
+
|
105
|
+
Lint/DeprecatedClassMethods:
|
106
|
+
Enabled: true
|
107
|
+
|
108
|
+
Lint/DuplicateMethods:
|
109
|
+
Enabled: true
|
110
|
+
|
111
|
+
Lint/DuplicateHashKey:
|
112
|
+
Enabled: true
|
113
|
+
|
114
|
+
Lint/EachWithObjectArgument:
|
115
|
+
Enabled: true
|
116
|
+
|
117
|
+
Lint/ElseLayout:
|
118
|
+
Enabled: true
|
119
|
+
|
120
|
+
Lint/EmptyEnsure:
|
121
|
+
Enabled: true
|
122
|
+
|
123
|
+
Lint/EmptyInterpolation:
|
124
|
+
Enabled: true
|
125
|
+
|
126
|
+
Lint/EnsureReturn:
|
127
|
+
Enabled: true
|
128
|
+
|
129
|
+
Lint/FlipFlop:
|
130
|
+
Enabled: true
|
131
|
+
|
132
|
+
Lint/FloatOutOfRange:
|
133
|
+
Enabled: true
|
134
|
+
|
135
|
+
Lint/FormatParameterMismatch:
|
136
|
+
Enabled: true
|
137
|
+
|
138
|
+
Lint/LiteralAsCondition:
|
139
|
+
Enabled: true
|
140
|
+
|
141
|
+
Lint/LiteralInInterpolation:
|
142
|
+
Enabled: true
|
143
|
+
|
144
|
+
Lint/Loop:
|
145
|
+
Enabled: true
|
146
|
+
|
147
|
+
Lint/NextWithoutAccumulator:
|
148
|
+
Enabled: true
|
149
|
+
|
150
|
+
Lint/RandOne:
|
151
|
+
Enabled: true
|
152
|
+
|
153
|
+
Lint/RequireParentheses:
|
154
|
+
Enabled: true
|
155
|
+
|
156
|
+
Lint/RescueException:
|
157
|
+
Enabled: true
|
158
|
+
|
159
|
+
Lint/RedundantStringCoercion:
|
160
|
+
Enabled: true
|
161
|
+
|
162
|
+
Lint/UnderscorePrefixedVariableName:
|
163
|
+
Enabled: true
|
164
|
+
|
165
|
+
Lint/RedundantCopDisableDirective:
|
166
|
+
Enabled: true
|
167
|
+
|
168
|
+
Lint/RedundantSplatExpansion:
|
169
|
+
Enabled: true
|
170
|
+
|
171
|
+
Lint/UnreachableCode:
|
172
|
+
Enabled: true
|
173
|
+
|
174
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
175
|
+
Enabled: true
|
176
|
+
|
177
|
+
Lint/UselessSetterCall:
|
178
|
+
Enabled: true
|
179
|
+
|
180
|
+
Lint/Void:
|
181
|
+
Enabled: true
|
182
|
+
|
183
|
+
Metrics/AbcSize:
|
184
|
+
Enabled: false
|
185
|
+
|
186
|
+
Metrics/BlockLength:
|
187
|
+
Enabled: false
|
188
|
+
|
189
|
+
Metrics/BlockNesting:
|
190
|
+
Enabled: false
|
191
|
+
|
192
|
+
Metrics/ClassLength:
|
193
|
+
Enabled: false
|
194
|
+
|
195
|
+
Metrics/CyclomaticComplexity:
|
196
|
+
Enabled: false
|
197
|
+
|
198
|
+
Metrics/MethodLength:
|
199
|
+
Enabled: false
|
200
|
+
|
201
|
+
Metrics/ModuleLength:
|
202
|
+
Enabled: false
|
203
|
+
|
204
|
+
Metrics/ParameterLists:
|
205
|
+
Enabled: false
|
206
|
+
|
207
|
+
Metrics/PerceivedComplexity:
|
208
|
+
Enabled: false
|
209
|
+
|
210
|
+
Naming/AsciiIdentifiers:
|
211
|
+
Enabled: true
|
212
|
+
|
213
|
+
Naming/ClassAndModuleCamelCase:
|
214
|
+
Enabled: true
|
215
|
+
|
216
|
+
Naming/FileName:
|
217
|
+
Enabled: true
|
218
|
+
|
219
|
+
Naming/MethodName:
|
220
|
+
Enabled: true
|
221
|
+
|
222
|
+
Performance/CaseWhenSplat:
|
223
|
+
Enabled: false
|
224
|
+
|
225
|
+
Performance/Count:
|
226
|
+
Enabled: true
|
227
|
+
|
228
|
+
Performance/Detect:
|
229
|
+
Enabled: true
|
230
|
+
|
231
|
+
Performance/DoubleStartEndWith:
|
232
|
+
Enabled: true
|
233
|
+
|
234
|
+
Performance/EndWith:
|
235
|
+
Enabled: true
|
236
|
+
|
237
|
+
Performance/FlatMap:
|
238
|
+
Enabled: true
|
239
|
+
|
240
|
+
Performance/RangeInclude:
|
241
|
+
Enabled: false
|
242
|
+
|
243
|
+
Performance/RedundantMatch:
|
244
|
+
Enabled: false
|
245
|
+
|
246
|
+
Performance/RedundantMerge:
|
247
|
+
Enabled: true
|
248
|
+
MaxKeyValuePairs: 1
|
249
|
+
|
250
|
+
Performance/ReverseEach:
|
251
|
+
Enabled: true
|
252
|
+
|
253
|
+
Performance/Size:
|
254
|
+
Enabled: true
|
255
|
+
|
256
|
+
Performance/StartWith:
|
257
|
+
Enabled: true
|
258
|
+
|
259
|
+
Security/Eval:
|
260
|
+
Enabled: true
|
261
|
+
|
262
|
+
Style/ArrayJoin:
|
263
|
+
Enabled: true
|
264
|
+
|
265
|
+
Style/BeginBlock:
|
266
|
+
Enabled: true
|
267
|
+
|
268
|
+
Style/BlockComments:
|
269
|
+
Enabled: true
|
270
|
+
|
271
|
+
Style/CaseEquality:
|
272
|
+
Enabled: true
|
273
|
+
|
274
|
+
Style/CharacterLiteral:
|
275
|
+
Enabled: true
|
276
|
+
|
277
|
+
Style/ClassMethods:
|
278
|
+
Enabled: true
|
279
|
+
|
280
|
+
Style/Copyright:
|
281
|
+
Enabled: false
|
282
|
+
|
283
|
+
Style/DefWithParentheses:
|
284
|
+
Enabled: true
|
285
|
+
|
286
|
+
Style/EndBlock:
|
287
|
+
Enabled: true
|
288
|
+
|
289
|
+
Style/For:
|
290
|
+
Enabled: true
|
291
|
+
|
292
|
+
Style/FrozenStringLiteralComment:
|
293
|
+
Enabled: true
|
294
|
+
|
295
|
+
Style/HashSyntax:
|
296
|
+
Enabled: true
|
297
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
298
|
+
|
299
|
+
Style/LambdaCall:
|
300
|
+
Enabled: true
|
301
|
+
|
302
|
+
Style/MethodCallWithoutArgsParentheses:
|
303
|
+
Enabled: true
|
304
|
+
|
305
|
+
Style/MethodDefParentheses:
|
306
|
+
Enabled: true
|
307
|
+
|
308
|
+
Style/MultilineIfThen:
|
309
|
+
Enabled: true
|
310
|
+
|
311
|
+
Style/NilComparison:
|
312
|
+
Enabled: true
|
313
|
+
|
314
|
+
Style/Not:
|
315
|
+
Enabled: true
|
316
|
+
|
317
|
+
Style/OneLineConditional:
|
318
|
+
Enabled: true
|
319
|
+
|
320
|
+
Style/RedundantSortBy:
|
321
|
+
Enabled: true
|
322
|
+
|
323
|
+
Style/Sample:
|
324
|
+
Enabled: true
|
325
|
+
|
326
|
+
Style/StabbyLambdaParentheses:
|
327
|
+
Enabled: true
|
328
|
+
|
329
|
+
Style/Strip:
|
330
|
+
Enabled: true
|
331
|
+
|
332
|
+
Style/StringLiterals:
|
333
|
+
Enabled: true
|
334
|
+
EnforcedStyle: double_quotes
|
data/config/rails.yml
CHANGED
@@ -1,2 +1,127 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require:
|
2
|
+
- rubocop-rails
|
3
|
+
|
4
|
+
Rails/OutputSafety:
|
5
|
+
Enabled: true
|
6
|
+
|
7
|
+
Rails/PluralizationGrammar:
|
8
|
+
Enabled: true
|
9
|
+
|
10
|
+
Rails/RequestReferer:
|
11
|
+
Enabled: true
|
12
|
+
EnforcedStyle: referrer
|
13
|
+
|
14
|
+
Rails/ScopeArgs:
|
15
|
+
Enabled: true
|
16
|
+
|
17
|
+
Rails/UniqBeforePluck:
|
18
|
+
Enabled: true
|
19
|
+
|
20
|
+
GitHub/RailsApplicationRecord:
|
21
|
+
Enabled: true
|
22
|
+
|
23
|
+
GitHub/RailsControllerRenderActionSymbol:
|
24
|
+
Enabled: true
|
25
|
+
Include:
|
26
|
+
- 'app/controllers/**/*.rb'
|
27
|
+
|
28
|
+
GitHub/RailsControllerRenderLiteral:
|
29
|
+
Enabled: true
|
30
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md
|
31
|
+
Include:
|
32
|
+
- 'app/controllers/**/*.rb'
|
33
|
+
|
34
|
+
GitHub/RailsControllerRenderPathsExist:
|
35
|
+
Enabled: true
|
36
|
+
ViewPath:
|
37
|
+
- 'app/views'
|
38
|
+
Include:
|
39
|
+
- 'app/controllers/**/*.rb'
|
40
|
+
|
41
|
+
GitHub/RailsControllerRenderShorthand:
|
42
|
+
Enabled: true
|
43
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-shorthand.md
|
44
|
+
Include:
|
45
|
+
- 'app/controllers/**/*.rb'
|
46
|
+
|
47
|
+
GitHub/RailsRenderInline:
|
48
|
+
Enabled: true
|
49
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-inline.md
|
50
|
+
Include:
|
51
|
+
- 'app/controllers/**/*.rb'
|
52
|
+
- 'app/helpers/**/*.rb'
|
53
|
+
- 'app/view_models/**/*.rb'
|
54
|
+
- 'app/views/**/*.erb'
|
55
|
+
|
56
|
+
GitHub/RailsRenderObjectCollection:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
GitHub/RailsViewRenderLiteral:
|
60
|
+
Enabled: true
|
61
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md
|
62
|
+
Include:
|
63
|
+
- 'app/helpers/**/*.rb'
|
64
|
+
- 'app/view_models/**/*.rb'
|
65
|
+
- 'app/views/**/*.erb'
|
66
|
+
|
67
|
+
GitHub/RailsViewRenderPathsExist:
|
68
|
+
Enabled: true
|
69
|
+
ViewPath:
|
70
|
+
- 'app/views'
|
71
|
+
Include:
|
72
|
+
- 'app/helpers/**/*.rb'
|
73
|
+
- 'app/view_models/**/*.rb'
|
74
|
+
- 'app/views/**/*.erb'
|
75
|
+
|
76
|
+
GitHub/RailsViewRenderShorthand:
|
77
|
+
Enabled: true
|
78
|
+
Include:
|
79
|
+
- 'app/helpers/**/*.rb'
|
80
|
+
- 'app/view_models/**/*.rb'
|
81
|
+
- 'app/views/**/*.erb'
|
82
|
+
|
83
|
+
# Exclude Rails ERB files from incompatible cops
|
84
|
+
|
85
|
+
Layout/BlockAlignment:
|
86
|
+
Exclude:
|
87
|
+
- 'app/views/**/*.erb'
|
88
|
+
|
89
|
+
Style/For:
|
90
|
+
Exclude:
|
91
|
+
- 'app/views/**/*.erb'
|
92
|
+
|
93
|
+
Style/OneLineConditional:
|
94
|
+
Exclude:
|
95
|
+
- 'app/views/**/*.erb'
|
96
|
+
|
97
|
+
Style/Semicolon:
|
98
|
+
Exclude:
|
99
|
+
- 'app/views/**/*.erb'
|
100
|
+
|
101
|
+
Layout/SpaceInsideParens:
|
102
|
+
Exclude:
|
103
|
+
- 'app/views/**/*.erb'
|
104
|
+
|
105
|
+
Style/StringLiterals:
|
106
|
+
Exclude:
|
107
|
+
- 'app/views/**/*.erb'
|
108
|
+
|
109
|
+
Layout/TrailingEmptyLines:
|
110
|
+
Exclude:
|
111
|
+
- 'app/views/**/*.erb'
|
112
|
+
|
113
|
+
Layout/TrailingWhitespace:
|
114
|
+
Exclude:
|
115
|
+
- 'app/views/**/*.erb'
|
116
|
+
|
117
|
+
Layout/IndentationWidth:
|
118
|
+
Exclude:
|
119
|
+
- 'app/views/**/*.erb'
|
120
|
+
|
121
|
+
Layout/InitialIndentation:
|
122
|
+
Exclude:
|
123
|
+
- 'app/views/**/*.erb'
|
124
|
+
|
125
|
+
Lint/UselessAccessModifier:
|
126
|
+
ContextCreatingMethods:
|
127
|
+
- concerning
|
@@ -5,7 +5,7 @@ require "rubocop"
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
7
7
|
module GitHub
|
8
|
-
class InsecureHashAlgorithm <
|
8
|
+
class InsecureHashAlgorithm < Base
|
9
9
|
MSG = "This hash function is not allowed"
|
10
10
|
UUID_V3_MSG = "uuid_v3 uses MD5, which is not allowed"
|
11
11
|
UUID_V5_MSG = "uuid_v5 uses SHA1, which is not allowed"
|
@@ -5,7 +5,7 @@ require "rubocop"
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
7
7
|
module GitHub
|
8
|
-
class RailsApplicationRecord <
|
8
|
+
class RailsApplicationRecord < Base
|
9
9
|
MSG = "Models should subclass from ApplicationRecord"
|
10
10
|
|
11
11
|
def_node_matcher :active_record_base_const?, <<-PATTERN
|
@@ -20,7 +20,7 @@ module RuboCop
|
|
20
20
|
klass, superclass, _ = *node
|
21
21
|
|
22
22
|
if active_record_base_const?(superclass) && !(application_record_const?(klass))
|
23
|
-
add_offense(superclass
|
23
|
+
add_offense(superclass)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -5,7 +5,9 @@ require "rubocop"
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
7
7
|
module GitHub
|
8
|
-
class RailsControllerRenderActionSymbol <
|
8
|
+
class RailsControllerRenderActionSymbol < Base
|
9
|
+
extend AutoCorrector
|
10
|
+
|
9
11
|
MSG = "Prefer `render` with string instead of symbol"
|
10
12
|
|
11
13
|
def_node_matcher :render_sym?, <<-PATTERN
|
@@ -22,18 +24,22 @@ module RuboCop
|
|
22
24
|
|
23
25
|
def on_send(node)
|
24
26
|
if sym_node = render_sym?(node)
|
25
|
-
add_offense(sym_node
|
27
|
+
add_offense(sym_node) do |corrector|
|
28
|
+
register_offense(sym_node, node)
|
29
|
+
end
|
26
30
|
elsif option_pairs = render_with_options?(node)
|
27
31
|
option_pairs.each do |pair|
|
28
32
|
if sym_node = action_key?(pair)
|
29
|
-
|
33
|
+
register_offense(sym_node, node)
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
34
38
|
|
35
|
-
|
36
|
-
|
39
|
+
private
|
40
|
+
|
41
|
+
def register_offense(sym_node, node)
|
42
|
+
add_offense(sym_node) do |corrector|
|
37
43
|
corrector.replace(node.source_range, "\"#{node.children[0]}\"")
|
38
44
|
end
|
39
45
|
end
|
@@ -6,7 +6,7 @@ require "rubocop/cop/github/render_literal_helpers"
|
|
6
6
|
module RuboCop
|
7
7
|
module Cop
|
8
8
|
module GitHub
|
9
|
-
class RailsControllerRenderLiteral <
|
9
|
+
class RailsControllerRenderLiteral < Base
|
10
10
|
include RenderLiteralHelpers
|
11
11
|
|
12
12
|
MSG = "render must be used with a string literal or an instance of a Class"
|
@@ -66,29 +66,29 @@ module RuboCop
|
|
66
66
|
|
67
67
|
if template_node = option_pairs.map { |pair| template_key?(pair) }.compact.first
|
68
68
|
if !literal?(template_node)
|
69
|
-
add_offense(node
|
69
|
+
add_offense(node)
|
70
70
|
return
|
71
71
|
end
|
72
72
|
else
|
73
|
-
add_offense(node
|
73
|
+
add_offense(node)
|
74
74
|
return
|
75
75
|
end
|
76
76
|
|
77
77
|
if layout_node = option_pairs.map { |pair| layout_key?(pair) }.compact.first
|
78
78
|
if !literal?(layout_node)
|
79
|
-
add_offense(node
|
79
|
+
add_offense(node)
|
80
80
|
return
|
81
81
|
end
|
82
82
|
end
|
83
83
|
else
|
84
|
-
add_offense(node
|
84
|
+
add_offense(node)
|
85
85
|
return
|
86
86
|
end
|
87
87
|
|
88
88
|
if render_literal?(node)
|
89
89
|
option_hash = node.arguments[1]
|
90
90
|
if option_hash && !option_hash.hash_type?
|
91
|
-
add_offense(node
|
91
|
+
add_offense(node)
|
92
92
|
return
|
93
93
|
end
|
94
94
|
option_pairs = option_hash && option_hash.pairs
|
@@ -99,7 +99,7 @@ module RuboCop
|
|
99
99
|
if option_pairs
|
100
100
|
locals = option_pairs.map { |pair| locals_key?(pair) }.compact.first
|
101
101
|
if locals && (!locals.hash_type? || !hash_with_literal_keys?(locals))
|
102
|
-
add_offense(node
|
102
|
+
add_offense(node)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|