-
Notifications
You must be signed in to change notification settings - Fork 18
/
.rubocop.yml
229 lines (190 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
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
# Last reviewed on Aug 31st 2023, using RuboCop v1.56.1
require:
- rubocop-rspec
AllCops:
NewCops: enable
TargetRubyVersion: 3.2
Style/FrozenStringLiteralComment:
Enabled: true
Metrics/MethodLength:
Max: 15
Metrics/PerceivedComplexity:
Max: 9
Metrics/CyclomaticComplexity:
Max: 9
# Our displays are wide enough. IDEs are configured to linebreak beautifully when needed :) we trust common sense here.
Layout/LineLength:
Enabled: false
# Enforce that all string literals must use double quotes. This ensures real consistency.
# https://www.viget.com/articles/just-use-double-quoted-ruby-strings/
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
Style/StringLiteralsInInterpolation:
Enabled: true
EnforcedStyle: double_quotes
# Multiline literals and method calls should always have a trailing comma as that makes diffs less noisy.
# https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8
Style/TrailingCommaInArrayLiteral:
Enabled: true
EnforcedStyleForMultiline: consistent_comma
Style/TrailingCommaInHashLiteral:
Enabled: true
EnforcedStyleForMultiline: consistent_comma
Style/TrailingCommaInArguments:
Enabled: true
EnforcedStyleForMultiline: consistent_comma
# Allows to write case/when/end statements like:
# long_variable_name = case x
# when "a" then 1
# when "b" then 2
# end
# Instead of having to indent it near the the case statement which looks weird.
Layout/CaseIndentation:
EnforcedStyle: end
IndentOneStep: true
Layout/EndAlignment:
EnforcedStyleAlignWith: start_of_line
# The default style is `special_inside_parentheses` which looks like:
#
# this_is_a_method_call({
# some_key: "value",
# })
#
# This would cause an unnecessary huge diff if `in_a_method_call` is renamed,
# because all following lines need to be re-indented. That's why we prefer
# the layout like this:
#
# this_is_a_method_call({
# some_key: "value",
# })
#
Layout/FirstHashElementIndentation:
EnforcedStyle: consistent
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent
# Make sure gems are always alphabetically ordered.
Bundler/OrderedGems:
Enabled: true
# Emojis are fun, guys. Let's use them! 🚀 (also, special characters such as "→" are way better than e.g. "->")
Style/AsciiComments:
Enabled: false
# Lengthy blocks shouldn't be an issue in rspec…
Metrics/BlockLength:
Exclude:
- 'spec/**/*'
# Prefer word array literals using %w[] syntax
# https://stackoverflow.com/a/1274703/4075379
Style/WordArray:
Enabled: true
EnforcedStyle: percent
# https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/Next
Style/Next:
Enabled: true
EnforcedStyle: skip_modifier_ifs
# https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/GuardClause
Style/GuardClause:
Enabled: true
# Check for if and case statements where each branch is used for assignment to the same variable when using the return of the condition can be used instead.
Style/ConditionalAssignment:
Enabled: true
EnforcedStyle: assign_to_condition
# Long positional parameter lists make it hard to reason about the code, but named arguments are easier to follow, so we allow them.
Metrics/ParameterLists:
CountKeywordArgs: false
# We leave this one up to the developer's best judgement. For this to work well, we'd need to enable Layout/LineLength,
# which we don't want to because it would affect other areas of the codebase.
# https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/IfUnlessModifier
Style/IfUnlessModifier:
Enabled: false
# Aligning hash keys is important :)
# https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Layout/HashAlignment
Layout/HashAlignment:
Enabled: true
EnforcedHashRocketStyle: key
EnforcedColonStyle: key
EnforcedLastArgumentHashStyle: always_inspect
# This extra empty line is not needed.
Layout/EmptyLineAfterGuardClause:
Enabled: false
# Ensures that each key, element, parameter, and argument in a multiline hash start on a separate line.
Layout/MultilineHashKeyLineBreaks:
Enabled: true
Layout/MultilineArrayLineBreaks:
Enabled: true
Layout/MultilineMethodParameterLineBreaks:
Enabled: true
Layout/MultilineMethodArgumentLineBreaks:
Enabled: true
# Ensures a line break before the first element in a multiline hash, array, parameter, and argument.
Layout/FirstHashElementLineBreak:
Enabled: true
Layout/FirstArrayElementLineBreak:
Enabled: true
Layout/FirstMethodParameterLineBreak:
Enabled: true
Layout/FirstMethodArgumentLineBreak:
Enabled: false # Except this one because sometimes it makes code more complex to read than it should be.
# Helpful to make large numbers more readable.
Style/NumericLiterals:
Enabled: true
Exclude:
- 'db/schema.rb' # Don't format the magic date-like numbers generated by Rails.
# Most of these are more complicated to read & write than simply writing the conventional way.
Style/SymbolArray:
Enabled: false
Style/PerlBackrefs:
Enabled: false
# Omitting the hash value makes the code look too obscure. Not great for newcomers who are not used to this.
Style/HashSyntax:
Enabled: false
# If it's redundant, let's get rid of the block as it's more noisy.
Style/RedundantFetchBlock:
Enabled: true
# Use $stdout instead of STDOUT.
Style/GlobalStdStream:
Enabled: true
# Prefer Api::V1::MyController instead of nested and indented modules
Style/ClassAndModuleChildren:
Enabled: false
# This one measures "Assignment Branch Condition size". It's annoying and not helpful at all.
Metrics/AbcSize:
Enabled: false
# Don't enforce documentation. Trust common sense here.
Style/Documentation:
Enabled: false
# Enforce use of parentheses to call methods with arguments, instead of spaces.
Style/MethodCallWithArgsParentheses:
Enabled: true
EnforcedStyle: require_parentheses
AllowParenthesesInMultilineCall: true
AllowedMethods:
- 'attr_accessor'
- 'attr_reader'
- 'command'
- 'desc'
- 'gem'
- 'lane'
- 'platform'
- 'program'
- 'raise'
- 'require_relative'
- 'require'
# rspec tests code below
- 'after'
- 'be'
- 'before'
- 'context'
- 'describe'
- 'it'
- 'not_to'
- 'to'
RSpec/NamedSubject:
Enabled: true
EnforcedStyle: named_only
RSpec/ExampleLength:
Max: 20
RSpec/MultipleMemoizedHelpers:
Enabled: false
RSpec/MultipleExpectations:
Enabled: false