rubocop-github 0.17.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ GitHub/InsecureHashAlgorithm:
2
+ Description: 'Encourage usage of secure hash algorithms'
3
+ Enabled: pending
data/config/rails.yml CHANGED
@@ -1,2 +1,414 @@
1
- # Inherit from rails_deprecated until 1.0
2
- inherit_from: rails_deprecated.yml
1
+ require:
2
+ - rubocop-github-rails
3
+ - rubocop-rails
4
+
5
+ GitHub/RailsApplicationRecord:
6
+ Enabled: true
7
+
8
+ GitHub/RailsControllerRenderActionSymbol:
9
+ Enabled: true
10
+
11
+ GitHub/RailsControllerRenderLiteral:
12
+ Enabled: true
13
+
14
+ GitHub/RailsControllerRenderPathsExist:
15
+ Enabled: true
16
+
17
+ GitHub/RailsControllerRenderShorthand:
18
+ Enabled: true
19
+
20
+ GitHub/RailsRenderInline:
21
+ Enabled: true
22
+
23
+ GitHub/RailsRenderObjectCollection:
24
+ Enabled: false
25
+
26
+ GitHub/RailsViewRenderLiteral:
27
+ Enabled: true
28
+
29
+ GitHub/RailsViewRenderPathsExist:
30
+ Enabled: true
31
+
32
+ GitHub/RailsViewRenderShorthand:
33
+ Enabled: true
34
+
35
+ Layout/BlockAlignment:
36
+ Exclude:
37
+ - app/views/**/*.erb
38
+
39
+ Layout/IndentationWidth:
40
+ Exclude:
41
+ - app/views/**/*.erb
42
+
43
+ Layout/InitialIndentation:
44
+ Exclude:
45
+ - app/views/**/*.erb
46
+
47
+ Layout/SpaceInsideParens:
48
+ Exclude:
49
+ - app/views/**/*.erb
50
+
51
+ Layout/TrailingEmptyLines:
52
+ Exclude:
53
+ - app/views/**/*.erb
54
+
55
+ Layout/TrailingWhitespace:
56
+ Exclude:
57
+ - app/views/**/*.erb
58
+
59
+ Lint/UselessAccessModifier:
60
+ ContextCreatingMethods:
61
+ - concerning
62
+
63
+ Rails/ActionControllerTestCase:
64
+ Enabled: false
65
+
66
+ Rails/ActionFilter:
67
+ Enabled: false
68
+
69
+ Rails/ActiveRecordAliases:
70
+ Enabled: false
71
+
72
+ Rails/ActiveRecordCallbacksOrder:
73
+ Enabled: false
74
+
75
+ Rails/ActiveRecordOverride:
76
+ Enabled: false
77
+
78
+ Rails/ActiveSupportAliases:
79
+ Enabled: false
80
+
81
+ Rails/AddColumnIndex:
82
+ Enabled: false
83
+
84
+ Rails/AfterCommitOverride:
85
+ Enabled: false
86
+
87
+ Rails/ApplicationController:
88
+ Enabled: false
89
+
90
+ Rails/ApplicationJob:
91
+ Enabled: false
92
+
93
+ Rails/ApplicationMailer:
94
+ Enabled: false
95
+
96
+ Rails/ApplicationRecord:
97
+ Enabled: false
98
+
99
+ Rails/ArelStar:
100
+ Enabled: false
101
+
102
+ Rails/AssertNot:
103
+ Enabled: false
104
+
105
+ Rails/AttributeDefaultBlockValue:
106
+ Enabled: false
107
+
108
+ Rails/BelongsTo:
109
+ Enabled: false
110
+
111
+ Rails/Blank:
112
+ Enabled: false
113
+
114
+ Rails/BulkChangeTable:
115
+ Enabled: false
116
+
117
+ Rails/CompactBlank:
118
+ Enabled: false
119
+
120
+ Rails/ContentTag:
121
+ Enabled: false
122
+
123
+ Rails/CreateTableWithTimestamps:
124
+ Enabled: false
125
+
126
+ Rails/Date:
127
+ Enabled: false
128
+
129
+ Rails/DefaultScope:
130
+ Enabled: false
131
+
132
+ Rails/Delegate:
133
+ Enabled: false
134
+
135
+ Rails/DelegateAllowBlank:
136
+ Enabled: false
137
+
138
+ Rails/DeprecatedActiveModelErrorsMethods:
139
+ Enabled: false
140
+
141
+ Rails/DotSeparatedKeys:
142
+ Enabled: false
143
+
144
+ Rails/DuplicateAssociation:
145
+ Enabled: false
146
+
147
+ Rails/DuplicateScope:
148
+ Enabled: false
149
+
150
+ Rails/DurationArithmetic:
151
+ Enabled: false
152
+
153
+ Rails/DynamicFindBy:
154
+ Enabled: false
155
+
156
+ Rails/EagerEvaluationLogMessage:
157
+ Enabled: false
158
+
159
+ Rails/EnumHash:
160
+ Enabled: false
161
+
162
+ Rails/EnumUniqueness:
163
+ Enabled: false
164
+
165
+ Rails/EnvironmentComparison:
166
+ Enabled: false
167
+
168
+ Rails/EnvironmentVariableAccess:
169
+ Enabled: false
170
+
171
+ Rails/Exit:
172
+ Enabled: false
173
+
174
+ Rails/ExpandedDateRange:
175
+ Enabled: false
176
+
177
+ Rails/FilePath:
178
+ Enabled: false
179
+
180
+ Rails/FindBy:
181
+ Enabled: false
182
+
183
+ Rails/FindById:
184
+ Enabled: false
185
+
186
+ Rails/FindEach:
187
+ Enabled: false
188
+
189
+ Rails/HasAndBelongsToMany:
190
+ Enabled: false
191
+
192
+ Rails/HasManyOrHasOneDependent:
193
+ Enabled: false
194
+
195
+ Rails/HelperInstanceVariable:
196
+ Enabled: false
197
+
198
+ Rails/HttpPositionalArguments:
199
+ Enabled: false
200
+
201
+ Rails/HttpStatus:
202
+ Enabled: false
203
+
204
+ Rails/I18nLazyLookup:
205
+ Enabled: false
206
+
207
+ Rails/I18nLocaleAssignment:
208
+ Enabled: false
209
+
210
+ Rails/I18nLocaleTexts:
211
+ Enabled: false
212
+
213
+ Rails/IgnoredSkipActionFilterOption:
214
+ Enabled: false
215
+
216
+ Rails/IndexBy:
217
+ Enabled: false
218
+
219
+ Rails/IndexWith:
220
+ Enabled: false
221
+
222
+ Rails/Inquiry:
223
+ Enabled: false
224
+
225
+ Rails/InverseOf:
226
+ Enabled: false
227
+
228
+ Rails/LexicallyScopedActionFilter:
229
+ Enabled: false
230
+
231
+ Rails/LinkToBlank:
232
+ Enabled: false
233
+
234
+ Rails/MailerName:
235
+ Enabled: false
236
+
237
+ Rails/MatchRoute:
238
+ Enabled: false
239
+
240
+ Rails/MigrationClassName:
241
+ Enabled: false
242
+
243
+ Rails/NegateInclude:
244
+ Enabled: false
245
+
246
+ Rails/NotNullColumn:
247
+ Enabled: false
248
+
249
+ Rails/OrderById:
250
+ Enabled: false
251
+
252
+ Rails/Output:
253
+ Enabled: false
254
+
255
+ Rails/OutputSafety:
256
+ Enabled: true
257
+
258
+ Rails/Pick:
259
+ Enabled: false
260
+
261
+ Rails/Pluck:
262
+ Enabled: false
263
+
264
+ Rails/PluckId:
265
+ Enabled: false
266
+
267
+ Rails/PluckInWhere:
268
+ Enabled: false
269
+
270
+ Rails/PluralizationGrammar:
271
+ Enabled: true
272
+
273
+ Rails/Presence:
274
+ Enabled: false
275
+
276
+ Rails/Present:
277
+ Enabled: false
278
+
279
+ Rails/RakeEnvironment:
280
+ Enabled: false
281
+
282
+ Rails/ReadWriteAttribute:
283
+ Enabled: false
284
+
285
+ Rails/RedundantAllowNil:
286
+ Enabled: false
287
+
288
+ Rails/RedundantForeignKey:
289
+ Enabled: false
290
+
291
+ Rails/RedundantPresenceValidationOnBelongsTo:
292
+ Enabled: false
293
+
294
+ Rails/RedundantReceiverInWithOptions:
295
+ Enabled: false
296
+
297
+ Rails/RedundantTravelBack:
298
+ Enabled: false
299
+
300
+ Rails/ReflectionClassName:
301
+ Enabled: false
302
+
303
+ Rails/RefuteMethods:
304
+ Enabled: false
305
+
306
+ Rails/RelativeDateConstant:
307
+ Enabled: false
308
+
309
+ Rails/RenderInline:
310
+ Enabled: false
311
+
312
+ Rails/RenderPlainText:
313
+ Enabled: false
314
+
315
+ Rails/RequestReferer:
316
+ Enabled: true
317
+ EnforcedStyle: referrer
318
+
319
+ Rails/RequireDependency:
320
+ Enabled: false
321
+
322
+ Rails/ReversibleMigration:
323
+ Enabled: false
324
+
325
+ Rails/ReversibleMigrationMethodDefinition:
326
+ Enabled: false
327
+
328
+ Rails/RootJoinChain:
329
+ Enabled: false
330
+
331
+ Rails/RootPublicPath:
332
+ Enabled: false
333
+
334
+ Rails/SafeNavigation:
335
+ Enabled: false
336
+
337
+ Rails/SafeNavigationWithBlank:
338
+ Enabled: false
339
+
340
+ Rails/SaveBang:
341
+ Enabled: false
342
+
343
+ Rails/SchemaComment:
344
+ Enabled: false
345
+
346
+ Rails/ScopeArgs:
347
+ Enabled: true
348
+
349
+ Rails/ShortI18n:
350
+ Enabled: false
351
+
352
+ Rails/SkipsModelValidations:
353
+ Enabled: false
354
+
355
+ Rails/SquishedSQLHeredocs:
356
+ Enabled: false
357
+
358
+ Rails/StripHeredoc:
359
+ Enabled: false
360
+
361
+ Rails/TableNameAssignment:
362
+ Enabled: false
363
+
364
+ Rails/TimeZone:
365
+ Enabled: false
366
+
367
+ Rails/TimeZoneAssignment:
368
+ Enabled: false
369
+
370
+ Rails/ToFormattedS:
371
+ Enabled: false
372
+
373
+ Rails/TransactionExitStatement:
374
+ Enabled: false
375
+
376
+ Rails/UniqBeforePluck:
377
+ Enabled: true
378
+
379
+ Rails/UniqueValidationWithoutIndex:
380
+ Enabled: false
381
+
382
+ Rails/UnknownEnv:
383
+ Enabled: false
384
+
385
+ Rails/UnusedIgnoredColumns:
386
+ Enabled: false
387
+
388
+ Rails/Validation:
389
+ Enabled: false
390
+
391
+ Rails/WhereEquals:
392
+ Enabled: false
393
+
394
+ Rails/WhereExists:
395
+ Enabled: false
396
+
397
+ Rails/WhereNot:
398
+ Enabled: false
399
+
400
+ Style/For:
401
+ Exclude:
402
+ - app/views/**/*.erb
403
+
404
+ Style/OneLineConditional:
405
+ Exclude:
406
+ - app/views/**/*.erb
407
+
408
+ Style/Semicolon:
409
+ Exclude:
410
+ - app/views/**/*.erb
411
+
412
+ Style/StringLiterals:
413
+ Exclude:
414
+ - app/views/**/*.erb
@@ -1,48 +1,32 @@
1
- Rails/OutputSafety:
2
- Enabled: true
3
-
4
- Rails/PluralizationGrammar:
5
- Enabled: true
6
-
7
- Rails/RequestReferer:
8
- Enabled: true
9
- EnforcedStyle: referrer
10
-
11
- Rails/ScopeArgs:
12
- Enabled: true
13
-
14
- Rails/UniqBeforePluck:
15
- Enabled: true
16
-
17
1
  GitHub/RailsApplicationRecord:
