-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path.rubocop.yml
More file actions
198 lines (170 loc) · 4.45 KB
/
Copy path.rubocop.yml
File metadata and controls
198 lines (170 loc) · 4.45 KB
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
inherit_from:
- .rubocop_todo.yml
plugins:
- rubocop-capybara
- rubocop-performance
- rubocop-rails
- rubocop-rspec
- rubocop-rspec_rails
AllCops:
Exclude:
- bin/**/*
- node_modules/**/*
- tmp/**/*
- vendor/**/*
NewCops: enable
Layout/IndentationWidth:
EnforcedStyleAlignWith: relative_to_receiver
Layout/LeadingCommentSpace:
AllowRBSInlineAnnotation: true
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
Layout/MultilineOperationIndentation:
EnforcedStyle: indented
Layout/SpaceInsideArrayLiteralBrackets:
Exclude:
- config/environments/production.rb
# Filter out all the DSLs
Metrics/BlockLength:
CountAsOne:
- array
- hash
- heredoc
AllowedMethods:
- describe
- context
- background
- scenario
- namespace
- task
- included
- shared_context
- shared_examples
- state_machine
- configure
- draw
- feature
- subject
- let
- let!
- factory
- define
- guard
- transient
- it
Exclude:
- config/robots.rb
Metrics/ClassLength:
CountAsOne:
- array
- hash
- heredoc
Metrics/MethodLength:
CountAsOne:
- array
- hash
- heredoc
# There is so much existing inconsistent code that it is not worth enforcing this cop
Naming/PredicateMethod:
Enabled: false
Naming/VariableNumber:
CheckSymbols:
false # Rubocop gets annoyed about our states. I'm disabling globally
# as I'm honestly not that bothered.
Rails:
Enabled: true
# We're not actually using Rails methods here.
Rails/InverseOf:
Enabled: false
Rails/HasManyOrHasOneDependent:
Enabled: false
Rails/FindBy:
Enabled: false
Rails/FindByOrAssignmentMemoization:
Enabled: true # Using JSON-API method; the interface is similar to Rails find_by, so this cop is still useful
RSpec/ContextWording:
Prefixes:
- by
- for
- from
- if
- in
- unless
- when
- where
- which
- with
- without
RSpec/DescribeClass:
# Exclude files like exports that do not have a specific class.
Exclude:
- spec/factory_outputs/**/*.rb
- spec/views/**/*exports/**/*.rb
RSpec/DescribedClass:
EnforcedStyle: described_class
SkipBlocks: true # Addresses a known caveat with rspec-rails’s ‘controller` helper that runs its
# block in a different context
RSpec/ExampleLength:
inherit_mode:
merge:
- Exclude
CountAsOne:
- array
- hash
- heredoc
- method_call
# Disable for features, as we might want to step through long processes
Exclude:
- 'spec/features/**/*'
RSpec/IndexedLet:
Enabled: false # We have a lot of indexed lets in our specs, mostly based on wells or racked tubes
RSpec/LetBeforeExamples:
Enabled: false # It can be helpful to have the let variables just before the relevant example
RSpec/ScatteredLet:
Enabled: false # Disabling due to scattered lets not being such a big deal and the automated fix
# being unreliable (see https://github.com/rubocop/rubocop-rspec/issues/1167).
RSpec/MultipleMemoizedHelpers:
Enabled: false # We have a lot of memoized helpers in our specs, not sure how best to work around this, so disabling
RSpec/NestedGroups:
Max: 5 # Default is 3, but we have a lot of nested groups in our specs
RSpec/NamedSubject:
EnforcedStyle: named_only
Style/ClassAndModuleChildren:
Enabled: false
# This cop doesn't always increase clarity
Style/CollectionQuerying:
Enabled: false
# The single-line syntax can be clearer than the multi-line version for multiple definitions
Style/EmptyClassDefinition:
Enabled: false
Style/EmptyMethod:
EnforcedStyle: expanded
# This is now default in Ruby 3.4
# Excluding generated files
Style/FrozenStringLiteralComment:
Exclude:
- bin/setup
- config/application.rb
- config/boot.rb
- config/environment.rb
- config/environments/*.rb
- config/initializers/content_security_policy.rb
- config/initializers/filter_parameter_logging.rb
- config/initializers/inflections.rb
- config/puma.rb
# Only use shorthand hash syntax when all keys match the variables for better readability
Style/HashSyntax:
EnforcedShorthandSyntax: consistent
Style/StringLiterals:
# Files generated by Rails
Exclude:
- bin/setup
- config/application.rb
- config/boot.rb
- config/environment.rb
- config/environments/*.rb
- config/puma.rb
Style/SymbolArray:
# Files generated by Rails and frequently updated
Exclude:
- config/initializers/filter_parameter_logging.rb