-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshared_rubocop.yml
304 lines (260 loc) · 7.62 KB
/
shared_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
# Configuration for the Rubocop code linting tool. See README.
AllCops:
DisabledByDefault: true
DisplayStyleGuide: true
SuggestExtensions: false
Exclude:
- db/schema.rb
- vendor/**/*
- node_modules/**/*
- tmp/**/*
- deploy/tmp/**/*
# Will only enable new cops for the subset of cops that are enabled. https://docs.rubocop.org/rubocop/versioning.html#pending-cops
NewCops: enable
# Enable all Security cops
Security:
Enabled: true
# Allow:
#
# foo
# .bar
#
# Disallow:
#
# foo.
# bar
#
Layout/DotPosition:
EnforcedStyle: leading
# Allow: def foo(...) = bar(...)
# Disallow: def foo(*args, &block) = bar(*args, &block)
Style/ArgumentsForwarding:
Enabled: true
# Allow e.g. `map` and disallow e.g. `collect`.
Style/CollectionMethods:
PreferredMethods:
collect: map
detect: find
filter: select
find_all: select
inject: reduce
# The default {} is not in our styleguide, but we need a default to use this cop: https://github.com/rubocop/rubocop/issues/12029
# And we've mostly used {} consistently anyway, so we might as well enforce it.
Style/PercentLiteralDelimiters:
PreferredDelimiters:
'default': '{}'
'%w': '[]'
'%W': '[]'
'%i': '[]'
'%I': '[]'
StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#use-square-brackets-for-w-and-friends
# Allow e.g. `numbers.map(&:to_s)` and disallow e.g. `numbers.map { _1.to_s }`.
Style/SymbolProc:
Enabled: true
# Allow: "foo"
# Disallow: 'foo'
Style/StringLiterals:
EnforcedStyle: double_quotes
StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#double-quote-strings-unless-the-string-contains-double-quotes
#https://docs.rubocop.org/rubocop/cops_style.html#stylequotedsymbols
Style/QuotedSymbols:
EnforcedStyle: same_as_string_literals
# Require a comma after the last item in a multi-line hash or array.
#
# The "consistent_comma" setting allows
#
# [
# 1, 2,
# 3,
# ]
#
# Whereas the "comma" setting seems to not want the comma after 3 if 1 and 2 were on the same line.
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma
StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#add-commas-to-the-end-of-multiline-lists-and-hashes
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: consistent_comma
StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#add-commas-to-the-end-of-multiline-lists-and-hashes
# Allow:
#
# list.map { |x| x }
#
# Disallow:
#
# list.map{ |x| x }
#
# Not in our styleguide, but it's what we've done for the most part.
Layout/SpaceBeforeBlockBraces:
Enabled: true
# Allow:
#
# list.map {|x| x }
#
# Disallow:
#
# list.map {|x| x }
#
# Not in our styleguide, but it's what we've done for the most part.
Layout/SpaceInsideBlockBraces:
Enabled: true
# Allow:
#
# { a: 1 }
#
# Disallow:
#
# {a: 1}
#
Layout/SpaceInsideHashLiteralBraces:
Enabled: true
StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#whitespace-in-arrays-and-hashes
# Allow:
#
# [ 1 ]
#
# Disallow:
#
# [1]
#
Layout/SpaceInsideArrayLiteralBrackets:
EnforcedStyle: space
StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#whitespace-in-arrays-and-hashes
# Allow:
#
# "foo" + 1 * 2 / 3**4
#
# Disallow:
#
# "foo"+1*2/3 ** 4
#
# Not in our styleguide, but it's what we've done for the most part.
Layout/SpaceAroundOperators:
Enabled: true
# bad: f( 3)
# good: f(3)
Layout/SpaceInsideParens:
Enabled: true
# bad: "foo #{ var } bar"
# good: "foo #{var} bar"
Layout/SpaceInsideStringInterpolation:
Enabled: true
# Disallow trailing whitespace.
Layout/TrailingWhitespace:
Enabled: true
StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#avoid-trailing-whitespace
# `BigDecimal.new` is deprecated on Ruby 2.5 in favour of `BigDecimal()`.
Lint/BigDecimalNew:
Enabled: true
Lint/DuplicateMethods:
Enabled: true
Lint/DeprecatedClassMethods:
Enabled: true
Layout/EmptyLineAfterGuardClause:
Enabled: true
StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#put-a-blank-line-below-guard-statements
Layout/ExtraSpacing:
Enabled: true
AllowForAlignment: true
AllowBeforeTrailingComments: true # Henrik likes this
ForceEqualSignAlignment: false
# Allow:
#
# Date.new(2019, 1, 2)
#
# Disallow:
#
# Date.new(2019,1,2)
#
# Not in our styleguide, but it's what we've done for the most part.
Layout/SpaceAfterComma:
Enabled: true
Style/ParallelAssignment: # https://rubystyle.guide/#parallel-assignment
Enabled: true
Style/NumericLiterals:
Enabled: false
Style/StabbyLambdaParentheses:
Enabled: true
EnforcedStyle: require_parentheses
StyleGuide: https://github.com/barsoom/devbook/tree/master/styleguide#lambdas-should-stab-their-arguments
# Not in our styleguide, but it's what we've done for the most part. And it ensures "rubocop --auto-correct" doesn't make the StabbyLambdaParentheses rule add in unconventional-to-us spaces.
Layout/SpaceInLambdaLiteral:
Enabled: true
EnforcedStyle: require_no_space
Lint/RaiseException:
Enabled: true
# Skip redundant "begin"/"end" at the top level of method definitions or blocks.
Style/RedundantBegin:
Enabled: true
# Allow:
#
# foo.bar
#
# Disallow:
#
# foo.bar()
#
Style/MethodCallWithoutArgsParentheses:
Enabled: true
# https://docs.rubocop.org/rubocop/cops_style.html#enforcedstyleformultiline-comma
Style/TrailingCommaInArguments:
Enabled: true
EnforcedStyleForMultiline: comma
# https://docs.rubocop.org/rubocop/cops_style.html#stylereturnnilinpredicatemethoddefinition
Style/ReturnNilInPredicateMethodDefinition:
Enabled: true
# Warn about "too many positional arguments in the parameter list" when more than 5.
# Warn about "too many positional arguments with optional values" when more than 3.
Metrics/ParameterLists:
Enabled: true
CountKeywordArgs: false
Max: 5
MaxOptionalParameters: 3
# https://docs.rubocop.org/rubocop/cops_lint.html#lintparenthesesasgroupedexpression
Lint/ParenthesesAsGroupedExpression:
Enabled: true
# https://docs.rubocop.org/rubocop/cops_lint.html#lintuselessassignment
Lint/UselessAssignment:
Enabled: true
# https://docs.rubocop.org/rubocop/cops_layout.html#layoutindentationwidth
Layout/IndentationWidth:
Enabled: true
# https://docs.rubocop.org/rubocop/cops_layout.html#layoutindentationconsistency
Layout/IndentationConsistency:
Enabled: true
# https://docs.rubocop.org/rubocop/cops_layout.html#layoutclassstructure
# https://github.com/barsoom/devbook/tree/master/styleguide#use-a-consistent-class-layout
# AutoCorrect: false because it has a tendency to make private delegates public, and it messes up whitespace
Layout/ClassStructure:
Enabled: true
AutoCorrect: false
ExpectedOrder:
- module_inclusion
- constants
- association
- public_attribute_macros
- public_delegate
- macros
- public_class_methods
- initializer
- public_methods
- protected_attribute_macros
- protected_methods
- private_attribute_macros
- private_delegate
- private_methods
# https://docs.rubocop.org/rubocop/cops_style.html#stylehashsyntax
Style/HashSyntax:
Enabled: true
EnforcedStyle: ruby19
# https://docs.rubocop.org/rubocop/cops_gemspec.html#gemspecduplicatedassignment
Gemspec/DuplicatedAssignment:
Enabled: true
# https://docs.rubocop.org/rubocop/cops_gemspec.html#gemspecordereddependencies
Gemspec/OrderedDependencies:
Enabled: true
# https://docs.rubocop.org/rubocop/cops_gemspec.html#gemspecrequiremfa
Gemspec/RequireMFA:
Enabled: true
# https://docs.rubocop.org/rubocop/cops_naming.html#namingblockforwarding
Naming/BlockForwarding:
Enabled: true