18
- Enabled: true
2
+ Enabled: pending
19
3
 
20
4
  GitHub/RailsControllerRenderActionSymbol:
21
- Enabled: true
5
+ Enabled: pending
22
6
  Include:
23
7
  - 'app/controllers/**/*.rb'
24
8
 
25
9
  GitHub/RailsControllerRenderLiteral:
26
- Enabled: true
10
+ Enabled: pending
27
11
  StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md
28
12
  Include:
29
13
  - 'app/controllers/**/*.rb'
30
14
 
31
15
  GitHub/RailsControllerRenderPathsExist:
32
- Enabled: true
16
+ Enabled: pending
33
17
  ViewPath:
34
18
  - 'app/views'
35
19
  Include:
36
20
  - 'app/controllers/**/*.rb'
37
21
 
38
22
  GitHub/RailsControllerRenderShorthand:
39
- Enabled: true
23
+ Enabled: pending
40
24
  StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-shorthand.md
41
25
  Include:
42
26
  - 'app/controllers/**/*.rb'
43
27
 
44
28
  GitHub/RailsRenderInline:
45
- Enabled: true
29
+ Enabled: pending
46
30
  StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-inline.md
47
31
  Include:
48
32
  - 'app/controllers/**/*.rb'
@@ -51,10 +35,10 @@ GitHub/RailsRenderInline:
51
35
  - 'app/views/**/*.erb'
