-
Notifications
You must be signed in to change notification settings - Fork 375
/
.rubocop.yml
428 lines (346 loc) · 10.5 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
inherit_from: .rubocop_todo.yml
require:
- rubocop-packaging
- rubocop-performance
- rubocop-rspec
AllCops:
TargetRubyVersion: 2.6 # Lowest version supported as of Rubocop 1.29.0
Include:
- 'lib/**/*.rb'
- 'ext/**/*.rb'
- 'test/**/*.rb'
- 'spec/**/*.rb'
- 'yard/**/*.rb'
- 'Gemfile'
- 'Rakefile'
Exclude:
- 'Appraisals'
- 'lib/ddtrace/**/vendor/**/*.rb'
- 'lib/datadog/**/vendor/**/*.rb'
- 'integration/apps/*/bin/*'
- 'integration/apps/*/Gemfile'
- 'integration/apps/hanami/Rakefile'
- 'lib/datadog/profiling/pprof/pprof_pb.rb'
- 'spec/**/**/interesting_backtrace_helper.rb' # This file needs quite a few bizarre code patterns by design
NewCops: disable # Don't allow new cops to be enabled implicitly.
Layout/LineLength:
Max: 124
Exclude:
- 'Rakefile'
# These exceptions are good goals to attain, and probably will over time,
# so periodic disabling and re-running to inspect values is suggested.
Metrics/AbcSize:
Max: 50
# TODO: As refactors continue, this should drop. However, the goal of
# 10 lines in a method may be a little lofty.
Metrics/MethodLength:
Max: 36
Performance/Casecmp:
Enabled: false
# TODO: this is not compliant with the Ruby community style guide. We
# should enable again this rule but it will change the public API because
# we're using set_ methods. We should work on that because also Rails
# honors this rule.
Naming/AccessorMethodName:
Enabled: false
Naming/MemoizedInstanceVariableName:
Enabled: false
Style/RescueModifier:
Enabled: false
Style/NumericLiterals:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/BlockLength:
Max: 42
Exclude:
- test/**/*
- spec/**/*
Metrics/ModuleLength:
Enabled: false
Metrics/ParameterLists:
Enabled: false
Metrics/CyclomaticComplexity:
Max: 15
Metrics/PerceivedComplexity:
Max: 15
Lint/UnusedMethodArgument:
Enabled: false
Style/RescueStandardError:
Enabled: false
# alias and alias_method are not equivalent
Style/Alias:
Enabled: false
# Disabling advices that would lead to incompatible Ruby 1.9 code
Style/SymbolArray:
Enabled: false
# Simple conditionals are perfectly fine, and more readable for multiline
# expressions.
Style/GuardClause:
Enabled: false
# Case equality is not intrinsically problematic.
Style/CaseEquality:
Enabled: false
# New cops since Rubocop 1.0.
# We have to explicitly opt-in for new cops to apply
# before the next major release.
Gemspec/DeprecatedAttributeAssignment: # (Gemspec/DateAssignment integrated in 1.31.0)
Enabled: true
Layout/SpaceBeforeBrackets: # (new in 1.7)
Enabled: true
Lint/AmbiguousAssignment: # (new in 1.7)
Enabled: true
Lint/DeprecatedConstants: # (new in 1.8)
Enabled: true
Lint/DuplicateBranch: # (new in 1.3)
Enabled: true
Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
Enabled: true
Lint/EmptyClass: # (new in 1.3)
Enabled: true
Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
Enabled: true
# Prevents `return` in an assignment block `var = begin; return; end` block.
Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
Enabled: false
Lint/NumberedParameterAssignment: # (new in 1.9)
Enabled: true
Lint/OrAssignmentToConstant: # (new in 1.9)
Enabled: true
Lint/RedundantDirGlobSort: # (new in 1.8)
Enabled: true
Lint/SymbolConversion: # (new in 1.9)
Enabled: true
Lint/ToEnumArguments: # (new in 1.1)
Enabled: true
Lint/TripleQuotes: # (new in 1.9)
Enabled: true
Lint/UnexpectedBlockArity: # (new in 1.5)
Enabled: true
Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
Enabled: true
Style/ArgumentsForwarding: # (new in 1.1)
Enabled: true
Style/DocumentDynamicEvalDefinition: # (new in 1.1)
Enabled: true
Style/EndlessMethod: # (new in 1.8)
Enabled: true
Style/HashExcept: # (new in 1.7)
Enabled: true
Style/IfWithBooleanLiteralBranches: # (new in 1.9)
Enabled: true
Style/NilLambda: # (new in 1.3)
Enabled: true
Style/RedundantArgument: # (new in 1.4)
Enabled: true
Style/SwapValues: # (new in 1.1)
Enabled: true
Performance/AncestorsInclude: # (new in 1.7)
Enabled: true
Performance/BigDecimalWithNumericArgument: # (new in 1.7)
Enabled: true
Performance/BlockGivenWithExplicitBlock: # (new in 1.9)
Enabled: true
Performance/CollectionLiteralInLoop: # (new in 1.8)
Enabled: true
Performance/ConstantRegexp: # (new in 1.9)
Enabled: true
Performance/MethodObjectAsBlock: # (new in 1.9)
Enabled: true
Performance/RedundantSortBlock: # (new in 1.7)
Enabled: true
Performance/RedundantStringChars: # (new in 1.7)
Enabled: true
Performance/ReverseFirst: # (new in 1.7)
Enabled: true
Performance/SortReverse: # (new in 1.7)
Enabled: true
Performance/Squeeze: # (new in 1.7)
Enabled: true
Performance/StringInclude: # (new in 1.7)
Enabled: true
# Requires Ruby 2.2
Style/HashSyntax:
Enabled: false
# Requires Ruby 2.3
Layout/HeredocIndentation:
Enabled: false
# Requires Ruby 2.3
Style/SafeNavigation:
Enabled: false
# Requires Ruby 2.3
Performance/UnfreezeString:
Enabled: false
# Requires Ruby 2.4
Style/HashTransformValues:
Enabled: false
# Requires Ruby 2.4
Style/CollectionCompact:
Enabled: false
# Requires Ruby 2.4
Performance/RegexpMatch:
Enabled: false
# Requires Ruby 2.4
Performance/Sum:
Enabled: false
# Requires Ruby 2.5
Style/RedundantBegin:
Enabled: false
# Requires Ruby 2.5
Style/HashTransformKeys:
Enabled: false
# Requires Ruby 2.6
Style/SlicingWithRange:
Enabled: false
# Enforces negative/positive branching order,
# which can hurt readability.
Style/NegatedIfElseCondition:
Enabled: false
# Converts `to change{foo.bar}` to `to change(foo, :bar)`.
# It doesn't seem to make it more readable, and doesn't work
# when `foo` has to be re-evaluated.
RSpec/ExpectChange:
Enabled: false
# Readability is not meaningfully affected by enforcing
# `not_to` vs `to_not`.
RSpec/NotToNot:
Enabled: false
# Enforces `subject` above all else, even `include_context`
# declarations.
RSpec/LeadingSubject:
Enabled: false
# Enforces usage of `expect(subject)` instead of `is_expected`.
RSpec/ImplicitSubject:
Enabled: false
# Enforces empty line after hook declaration.
RSpec/EmptyLineAfterHook:
Enabled: false
# Enforces empty line after subject declaration.
RSpec/EmptyLineAfterSubject:
Enabled: false
# Enforces empty line after last let declaration.
RSpec/EmptyLineAfterFinalLet:
Enabled: false
# TODO: Disabling until we categorize which file are safe to do so.
Style/FrozenStringLiteralComment:
Enabled: false
# Replaces `x == 0` with `x.zero?` and similar.
# These methods are ~2x slower than the simple math comparison.
Style/NumericPredicate:
Enabled: false
# Allow for empty blocks (without a comment) in tests.
Lint/EmptyBlock:
Exclude:
- 'test/**/*.rb'
- 'spec/**/*.rb'
# Enforces that context description must start with 'when', 'with', or 'without'.
RSpec/ContextWording:
Enabled: false
# Checks for multiple top-level example groups.
# Multiple descriptions for the same class or module should either
# be nested or separated into different test files.
RSpec/MultipleDescribes:
Enabled: false
# Enforces that examples should only have a limited amount of assertions.
RSpec/MultipleExpectations:
Enabled: false
# Enforces minimum character length for parameters.
Naming/MethodParameterName:
Enabled: false
# Enforces no instance variable in specs.
RSpec/InstanceVariable:
Enabled: false
# Enforces a maximum nested example group level.
RSpec/NestedGroups:
Enabled: false
# Enforces `receive` vs `have_received` expectation pattern.
RSpec/MessageSpies:
Enabled: false
# Enforces use of `instance_double` over `double`
RSpec/VerifiedDoubles:
Enabled: false
# Enforces example line count limit.
RSpec/ExampleLength:
Enabled: false
# Enforces maximum let and subject calls.
RSpec/MultipleMemoizedHelpers:
Enabled: false
# Enforces `allow` over `expect` when configuring a response.
RSpec/StubbedMock:
Enabled: false
# Enforces no use of `expect` in `before` hooks.
RSpec/ExpectInHook:
Enabled: false
# Enforces no stubbing using `allow_any_instance_of`.
RSpec/AnyInstance:
Enabled: false
# Enforces strict matching of example class with spec file name.
# This does not work for our current namespacing as our gem is called
# `ddtrace` while our namespace is `::Datadog`.
# It would have to either be `ddtrace` + `::DDTrace` or
# `datadog` + `::Datadog`.
RSpec/FilePath:
Enabled: false
# Enforces no stubbing of methods of the object under test.
RSpec/SubjectStub:
Enabled: false
# Enforces that the first argument to describe should
# be the class or module being tested.
RSpec/DescribeClass:
Enabled: false
# Enforces to no use let! to setup objects not referenced in tests.
# Fails to account for shared examples across files.
RSpec/LetSetup:
Enabled: false
# Identifies where `fetch(key) { value }` can be replaced by `fetch(key, value)`.
# Can't differentiate between `Hash#fetch` and `RailsCache#fetch`,
# passing in wrong parameters to these methods.
Style/RedundantFetchBlock:
Enabled: false
# Warns about usage of `before(:all)`
RSpec/BeforeAfterAll:
Enabled: false
# Enforces snake case file names.
Naming/FileName:
Exclude:
- 'integration/**/Gemfile'
- 'integration/**/Rakefile'
# Enforces boolean parameters with default to be keyword arguments.
Style/OptionalBooleanParameter:
Enabled: false
Layout/ArgumentAlignment:
EnforcedStyle: with_fixed_indentation
Layout/BlockAlignment:
EnforcedStyleAlignWith: start_of_block
Layout/FirstArgumentIndentation:
EnforcedStyle: consistent
Layout/FirstMethodArgumentLineBreak:
Enabled: true
Layout/FirstMethodParameterLineBreak:
Enabled: true
Layout/MultilineMethodArgumentLineBreaks:
Enabled: true
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
Layout/MultilineOperationIndentation:
EnforcedStyle: indented
Lint/UnusedBlockArgument:
# Required keyword arguments normally cannot be omitted or renamed:
# Example: in `proc{|unused:|}`, `unused` cannot be renamed to `_unused`.
AllowUnusedKeywordArguments: true
Style/TrailingCommaInArguments:
Enabled: false
Style/TrailingCommaInArrayLiteral:
Enabled: false
Style/TrailingCommaInBlockArgs:
Enabled: false
Style/TrailingCommaInHashLiteral:
Enabled: false
Naming/VariableNumber:
Enabled: false
# Requires that the Rubocop linter should be configured to
# match the same version as `spec.required_rubygems_version` in our gemspec file.
# This is not currently possible, as we'd like to use updated versions of Rubocop
# that have already dropped support for our minimum supported Ruby version.
Gemspec/RequiredRubyVersion:
Enabled: false