-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.rubocop.yml
551 lines (480 loc) · 14.2 KB
/
.rubocop.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
# This is the configuration used to check the rubocop source code.
inherit_from: .rubocop_todo.yml
require:
- rubocop/cop/internal_affairs
# - rubocop-performance
# - rubocop-rspec
- rubocop-rake
AllCops:
NewCops: enable
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'tmp/**/*'
- '.git/**/*'
- 'bin/*'
- 'node_modules/**/*'
- 'solr/**/'
- 'solr/**/**'
- 'vendor/**/*'
- 'db/*'
- 'test/test_helper.rb'
- 'Gemfile'
- 'config/initializers/*'
- 'db/migrate/*'
- 'test/**/*'
- 'spec/*/*/*/*'
- 'spec/**/**/**/**'
- 'spec/*/*/*'
- 'app/assets/javascripts/*.js.coffee'
- 'app/assets/javascripts/collections.js'
- 'app/helpers/devise_helper.rb'
- 'config/initializers/sunspot/indexer.rb'
- 'lib/tasks/**/*'
- 'lib/custom_fields/**/*'
- app/services/aviary/alberta.rb
TargetRubyVersion: 2.5
SuggestExtensions: false
Naming/PredicateName:
# Method define macros for dynamically generated method.
MethodDefinitionMacros:
- define_method
- define_singleton_method
- def_node_matcher
- def_node_search
Exclude:
- app/helpers/blacklight/facets_helper_behavior.rb
Style/AccessorGrouping:
Enabled: false
Exclude:
- lib/rubocop/formatter/base_formatter.rb
- lib/rubocop/cop/offense.rb
Style/FormatStringToken:
Enabled: false
# Because we parse a lot of source codes from strings. Percent arrays
# look like unannotated format string tokens to this cop.
Exclude:
- spec/**/*
Style/IpAddresses:
# The test for this cop includes strings that would cause offenses
Exclude:
- spec/rubocop/cop/style/ip_addresses_spec.rb
Layout/EndOfLine:
Description: 'Use Unix-style line endings.'
StyleGuide: '#crlf'
Enabled: false
VersionAdded: '0.49'
# The `native` style means that CR+LF (Carriage Return + Line Feed) is
# enforced on Windows, and LF is enforced on other platforms. The other styles
# mean LF and CR+LF, respectively.
EnforcedStyle: native
SupportedStyles:
- native
- lf
- crlf
Layout/ClassStructure:
Enabled: true
Layout/RedundantLineBreak:
Enabled: false
Layout/TrailingWhitespace:
AllowInHeredoc: false
Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/**/*.rb'
Layout/HashAlignment:
EnforcedHashRocketStyle:
- key
- table
EnforcedColonStyle:
- key
- table
Layout/LineLength:
Max: 435
Lint/InterpolationCheck:
Exclude:
- 'spec/**/*.rb'
Lint/UselessAccessModifier:
MethodCreatingMethods:
- 'def_matcher'
- 'def_node_matcher'
Metrics/BlockLength:
Max: 500
Exclude:
- 'Rakefile'
- '**/*.rake'
- 'spec/**/*.rb'
- '**/*.gemspec'
- config/routes.rb
Metrics/ClassLength:
Max: 950
Exclude:
- lib/rubocop/config_obsoletion.rb
Metrics/ModuleLength:
Max: 400
Exclude:
- 'spec/**/*.rb'
Naming/InclusiveLanguage:
FlaggedTerms:
offence:
Suggestions:
- offense
Exclude:
- lib/rubocop/cop/naming/inclusive_language.rb
#Performance/CollectionLiteralInLoop:
# Enabled: false
# Exclude:
# - 'Rakefile'
# - 'spec/**/*.rb'
#
#Performance/EndWith:
# SafeMultiline: false
#
#Performance/StartWith:
# SafeMultiline: false
InternalAffairs/ExampleDescription:
Include:
- 'spec/rubocop/cop/**/*.rb'
InternalAffairs/UndefinedConfig:
Include:
- 'lib/rubocop/cop/**/*.rb'
Exclude:
- 'lib/rubocop/cop/correctors/**/*.rb'
- 'lib/rubocop/cop/mixin/**/*.rb'
InternalAffairs/StyleDetectedApiUse:
Exclude:
- 'lib/rubocop/cop/mixin/percent_array.rb'
Metrics/MethodLength:
Description: 'Avoid methods longer than 10 lines of code.'
StyleGuide: '#short-methods'
Enabled: true
VersionAdded: '0.25'
VersionChanged: '0.59.2'
CountComments: false # count full line comments?
Max: 285
Layout/EmptyLineAfterGuardClause:
Description: 'Add empty line after guard clause.'
Enabled: false
VersionAdded: '0.56'
VersionChanged: '0.59'
Style/ExpandPathArguments:
Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`."
Enabled: false
VersionAdded: '0.53'
Style/FrozenStringLiteralComment:
Description: >-
Add the frozen_string_literal comment to the top of files
to help transition to frozen string literals by default.
Enabled: false
VersionAdded: '0.36'
VersionChanged: '0.79'
EnforcedStyle: always
SupportedStyles:
# `always` will always add the frozen string literal comment to a file
# regardless of the Ruby version or if `freeze` or `<<` are called on a
# string literal. If you run code against multiple versions of Ruby, it is
# possible that this will create errors in Ruby 2.3.0+.
- always
# `always_true` will add the frozen string literal comment to a file,
# similarly to the `always` style, but will also change any disabled
# comments (e.g. `# frozen_string_literal: false`) to be enabled.
- always_true
# `never` will enforce that the frozen string literal comment does not
# exist in a file.
- never
Metrics/AbcSize:
Description: >-
A calculated magnitude based on number of assignments,
branches, and conditions.
Reference:
- http://c2.com/cgi/wiki?AbcMetric
- https://en.wikipedia.org/wiki/ABC_Software_Metric
Enabled: true
VersionAdded: '0.27'
VersionChanged: '0.81'
# The ABC size is a calculated magnitude, so this number can be an Integer or
# a Float.
Max: 520
Metrics/BlockNesting:
Description: 'Avoid excessive block nesting.'
StyleGuide: '#three-is-the-number-thou-shalt-count'
Enabled: true
VersionAdded: '0.25'
VersionChanged: '0.47'
CountBlocks: false
Max: 15
Style/IfUnlessModifier:
Description: >-
Favor modifier if/unless usage when you have a
single-line body.
StyleGuide: '#if-as-a-modifier'
Enabled: false
VersionAdded: '0.9'
VersionChanged: '0.30'
Style/BlockDelimiters:
Description: >-
Avoid using {...} for multi-line blocks (multiline chaining is
always ugly).
Prefer {...} over do...end for single-line blocks.
StyleGuide: '#single-line-blocks'
Enabled: false
VersionAdded: '0.30'
VersionChanged: '0.35'
EnforcedStyle: line_count_based
SupportedStyles:
# The `line_count_based` style enforces braces around single line blocks and
# do..end around multi-line blocks.
- line_count_based
# The `semantic` style enforces braces around functional blocks, where the
# primary purpose of the block is to return a value and do..end for
# multi-line procedural blocks, where the primary purpose of the block is
# its side-effects. Single-line procedural blocks may only use do-end,
# unless AllowBracesOnProceduralOneLiners has a truthy value (see below).
#
# This looks at the usage of a block's method to determine its type (e.g. is
# the result of a `map` assigned to a variable or passed to another
# method) but exceptions are permitted in the `ProceduralMethods`,
# `FunctionalMethods` and `IgnoredMethods` sections below.
- semantic
# The `braces_for_chaining` style enforces braces around single line blocks
# and do..end around multi-line blocks, except for multi-line blocks whose
# return value is being chained with another method (in which case braces
# are enforced).
- braces_for_chaining
# The `always_braces` style always enforces braces.
- always_braces
ProceduralMethods:
# Methods that are known to be procedural in nature but look functional from
# their usage, e.g.
#
# time = Benchmark.realtime do
# foo.bar
# end
#
# Here, the return value of the block is discarded but the return value of
# `Benchmark.realtime` is used.
- benchmark
- bm
- bmbm
- create
- each_with_object
- measure
- new
- realtime
- tap
- with_object
FunctionalMethods:
# Methods that are known to be functional in nature but look procedural from
# their usage, e.g.
#
# let(:foo) { Foo.new }
#
# Here, the return value of `Foo.new` is used to define a `foo` helper but
# doesn't appear to be used from the return value of `let`.
- let
- let!
- subject
- watch
# The AllowBracesOnProceduralOneLiners option is ignored unless the
# EnforcedStyle is set to `semantic`. If so:
#
# If AllowBracesOnProceduralOneLiners is unspecified, or set to any
# falsey value, then semantic purity is maintained, so one-line
# procedural blocks must use do-end, not braces.
#
# # bad
# collection.each { |element| puts element }
#
# # good
# collection.each do |element| puts element end
#
# If AllowBracesOnProceduralOneLiners is set to any truthy value,
# then one-line procedural blocks may use either style.
#
# # good
# collection.each { |element| puts element }
#
# # also good
# collection.each do |element| puts element end
AllowBracesOnProceduralOneLiners: false
# The BracesRequiredMethods overrides all other configurations except
# IgnoredMethods. It can be used to enforce that all blocks for specific
# methods use braces. For example, you can use this to enforce Sorbet
# signatures use braces even when the rest of your codebase enforces
# the `line_count_based` style.
BracesRequiredMethods: []
Metrics/PerceivedComplexity:
Description: >-
A complexity metric geared towards measuring complexity for a
human reader.
Enabled: true
VersionAdded: '0.25'
VersionChanged: '0.81'
Max: 100
Metrics/CyclomaticComplexity:
Description: >-
A complexity metric that is strongly correlated to the number
of test cases needed to validate a method.
Enabled: true
VersionAdded: '0.25'
VersionChanged: '0.81'
Max: 100
Layout/EmptyLines:
Description: "Don't use several empty lines in a row."
StyleGuide: '#two-or-more-empty-lines'
Enabled: true
VersionAdded: '0.49'
Style/ClassAndModuleChildren:
Description: 'Checks style of children classes and modules.'
StyleGuide: '#namespace-definition'
# Moving from compact to nested children requires knowledge of whether the
# outer parent is a module or a class. Moving from nested to compact requires
# verification that the outer parent is defined elsewhere. Rubocop does not
# have the knowledge to perform either operation safely and thus requires
# manual oversight.
SafeAutoCorrect: false
AutoCorrect: false
Enabled: false
VersionAdded: '0.19'
#
# Basically there are two different styles:
#
# `nested` - have each child on a separate line
# class Foo
# class Bar
# end
# end
#
# `compact` - combine definitions as much as possible
# class Foo::Bar
# end
#
# The compact style is only forced, for classes or modules with one child.
EnforcedStyle: nested
SupportedStyles:
- nested
- compact
Style/StringLiterals:
Description: 'Checks if uses of quotes match the configured preference.'
StyleGuide: '#consistent-string-literals'
Enabled: true
VersionAdded: '0.9'
VersionChanged: '0.36'
EnforcedStyle: single_quotes
SupportedStyles:
- single_quotes
- double_quotes
# If `true`, strings which span multiple lines using `\` for continuation must
# use the same type of quotes on each line.
ConsistentQuotesInMultiline: false
Style/RedundantRegexpEscape:
Enabled: false
Style/StringConcatenation:
Enabled: false
Lint/AmbiguousOperatorPrecedence:
Enabled: false
Style/CaseLikeIf:
Enabled: false
Style/SoleNestedConditional:
Enabled: false
Style/RedundantArgument:
Enabled: false
Style/OptionalBooleanParameter:
Enabled: false
Lint/UselessMethodDefinition:
Enabled: false
Lint/EmptyClass:
Enabled: false
Style/Next:
Description: 'Use `next` to skip iteration instead of a condition at the end.'
StyleGuide: '#no-nested-conditionals'
Enabled: false
VersionAdded: '0.22'
VersionChanged: '0.35'
# With `always` all conditions at the end of an iteration needs to be
# replaced by next - with `skip_modifier_ifs` the modifier if like this one
# are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
EnforcedStyle: skip_modifier_ifs
# `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
# needs to have to trigger this cop
MinBodyLength: 3
SupportedStyles:
- skip_modifier_ifs
- always
Style/HashTransformValues:
Description: 'Prefer `transform_values` over `each_with_object` and `map`.'
Enabled: false
VersionAdded: '0.80'
Safe: false
Style/HashConversion:
Enabled: false
Lint/SelfAssignment:
Enabled: false
Style/CombinableLoops:
Enabled: false
Style/ClassEqualityComparison:
Enabled: false
Style/RedundantSelfAssignmentBranch:
Enabled: false
Lint/Void:
Description: 'Possible use of operator/literal/variable in void context.'
Enabled: false
VersionAdded: '0.9'
CheckForMethodsWithNoSideEffects: false
#Performance/Casecmp:
# Enabled: false
Style/NegatedIfElseCondition:
Enabled: false
Naming/VariableNumber:
Enabled: false
Naming/RescuedExceptionsVariableName:
Enabled: false
Style/NumericPredicate:
Enabled: false
Security/Open:
Enabled: false
Metrics/ParameterLists:
Description: 'Avoid parameter lists longer than three or four parameters.'
StyleGuide: '#too-many-params'
Enabled: true
VersionAdded: '0.25'
Max: 10
MaxOptionalParameters: 6
CountKeywordArgs: true
Lint/DuplicateBranch:
Enabled: false
Style/RedundantAssignment:
Enabled: false
Style/PercentLiteralDelimiters:
Description: 'Use `%`-literal delimiters consistently.'
StyleGuide: '#percent-literal-braces'
Enabled: false
VersionAdded: '0.19'
# Specify the default preferred delimiter for all types with the 'default' key
# Override individual delimiters (even with default specified) by specifying
# an individual key
PreferredDelimiters:
default: ()
'%i': '[]'
'%I': '[]'
'%r': '{}'
'%w': '[]'
'%W': '[]'
VersionChanged: '0.48.1'
Lint/MissingSuper:
Enabled: false
Security/Eval:
Description: 'The use of eval represents a serious security risk.'
Enabled: false
VersionAdded: '0.47'
Style/IfWithBooleanLiteralBranches:
Enabled: false
Style/DocumentDynamicEvalDefinition:
Enabled: false
Style/StringChars:
Enabled: false
Lint/DuplicateElsifCondition:
Enabled: false
Lint/UselessAssignment:
# Method define macros for dynamically generated method.
Exclude:
- app/helpers/blacklight/facets_helper_behavior.rb