52
36
 
53
37
  GitHub/RailsRenderObjectCollection:
54
- Enabled: false
38
+ Enabled: pending
55
39
 
56
40
  GitHub/RailsViewRenderLiteral:
57
- Enabled: true
41
+ Enabled: pending
58
42
  StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md
59
43
  Include:
60
44
  - 'app/helpers/**/*.rb'
@@ -62,7 +46,7 @@ GitHub/RailsViewRenderLiteral:
62
46
  - 'app/views/**/*.erb'
63
47
 
64
48
  GitHub/RailsViewRenderPathsExist:
65
- Enabled: true
49
+ Enabled: pending
66
50
  ViewPath:
67
51
  - 'app/views'
68
52
  Include:
@@ -71,50 +55,8 @@ GitHub/RailsViewRenderPathsExist:
71
55
  - 'app/views/**/*.erb'
72
56
 
73
57
  GitHub/RailsViewRenderShorthand:
74
- Enabled: true
58
+ Enabled: pending
75
59
  Include:
76
60
  - 'app/helpers/**/*.rb'
77
61
  - 'app/view_models/**/*.rb'
78
62
  - 'app/views/**/*.erb'
79
-
80
- # Exclude Rails ERB files from incompatible cops
81
-
82
- Layout/BlockAlignment:
83
- Exclude:
84
- - 'app/views/**/*.erb'
85
-
86
- Style/For:
87
- Exclude:
88
- - 'app/views/**/*.erb'
89
-
90
- Style/OneLineConditional:
91
- Exclude:
92
- - 'app/views/**/*.erb'
93
-
94
- Style/Semicolon:
95
- Exclude:
96
- - 'app/views/**/*.erb'
97
-
98
- Layout/SpaceInsideParens:
99
- Exclude:
100
- - 'app/views/**/*.erb'
101
-
102
- Style/StringLiterals:
103
- Exclude:
104
- - 'app/views/**/*.erb'
105
-
106
- Layout/TrailingEmptyLines:
107
- Exclude:
108
- - 'app/views/**/*.erb'
109
-
110
- Layout/TrailingWhitespace:
111
- Exclude:
112
- - 'app/views/**/*.erb'
113
-
114
- Layout/InitialIndentation:
115
- Exclude:
116
- - 'app/views/**/*.erb'
117
-
118
- Lint/UselessAccessModifier:
119
- ContextCreatingMethods:
120
- - concerning
@@ -5,7 +5,7 @@ require "rubocop"
5
5
  module RuboCop
