-
Notifications
You must be signed in to change notification settings - Fork 1
/
.rubocop.yml
243 lines (203 loc) · 5.39 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
---
require:
- rubocop-performance
- rubocop-rspec
# Built-in config:
# https://github.com/bbatsov/rubocop/blob/master/config/default.yml
# We do not typically use/need class documentation
Style/Documentation:
Enabled: false
AllCops:
NewCops: enable
DisplayCopNames: true
DisplayStyleGuide: true
TargetRubyVersion: 2.6
SuggestExtensions: false
Exclude:
- 'bin/*'
- 'node_modules/**/*'
- 'bower_components/**/*'
- 'tmp/**/*'
- 'vendor/**/*'
- 'bin/**/*'
- 'doc/**/*'
Layout/LineLength:
Max: 120
Metrics/ModuleLength:
Exclude:
- 'spec/**/*_spec.rb'
Metrics/BlockLength:
Exclude:
- 'spec/**/*.rb'
# We generally don't want methods longer than 20 lines, except in migrations where it's probably okay.
Metrics/MethodLength:
Max: 20
Exclude:
- 'db/migrate/**/*.rb'
- 'spec/**/*'
# This cop complains when you have variables named things like:
# address_line_1
# address_line_2
# etc.
Naming/VariableNumber:
Enabled: false
# Just always use `raise` and stop thinking about it.
Style/SignalException:
EnforcedStyle: only_raise
# We think that:
# array = [
# :value
# ]
# and_in_a_method_call([
# :value
# ])
# Looks better than:
# value = [
# :value
# ]
# but_in_a_method_call([
# :its_like_this
# ])
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent
# We think that:
# hash = {
# key: :value
# }
# and_in_a_method_call({
# no: :difference
# })
# Looks better than:
# hash = {
# key: :value
# }
# but_in_a_method_call({
# its_like: :this
# })
Layout/FirstHashElementIndentation:
EnforcedStyle: consistent
# We think that:
# {
# foo: :bar
# baz: :bip
# }
# Looks better than:
# { foo: :bar
# baz: :bip }
Layout/MultilineHashBraceLayout:
Enabled: false
# We think that:
# foo(
# bar: :baz,
# bip: :whizz
# )
# Looks better than:
# foo(bar: baz,
# bip: :whizz)
Layout/MultilineMethodCallBraceLayout:
Enabled: false
# Just always use double quotes and stop thinking about it.
Style/StringLiterals:
EnforcedStyle: double_quotes
Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes
# Ruby 2.4+ has a magic comment that makes all strings frozen and Rubocop wants to put it
# at the top of every. single. file. We decided we didn't want that - for now.
Style/FrozenStringLiteralComment:
Enabled: false
# We usually don't want you to use semicolons in Ruby, except in specs where brevity is
# often more valued than readability.
Style/Semicolon:
AllowAsExpressionSeparator: true
Exclude:
- 'spec/**/*.rb'
# Single line method definitions are totally fine, and often more readable, consider:
# class WidgetsPolicy
# def create?; false; end
# def index?; true; end
# def show?; true; end
# def update?; false; end
# def delete?; false; end
# end
Style/SingleLineMethods:
Enabled: false
# We want you to put a blank line between method definitions, the only exception being
# if you're defining a bunch of single-line methods as above.
Layout/EmptyLineBetweenDefs:
AllowAdjacentOneLineDefs: true
Naming/FileName:
Exclude:
- '**/Gemfile'
- '**/Rakefile'
- '**/Berksfile'
# Disable preference for Ruby's new safe navigation operator `&.` because it
# usually comes at the cost of expressiveness in the simple case:
#
# - coupon_usage.destroy if coupon_usage
# + coupon_usage&.destroy
#
# And guides you towards Law of Demeter violations in the extreme case:
#
# result&.data&.attributes&.payments&.first&.payment_token
#
# Disabling this cop doesn't stop you from using it, but be prepared to defend
# it in code review if you do.
Style/SafeNavigation:
Enabled: false
# Ruby supports two styles of string template formatting.
# "annotated" - format("%<greeting>s", greeting: "Hello")
# "template" - format("%{greeting}", greeting: "Hello")
#
# While the annotated format is more descriptive, it also comes in a style that is
# significantly harder for a developer to parse. The template style is easy to read, understand,
# and is consistent with formatting with (for example), interpolation (#{}).
Style/FormatStringToken:
EnforcedStyle: template
# This syntax is a deliberate idiom in rspec
# bbatsov endorses disabling it for rspec
# https://github.com/bbatsov/rubocop/issues/4222#issuecomment-290722962
Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/**/*'
# https://rubocop.readthedocs.io/en/latest/cops_style/
Style/HashTransformKeys:
Enabled: false
# https://rubocop.readthedocs.io/en/latest/cops_style/
Style/HashTransformValues:
Enabled: false
Metrics/AbcSize:
Max: 18
Exclude:
- 'spec/**/*'
Metrics/ClassLength:
Exclude:
- 'spec/**/*'
Naming/MemoizedInstanceVariableName:
EnforcedStyleForLeadingUnderscores: optional
Performance/Casecmp:
Enabled: false
Style/BarePercentLiterals:
EnforcedStyle: percent_q
Style/ClassAndModuleChildren:
Enabled: false
Style/DoubleNegation:
Enabled: false
Style/EmptyMethod:
Enabled: false
Style/NumericPredicate:
Enabled: false
Style/TrivialAccessors:
AllowPredicates: true
RSpec:
Language:
Expectations:
- assert_match
RSpec/MultipleExpectations:
Max: 10
RSpec/ExampleLength:
Max: 30
RSpec/RepeatedExample:
Exclude:
- 'spec/policies/**'
RSpec/MultipleMemoizedHelpers:
Max: 10