finstyle 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,131 @@
1
+ #
2
+ ## Finstyle RuboCop configuration
3
+ #
4
+
5
+ #
6
+ ### Lint Cops
7
+ #
8
+
9
+ # Nothing but false positives in the Kitchen codebase--which has test coverage
10
+ Lint/AssignmentInCondition:
11
+ Enabled: false
12
+
13
+ # Align if/end with the variable, not align with the if keyword
14
+ Lint/EndAlignment:
15
+ AlignWith: variable
16
+
17
+ #
18
+ ### Style Cops
19
+ #
20
+
21
+ Style/AlignParameters:
22
+ EnforcedStyle: with_fixed_indentation
23
+
24
+ # I very much agree with the Jim Weirich school of thought on usage of do/end
25
+ # vs. {...}:
26
+ # * http://devblog.avdi.org/2011/07/26/the-procedurefunction-block-convention-in-ruby/
27
+ # * http://talklikeaduck.denhaven2.com/2007/10/02/ruby-blocks-do-or-brace
28
+ # * http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc
29
+ Style/Blocks:
30
+ Enabled: false
31
+
32
+ # ABC complexity is a far better code smell signal than raw class length.
33
+ Style/ClassLength:
34
+ Max: 300
35
+
36
+ # Words help us convey meaning and Ruby aliased methods help with this.
37
+ Style/CollectionMethods:
38
+ PreferredMethods:
39
+ inject:
40
+
41
+ # Other tooling can detect and handle this, too many false positives.
42
+ Style/Documentation:
43
+ Enabled: false
44
+
45
+ # This isn't javascript, gotta be super careful with the Ruby parser.
46
+ Style/DotPosition:
47
+ EnforcedStyle: trailing
48
+
49
+ Style/EachWithObject:
50
+ Enabled: false
51
+
52
+ # Whitespace between modules/classes/methods can be helpful to read and
53
+ # don't hurt anybody.
54
+ Style/EmptyLinesAroundBody:
55
+ Enabled: false
56
+
57
+ Style/HashSyntax:
58
+ EnforcedStyle: hash_rockets
59
+
60
+ Style/EmptyLiteral:
61
+ Enabled: false
62
+
63
+ # Claimed violations of this by Rubocop are, in general, complete nonsense and
64
+ # worse can dramtically reduce the safe readability of code (it would lead you
65
+ # to add a lot more `return if ...` blocks in the *middle* of method bodies)
66
+ Style/GuardClause:
67
+ Enabled: false
68
+
69
+ # Appending a statement modifier can drastically reduce readbility and push
70
+ # the line length to extremes.
71
+ Style/IfUnlessModifier:
72
+ Enabled: false
73
+
74
+ Style/LineLength:
75
+ Max: 100
76
+
77
+ # ABC complexity is a far better code smell signal than raw method length.
78
+ Style/MethodLength:
79
+ Max: 20
80
+
81
+ # True functional-style chaining is fine by me
82
+ Style/MultilineBlockChain:
83
+ Enabled: false
84
+
85
+ # Using unless in many circumstances can place an overly large cognitive load
86
+ # on someone reading the code. Unless can be great in postfix/modifier position
87
+ # but no so much at the head of a conditional block.
88
+ Style/NegatedIf:
89
+ Enabled: false
90
+
91
+ # When this is useful, it's useful, every other time it's entirely surprising
92
+ # to new Rubyists
93
+ Style/NumericLiterals:
94
+ Enabled: false
95
+
96
+ Style/PercentLiteralDelimiters:
97
+ PreferredDelimiters:
98
+ '%': '{}'
99
+ '%q': '{}'
100
+ '%Q': '{}'
101
+ '%w': '[]'
102
+ '%W': '[]'
103
+ '%x': '{}'
104
+
105
+ Style/RegexpLiteral:
106
+ Enabled: false
107
+
108
+ Style/Semicolon:
109
+ Enabled: false
110
+
111
+ # I just... what?
112
+ Style/SignalException:
113
+ Enabled: false
114
+
115
+ # Let's not argue over this...
116
+ Style/StringLiterals:
117
+ EnforcedStyle: double_quotes
118
+
119
+ # Nothing but a single-quoting strings rule in disguise
120
+ Style/UnneededCapitalW:
121
+ Enabled: false
122
+
123
+ # I prefer this to be a much more explicit form of communication than simple
124
+ # backticks
125
+ Style/UnneededPercentX:
126
+ Enabled: false
127
+
128
+ # Always enforcing a postfix/modifier is silly if the code block spans
129
+ # multiple lines
130
+ Style/WhileUntilModifier:
131
+ Enabled: false
@@ -0,0 +1,522 @@
1
+ # This is the default configuration file. Enabling and disabling is configured
2
+ # in separate files. This file adds all other parameters apart from Enabled.
3
+
4
+ inherit_from:
5
+ - enabled.yml
6
+ - disabled.yml
7
+
8
+ # Common configuration.
9
+ AllCops:
10
+ # Include gemspec and Rakefile
11
+ Include:
12
+ - '**/*.gemspec'
13
+ - '**/Rakefile'
14
+ Exclude:
15
+ - 'vendor/**/*'
16
+ # By default, the rails cops are not run. Override in project or home
17
+ # directory .rubocop.yml files, or by giving the -R/--rails option.
18
+ RunRailsCops: false
19
+
20
+ # Indent private/protected/public as deep as method definitions
21
+ Style/AccessModifierIndentation:
22
+ EnforcedStyle: indent
23
+ SupportedStyles:
24
+ - outdent
25
+ - indent
26
+
27
+ # Align the elements of a hash literal if they span more than one line.
28
+ Style/AlignHash:
29
+ # Alignment of entries using hash rocket as separator. Valid values are:
30
+ #
31
+ # key - left alignment of keys
32
+ # 'a' => 2
33
+ # 'bb' => 3
34
+ # separator - alignment of hash rockets, keys are right aligned
35
+ # 'a' => 2
36
+ # 'bb' => 3
37
+ # table - left alignment of keys, hash rockets, and values
38
+ # 'a' => 2
39
+ # 'bb' => 3
40
+ EnforcedHashRocketStyle: key
41
+ # Alignment of entries using colon as separator. Valid values are:
42
+ #
43
+ # key - left alignment of keys
44
+ # a: 0
45
+ # bb: 1
46
+ # separator - alignment of colons, keys are right aligned
47
+ # a: 0
48
+ # bb: 1
49
+ # table - left alignment of keys and values
50
+ # a: 0
51
+ # bb: 1
52
+ EnforcedColonStyle: key
53
+ # Select whether hashes that are the last argument in a method call should be
54
+ # inspected? Valid values are:
55
+ #
56
+ # always_inspect - Inspect both implicit and explicit hashes.
57
+ # Registers an offense for:
58
+ # function(a: 1,
59
+ # b: 2)
60
+ # Registers an offense for:
61
+ # function({a: 1,
62
+ # b: 2})
63
+ # always_ignore - Ignore both implicit and explicit hashes.
64
+ # Accepts:
65
+ # function(a: 1,
66
+ # b: 2)
67
+ # Accepts:
68
+ # function({a: 1,
69
+ # b: 2})
70
+ # ignore_implicit - Ignore only implicit hashes.
71
+ # Accepts:
72
+ # function(a: 1,
73
+ # b: 2)
74
+ # Registers an offense for:
75
+ # function({a: 1,
76
+ # b: 2})
77
+ # ignore_explicit - Ignore only explicit hashes.
78
+ # Accepts:
79
+ # function({a: 1,
80
+ # b: 2})
81
+ # Registers an offense for:
82
+ # function(a: 1,
83
+ # b: 2)
84
+ EnforcedLastArgumentHashStyle: always_inspect
85
+ SupportedLastArgumentHashStyles:
86
+ - always_inspect
87
+ - always_ignore
88
+ - ignore_implicit
89
+ - ignore_explicit
90
+
91
+ Style/AlignParameters:
92
+ # Alignment of parameters in multi-line method calls.
93
+ #
94
+ # The `with_first_parameter` style aligns the following lines along the same column
95
+ # as the first parameter.
96
+ #
97
+ # method_call(a,
98
+ # b)
99
+ #
100
+ # The `with_fixed_indentation` style aligns the following lines with one
101
+ # level of indentation relative to the start of the line with the method call.
102
+ #
103
+ # method_call(a,
104
+ # b)
105
+ EnforcedStyle: with_first_parameter
106
+ SupportedStyles:
107
+ - with_first_parameter
108
+ - with_fixed_indentation
109
+
110
+ Style/BlockNesting:
111
+ Max: 3
112
+
113
+ Style/BracesAroundHashParameters:
114
+ EnforcedStyle: no_braces
115
+ SupportedStyles:
116
+ - braces
117
+ - no_braces
118
+
119
+ # Indentation of `when`.
120
+ Style/CaseIndentation:
121
+ IndentWhenRelativeTo: case
122
+ SupportedStyles:
123
+ - case
124
+ - end
125
+ IndentOneStep: false
126
+
127
+ Style/ClassAndModuleChildren:
128
+ # Checks the style of children definitions at classes and modules.
129
+ #
130
+ # Basically there are two different styles:
131
+ #
132
+ # `nested` - have each child on a separate line
133
+ # class Foo
134
+ # class Bar
135
+ # end
136
+ # end
137
+ #
138
+ # `compact` - combine definitions as much as possible
139
+ # class Foo::Bar
140
+ # end
141
+ #
142
+ # The compact style is only forced, for classes / modules with one child.
143
+ EnforcedStyle: nested
144
+ SupportedStyles:
145
+ - nested
146
+ - compact
147
+
148
+ Style/ClassCheck:
149
+ EnforcedStyle: is_a?
150
+ SupportedStyles:
151
+ - is_a?
152
+ - kind_of?
153
+
154
+ Style/ClassLength:
155
+ CountComments: false # count full line comments?
156
+ Max: 100
157
+
158
+ # Align with the style guide.
159
+ Style/CollectionMethods:
160
+ # Mapping from undesired method to desired_method
161
+ # e.g. to use `detect` over `find`:
162
+ #
163
+ # CollectionMethods:
164
+ # PreferredMethods:
165
+ # find: detect
166
+ PreferredMethods:
167
+ collect: 'map'
168
+ collect!: 'map!'
169
+ inject: 'reduce'
170
+ detect: 'find'
171
+ find_all: 'select'
172
+
173
+ # Checks formatting of special comments
174
+ Style/CommentAnnotation:
175
+ Keywords:
176
+ - TODO
177
+ - FIXME
178
+ - OPTIMIZE
179
+ - HACK
180
+ - REVIEW
181
+
182
+ # Avoid complex methods.
183
+ Style/CyclomaticComplexity:
184
+ Max: 6
185
+
186
+ # Multi-line method chaining should be done with leading dots.
187
+ Style/DotPosition:
188
+ EnforcedStyle: leading
189
+ SupportedStyles:
190
+ - leading
191
+ - trailing
192
+
193
+ # Use empty lines between defs.
194
+ Style/EmptyLineBetweenDefs:
195
+ # If true, this parameter means that single line method definitions don't
196
+ # need an empty line between them.
197
+ AllowAdjacentOneLineDefs: false
198
+
199
+ # Checks whether the source file has a utf-8 encoding comment or not
200
+ Style/Encoding:
201
+ EnforcedStyle: always
202
+ SupportedStyles:
203
+ - when_needed
204
+ - always
205
+
206
+ Style/FileName:
207
+ Exclude:
208
+ - '**/Rakefile'
209
+ - '**/Gemfile'
210
+ - '**/Capfile'
211
+
212
+ # Checks use of for or each in multiline loops.
213
+ Style/For:
214
+ EnforcedStyle: each
215
+ SupportedStyles:
216
+ - for
217
+ - each
218
+
219
+ # Enforce the method used for string formatting.
220
+ Style/FormatString:
221
+ EnforcedStyle: format
222
+ SupportedStyles:
223
+ - format
224
+ - sprintf
225
+ - percent
226
+
227
+ # Built-in global variables are allowed by default.
228
+ Style/GlobalVars:
229
+ AllowedVariables: []
230
+
231
+ # `MinBodyLength` defines the number of lines of the a body of an if / unless
232
+ # needs to have to trigger this cop
233
+ Style/GuardClause:
234
+ MinBodyLength: 1
235
+
236
+ Style/HashSyntax:
237
+ EnforcedStyle: ruby19
238
+ SupportedStyles:
239
+ - ruby19
240
+ - hash_rockets
241
+
242
+ Style/IfUnlessModifier:
243
+ MaxLineLength: 80
244
+
245
+ # Checks the indentation of the first key in a hash literal.
246
+ Style/IndentHash:
247
+ # The value `special_inside_parentheses` means that hash literals with braces
248
+ # that have their opening brace on the same line as a surrounding opening
249
+ # round parenthesis, shall have their first key indented relative to the
250
+ # first position inside the parenthesis.
251
+ # The value `consistent` means that the indentation of the first key shall
252
+ # always be relative to the first position of the line where the opening
253
+ # brace is.
254
+ EnforcedStyle: special_inside_parentheses
255
+ SupportedStyles:
256
+ - special_inside_parentheses
257
+ - consistent
258
+
259
+ Style/LambdaCall:
260
+ EnforcedStyle: call
261
+ SupportedStyles:
262
+ - call
263
+ - braces
264
+
265
+ Style/LineLength:
266
+ Max: 80
267
+ AllowURI: true
268
+
269
+ Style/Next:
270
+ # With `always` all conditions at the end of an iteration needs to be
271
+ # replace by next - with `skip_modifier_ifs` the modifier if like this one
272
+ # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
273
+ EnforcedStyle: skip_modifier_ifs
274
+ SupportedStyles:
275
+ - skip_modifier_ifs
276
+ - always
277
+
278
+ Style/NonNilCheck:
279
+ # With `IncludeSemanticChanges` set to `true`, this cop reports offenses for
280
+ # `!x.nil?` and autocorrects that and `x != nil` to solely `x`, which is
281
+ # **usually** OK, but might change behavior.
282
+ #
283
+ # With `IncludeSemanticChanges` set to `false`, this cop does not report
284
+ # offenses for `!x.nil?` and does no changes that might change behavior.
285
+ IncludeSemanticChanges: false
286
+
287
+ Style/MethodDefParentheses:
288
+ EnforcedStyle: require_parentheses
289
+ SupportedStyles:
290
+ - require_parentheses
291
+ - require_no_parentheses
292
+
293
+ Style/MethodLength:
294
+ CountComments: false # count full line comments?
295
+ Max: 10
296
+
297
+ Style/MethodName:
298
+ EnforcedStyle: snake_case
299
+ SupportedStyles:
300
+ - snake_case
301
+ - camelCase
302
+
303
+ Style/NumericLiterals:
304
+ MinDigits: 5
305
+
306
+ Style/ParameterLists:
307
+ Max: 5
308
+ CountKeywordArgs: true
309
+
310
+ # Allow safe assignment in conditions.
311
+ Style/ParenthesesAroundCondition:
312
+ AllowSafeAssignment: true
313
+
314
+ Style/PercentLiteralDelimiters:
315
+ PreferredDelimiters:
316
+ '%': ()
317
+ '%i': ()
318
+ '%q': ()
319
+ '%Q': ()
320
+ '%r': '{}'
321
+ '%s': ()
322
+ '%w': ()
323
+ '%W': ()
324
+ '%x': ()
325
+
326
+ Style/PredicateName:
327
+ NamePrefixBlacklist:
328
+ - is_
329
+ - has_
330
+ - have_
331
+
332
+ Style/RaiseArgs:
333
+ EnforcedStyle: exploded
334
+ SupportedStyles:
335
+ - compact # raise Exception.new(msg)
336
+ - exploded # raise Exception, msg
337
+
338
+
339
+ Style/RedundantReturn:
340
+ # When true allows code like `return x, y`.
341
+ AllowMultipleReturnValues: false
342
+
343
+ Style/RegexpLiteral:
344
+ # The maximum number of (escaped) slashes that a slash-delimited regexp is
345
+ # allowed to have. If there are more slashes, a %r regexp shall be used.
346
+ MaxSlashes: 1
347
+
348
+ Style/Semicolon:
349
+ # Allow ; to separate several expressions on the same line.
350
+ AllowAsExpressionSeparator: false
351
+
352
+ Style/SignalException:
353
+ EnforcedStyle: semantic
354
+ SupportedStyles:
355
+ - only_raise
356
+ - only_fail
357
+ - semantic
358
+
359
+
360
+ Style/SingleLineBlockParams:
361
+ Methods:
362
+ - reduce:
363
+ - a
364
+ - e
365
+ - inject:
366
+ - a
367
+ - e
368
+
369
+ Style/SingleLineMethods:
370
+ AllowIfMethodIsEmpty: true
371
+
372
+ Style/StringLiterals:
373
+ EnforcedStyle: single_quotes
374
+ SupportedStyles:
375
+ - single_quotes
376
+ - double_quotes
377
+
378
+ Style/SpaceAroundEqualsInParameterDefault:
379
+ EnforcedStyle: space
380
+ SupportedStyles:
381
+ - space
382
+ - no_space
383
+
384
+ Style/SpaceBeforeBlockBraces:
385
+ EnforcedStyle: space
386
+ SupportedStyles:
387
+ - space
388
+ - no_space
389
+
390
+ Style/SpaceInsideBlockBraces:
391
+ EnforcedStyle: space
392
+ SupportedStyles:
393
+ - space
394
+ - no_space
395
+ # Valid values are: space, no_space
396
+ EnforcedStyleForEmptyBraces: no_space
397
+ # Space between { and |. Overrides EnforcedStyle if there is a conflict.
398
+ SpaceBeforeBlockParameters: true
399
+
400
+ Style/SpaceInsideHashLiteralBraces:
401
+ EnforcedStyle: space
402
+ EnforcedStyleForEmptyBraces: no_space
403
+ SupportedStyles:
404
+ - space
405
+ - no_space
406
+
407
+ Style/TrailingBlankLines:
408
+ EnforcedStyle: final_newline
409
+ SupportedStyles:
410
+ - final_newline
411
+ - final_blank_line
412
+
413
+ Style/TrailingComma:
414
+ # If EnforcedStyleForMultiline is comma, the cop allows a comma after the
415
+ # last item of a list, but only for lists where each item is on its own line.
416
+ EnforcedStyleForMultiline: no_comma
417
+ SupportedStyles:
418
+ - comma
419
+ - no_comma
420
+
421
+ # TrivialAccessors doesn't require exact name matches and doesn't allow
422
+ # predicated methods by default.
423
+ Style/TrivialAccessors:
424
+ ExactNameMatch: false
425
+ AllowPredicates: false
426
+ # Allows trivial writers that don't end in an equal sign. e.g.
427
+ #
428
+ # def on_exception(action)
429
+ # @on_exception=action
430
+ # end
431
+ # on_exception :restart
432
+ #
433
+ # Commonly used in DSLs
434
+ AllowDSLWriters: false
435
+ Whitelist:
436
+ - to_ary
437
+ - to_a
438
+ - to_c
439
+ - to_enum
440
+ - to_h
441
+ - to_hash
442
+ - to_i
443
+ - to_int
444
+ - to_io
445
+ - to_open
446
+ - to_path
447
+ - to_proc
448
+ - to_r
449
+ - to_regexp
450
+ - to_str
451
+ - to_s
452
+ - to_sym
453
+
454
+ Style/VariableName:
455
+ EnforcedStyle: snake_case
456
+ SupportedStyles:
457
+ - snake_case
458
+ - camelCase
459
+
460
+ Style/WhileUntilModifier:
461
+ MaxLineLength: 80
462
+
463
+ Style/WordArray:
464
+ MinSize: 0
465
+
466
+ ##################### Lint ##################################
467
+
468
+ # Allow safe assignment in conditions.
469
+ Lint/AssignmentInCondition:
470
+ AllowSafeAssignment: true
471
+
472
+ # Align ends correctly.
473
+ Lint/EndAlignment:
474
+ # The value `keyword` means that `end` should be aligned with the matching
475
+ # keyword (if, while, etc.).
476
+ # The value `variable` means that in assignments, `end` should be aligned
477
+ # with the start of the variable on the left hand side of `=`. In all other
478
+ # situations, `end` should still be aligned with the keyword.
479
+ AlignWith: keyword
480
+ SupportedStyles:
481
+ - keyword
482
+ - variable
483
+
484
+ Lint/DefEndAlignment:
485
+ # The value `def` means that `end` should be aligned with the def keyword.
486
+ # The value `start_of_line` means that `end` should be aligned with method
487
+ # calls like `private`, `public`, etc, if present in front of the `def`
488
+ # keyword on the same line.
489
+ AlignWith: start_of_line
490
+ SupportedStyles:
491
+ - start_of_line
492
+ - def
493
+
494
+ ##################### Rails ##################################
495
+
496
+ Rails/ActionFilter:
497
+ EnforcedStyle: action
498
+ SupportedStyles:
499
+ - action
500
+ - filter
501
+ Include:
502
+ - app/controllers/**/*.rb
503
+
504
+ Rails/DefaultScope:
505
+ Include:
506
+ - app/models/**/*.rb
507
+
508
+ Rails/HasAndBelongsToMany:
509
+ Include:
510
+ - app/models/**/*.rb
511
+
512
+ Rails/ReadWriteAttribute:
513
+ Include:
514
+ - app/models/**/*.rb
515
+
516
+ Rails/ScopeArgs:
517
+ Include:
518
+ - app/models/**/*.rb
519
+
520
+ Rails/Validation:
521
+ Include:
522
+ - app/models/**/*.rb