6
6
  module Cop
7
7
  module GitHub
8
- class InsecureHashAlgorithm < Cop
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 < Cop
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, location: :expression)
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 < Cop
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, location: :expression)
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
- add_offense(sym_node, location: :expression)
33
+ register_offense(sym_node, node)
30
34
  end
31
35
  end
32
36
  end
33
37
  end
34
38
 
35
- def autocorrect(node)
36
- lambda do |corrector|
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 < Cop
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, location: :expression)
69
+ add_offense(node)
70
70
  return
71
71
  end
72
72
  else
73
- add_offense(node, location: :expression)
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, location: :expression)
79
+ add_offense(node)
80
80
  return
81
81
  end
82
82
  end
83
83
  else
84
- add_offense(node, location: :expression)
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, location: :expression)
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, location: :expression)
102
+ add_offense(node)
103
103
  end
104
104
  end
105
105
  end
@@ -5,7 +5,7 @@ require "rubocop"
5
5
  module RuboCop
6
6
  module Cop
7
7
  module GitHub
8
- class RailsControllerRenderPathsExist < Cop
8
+ class RailsControllerRenderPathsExist < Base
9
9
  def_node_matcher :render?, <<-PATTERN
10
10
  (send nil? {:render :render_to_string} $...)
11
11
  PATTERN
@@ -28,7 +28,7 @@ module RuboCop
28
28
  if args = render_str?(node)
29
29
  node, path = args
30
30
  unless resolve_template(path.to_s)
31
- add_offense(node, location: :expression, message: "Template could not be found")
31
+ add_offense(node, message: "Template could not be found")
32
32
  end
33
33
  elsif pairs = render_options?(node)
34
34
  if pair = pairs.detect { |p| render_key?(p) }
@@ -37,11 +37,11 @@ module RuboCop
37
37
  case key
38
38
  when :action, :template
39
39
  unless resolve_template(path.to_s)
40
- add_offense(node, location: :expression, message: "Template could not be found")
40
+ add_offense(node, message: "Template could not be found")
41
41
  end
42
42
  when :partial
43
43
  unless resolve_partial(path.to_s)
44
- add_offense(node, location: :expression, message: "Partial template could not be found")
44
+ add_offense(node, message: "Partial template could not be found")
45
45
  end
46
46
  end
47
47
  end