-
Notifications
You must be signed in to change notification settings - Fork 22
/
.rubocop.yml
339 lines (274 loc) · 6.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
inherit_from: .rubocop_todo.yml
require: rubocop-rspec
AllCops:
TargetRubyVersion: 2.5
Exclude:
- lib/deimos/monkey_patches/*.rb
- vendor/**/*
- Guardfile
NewCops: enable
# class Plumbus
# private
# def smooth; end
# end
Layout/AccessModifierIndentation:
EnforcedStyle: outdent
# foo.bar.
# each do
# baz
# end
Layout/BlockAlignment:
EnforcedStyleAlignWith: start_of_block
# something.
# method
#
# instead of
#
# something
# .method
Layout/DotPosition:
EnforcedStyle: trailing
# sometimes empty lines can be used for clarity
Layout/EmptyLinesAroundBlockBody:
Enabled: false
Layout/LineLength:
Max: 120
Severity: refactor
# TODO: uncomment the files below once rubocop is fixed
# Exclude:
# - 'spec/**/*'
# foo = if expression
# 'bar'
# end
Layout/MultilineAssignmentLayout:
Enabled: true
EnforcedStyle: same_line
# while myvariable.
# a.
# b
#
# # do something
# end
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
# def some_method(arg1=true, arg2=42)
Layout/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: no_space
# do not allow e.g.
# if (v = array.grep(/foo/))
# do_something(v)
# end
Lint/AssignmentInCondition:
AllowSafeAssignment: false
Severity: convention
Lint/UnusedBlockArgument:
AllowUnusedKeywordArguments: true
Lint/UnusedMethodArgument:
AllowUnusedKeywordArguments: true
Metrics/AbcSize:
Severity: refactor
Max: 35
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
Severity: refactor
Max: 500
Metrics/CyclomaticComplexity:
Severity: refactor
Max: 20
Metrics/MethodLength:
Severity: refactor
Max: 50
Metrics/ModuleLength:
Severity: refactor
Max: 200
Metrics/ParameterLists:
Max: 5
CountKeywordArgs: false
Metrics/PerceivedComplexity:
Severity: refactor
Max: 10
# Use alias_method instead of alias
Style/Alias:
EnforcedStyle: prefer_alias_method
# Allow "and" or "or" to be used as a statement but not a conditional operator
Style/AndOr:
EnforcedStyle: conditionals
# Force use of File.open {...} instead of File.open but as a refactor
Style/AutoResourceCleanup:
Enabled: true
Severity: refactor
# Do not allow multiline {} blocks unless it is chained with a .
Style/BlockDelimiters:
EnforcedStyle: braces_for_chaining
# bad
# some_method(x, y, {a: 1, b: 2})
# some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)
# Enable both this:
# MyModule::MyClass
# and this:
# module MyModule
# class MyClass
Style/ClassAndModuleChildren:
Enabled: false
# Don't force "reduce" over "inject"
Style/CollectionMethods:
Enabled: true
AutoCorrect: false
PreferredMethods:
collect: map
collect!: map!
detect: find
find_all: select
Style/DateTime:
AllowCoercion: true
# TODO: uncomment the lines below once rubocop is fixed
#Style/Documentation:
# Exclude:
# - 'app/controllers/**/*'
# - 'app/helpers/**/*'
# - 'db/**/*'
# Force documentation for public methods and classes
Style/DocumentationMethod:
Enabled: true
# TODO: uncomment the file below once rubocop is fixed
# Exclude:
# - 'app/controllers/**/*'
# - 'db/**/*'
# Allow else with just nil in it
Style/EmptyElse:
EnforcedStyle: empty
# Do not allow one-line methods
Style/EmptyMethod:
EnforcedStyle: expanded
# One-line bodies are fine without a guard clause
Style/GuardClause:
MinBodyLength: 2
# Require hash syntax { key: value } in all cases
Style/HashSyntax:
EnforcedStyle: ruby19_no_mixed_keys
# We are still unofficially targeting Ruby 2.3
Style/HashTransformKeys:
Enabled: false
Style/HashTransformValues:
Enabled: false
Style/IfUnlessModifier:
Enabled: false
# Allow the following:
# var x = "foo" +
# "bar"
Style/LineEndConcatenation:
Enabled: false
# Require parentheses around all method arguments except for whitelist
Style/MethodCallWithArgsParentheses:
Enabled: true
IgnoredMethods:
- puts
- render
- redirect_to
- send_data
- require
- include
- require_relative
- specify
- example
- describe
- it
- to
- not_to
- to_not
- define
- expect_with
- mock_with
- factory
- travel_to
- travel
- get
- raise
- attr_accessor
- class_attribute
- before_save
- after_save
- before_create
- after_create
- before_update
- after_update
- before_destroy
- after_destroy
- queue_as
# TODO: uncomment the file below once rubocop is fixed
# Exclude:
# - 'bin/**/*'
# - 'Gemfile'
# Do not allow "end.something"
Style/MethodCalledOnDoEndBlock:
Enabled: true
Style/OptionHash:
Enabled: false
# Use %i() and %w() instead of []
Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%i': '()'
'%I': '()'
'%w': '()'
'%W': '()'
# Allow self.x in all cases - it helps make it obvious when dealing with
# instance variables
Style/RedundantSelf:
Enabled: false
# Do not allow single line methods
Style/SingleLineMethods:
AllowIfMethodIsEmpty: false
# NOTE change this for Ruby < 2.0
# require %i()
Style/SymbolArray:
EnforcedStyle: percent
RSpec/AlignLeftLetBrace:
Enabled: false
RSpec/AlignRightLetBrace:
Enabled: false
# Allow allow_any_instance_of().to receive
RSpec/AnyInstance:
Enabled: false
# Allow describe MyClass, 'some descriptor that isn't a method'
RSpec/DescribeMethod:
Enabled: false
RSpec/ExampleLength:
Severity: refactor
Max: 40
# Allow it 'should do something'
RSpec/ExampleWording:
Enabled: false
# Allow describing specs without only using classes and methods
RSpec/FilePath:
Enabled: false
# Use before(:each), not before or before(:example)
RSpec/HookArgument:
EnforcedStyle: each
RSpec/ItBehavesLike:
EnforcedStyle: it_should_behave_like
RSpec/LeakyConstantDeclaration:
Enabled: false
RSpec/MessageChain:
Severity: refactor
# Allow both "allow" and "expect"
RSpec/MessageExpectation:
Enabled: false
# Use to receive, not to have_received
RSpec/MessageSpies:
Enabled: false
RSpec/MultipleExpectations:
Max: 10
Severity: refactor
# Allow both and_return() and block returns (use these for multi-line)
RSpec/ReturnFromStub:
Enabled: false
RSpec/SubjectStub:
Severity: refactor
RSpec/ExpectActual:
Enabled: false
RSpec/BeforeAfterAll:
Enabled: false
Security/YAMLLoad:
Exclude:
- 'lib/deimos.rb'