-
Notifications
You must be signed in to change notification settings - Fork 0
/
.rubocop.yml
200 lines (161 loc) · 6.32 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
inherit_mode:
merge:
- Exclude
AllCops:
TargetRubyVersion: 2.4
NewCops: disable
Exclude:
- bin/benchmark-driver
- bin/rake
- bin/rspec
- bin/rubocop
###########################################################################
# rubocop defaults are simply WRONG about many rules... Sorry. It's true.
###########################################################################
# Layout: Alignment. I want these to work, I really do...
# I wish this worked with "table". but that goes wrong sometimes.
Layout/HashAlignment: { Enabled: false }
# This needs to be configurable so parenthesis calls are aligned with first
# parameter, and non-parenthesis calls are aligned with fixed indentation.
Layout/ParameterAlignment: { Enabled: false }
###########################################################################
# Layout: Empty lines
Layout/EmptyLineAfterGuardClause: { Enabled: false }
Layout/EmptyLineAfterMagicComment: { Enabled: true }
Layout/EmptyLineAfterMultilineCondition: { Enabled: false }
Layout/EmptyLines: { Enabled: true }
Layout/EmptyLinesAroundAccessModifier: { Enabled: true }
Layout/EmptyLinesAroundArguments: { Enabled: true }
Layout/EmptyLinesAroundBeginBody: { Enabled: true }
Layout/EmptyLinesAroundBlockBody: { Enabled: false }
Layout/EmptyLinesAroundExceptionHandlingKeywords: { Enabled: true }
Layout/EmptyLinesAroundMethodBody: { Enabled: true }
Layout/EmptyLineBetweenDefs:
Enabled: true
AllowAdjacentOneLineDefs: true
Layout/EmptyLinesAroundAttributeAccessor:
inherit_mode:
merge:
- Exclude
- AllowedMethods
Enabled: true
AllowedMethods:
- delegate
- def_delegator
- def_delegators
- def_instance_delegators
# "empty_lines_special" sometimes does the wrong thing and annoys me.
# But I've mostly learned to live with it... mostly. 🙁
Layout/EmptyLinesAroundClassBody:
Enabled: true
EnforcedStyle: empty_lines_special
Layout/EmptyLinesAroundModuleBody:
Enabled: true
EnforcedStyle: empty_lines_special
###########################################################################
# Layout: Space around, before, inside, etc
Layout/SpaceAroundEqualsInParameterDefault: { Enabled: false }
Layout/SpaceBeforeBlockBraces: { Enabled: false }
Layout/SpaceBeforeFirstArg: { Enabled: false }
Layout/SpaceInLambdaLiteral: { Enabled: false }
Layout/SpaceInsideArrayLiteralBrackets: { Enabled: false }
Layout/SpaceInsideHashLiteralBraces: { Enabled: false }
Layout/SpaceInsideBlockBraces:
EnforcedStyle: space
EnforcedStyleForEmptyBraces: space
SpaceBeforeBlockParameters: false
# I would enable this if it were a bit better at handling alignment.
Layout/ExtraSpacing:
Enabled: false
AllowForAlignment: true
AllowBeforeTrailingComments: true
###########################################################################
# Layout: Misc
Layout/LineLength:
Max: 90 # should stay under 80, but we'll allow a little wiggle-room
Layout/MultilineOperationIndentation: { Enabled: false }
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
###########################################################################
# Lint and Naming: rubocop defaults are mostly good, but...
Lint/UnusedMethodArgument: { Enabled: false }
Naming/BinaryOperatorParameterName: { Enabled: false } # def /(denominator)
Naming/RescuedExceptionsVariableName: { Enabled: false }
###########################################################################
# Matrics:
Metrics/CyclomaticComplexity:
Max: 10
# Although it may be better to split specs into multiple files...?
Metrics/BlockLength:
Exclude:
- "spec/**/*_spec.rb"
CountAsOne:
- array
- hash
- heredoc
Metrics/ClassLength:
Max: 200
CountAsOne:
- array
- hash
- heredoc
###########################################################################
# Style...
Style/AccessorGrouping: { Enabled: false }
Style/AsciiComments: { Enabled: false } # 👮 can't stop our 🎉🥳🎊🥳!
Style/ClassAndModuleChildren: { Enabled: false }
Style/EachWithObject: { Enabled: false }
Style/FormatStringToken: { Enabled: false }
Style/FloatDivision: { Enabled: false }
Style/GuardClause: { Enabled: false } # usually nice to do, but...
Style/IfUnlessModifier: { Enabled: false }
Style/IfWithSemicolon: { Enabled: false }
Style/Lambda: { Enabled: false }
Style/LineEndConcatenation: { Enabled: false }
Style/MixinGrouping: { Enabled: false }
Style/MultilineBlockChain: { Enabled: false }
Style/PerlBackrefs: { Enabled: false } # use occasionally/sparingly
Style/RescueStandardError: { Enabled: false }
Style/Semicolon: { Enabled: false }
Style/SingleLineMethods: { Enabled: false }
Style/StabbyLambdaParentheses: { Enabled: false }
Style/WhenThen : { Enabled: false }
# I require trailing commas elsewhere, but these are optional
Style/TrailingCommaInArguments: { Enabled: false }
# If rubocop had an option to only enforce this on constants and literals (e.g.
# strings, regexp, range), I'd agree.
#
# But if you are using it e.g. on method arguments of unknown type, in the same
# style that ruby uses it with grep, then you are doing exactly the right thing.
Style/CaseEquality: { Enabled: false }
# I'd enable if "require_parentheses_when_complex" considered unary '!' simple.
Style/TernaryParentheses:
EnforcedStyle: require_parentheses_when_complex
Enabled: false
Style/BlockDelimiters:
inherit_mode:
merge:
- Exclude
- ProceduralMethods
- IgnoredMethods
- FunctionalMethods
EnforcedStyle: semantic
AllowBracesOnProceduralOneLiners: true
IgnoredMethods:
- expect # rspec
- profile # ruby-prof
- ips # benchmark-ips
Style/FormatString:
EnforcedStyle: percent
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
Style/StringLiteralsInInterpolation:
Enabled: true
EnforcedStyle: double_quotes
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: consistent_comma
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma
Style/YodaCondition:
EnforcedStyle: forbid_for_equality_operators_only