-
Notifications
You must be signed in to change notification settings - Fork 33
/
.rubocop.yml
238 lines (209 loc) · 5.47 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
inherit_from:
- node_modules/@prettier/plugin-ruby/rubocop.yml
- .rubocop_todo.yml
require:
- test_prof/rubocop
- rubocop-performance
- rubocop-rails
- rubocop-rspec
- rubocop-rspec_rails
- rubocop-capybara
- rubocop-factory_bot
inherit_mode:
merge:
- Exclude
AllCops:
NewCops: enable
Exclude:
- db/schema.rb
- db/views_schema.rb
- db/archived_migrations/*
# CI installs gems in the vendor directory, which causes rubocop to try
# and cop our gems. We don't want it to.
- vendor/**/*
- bin/*
- sbin/*
- node_modules/**/*
- tmp/**/*
RSpec/AggregateExamples:
# Aggregate examples can be useful, but the cop gets into nasty battles with
# other Spec cops, and is only really of value in expensive tests.
Enabled: false
# Added exclude because api and feature specs do not have a specific class.
RSpec/DescribeClass:
Exclude:
- "spec/requests/**/*.rb"
- "spec/api/**/*.rb"
- "spec/features/**/*.rb"
- "spec/views/**/*.rb"
Rails/SkipsModelValidations:
Exclude:
- "db/migrate/*.rb"
- "db/migrate_asset_refactor/*.rb"
- "features/support/step_definitions/*.rb"
Style/Documentation:
Enabled: false
Rails:
Enabled: true
# Step definitions are defined with Given /regex/ do ...
# There is little ambiguity here, and brackets just break convention
Lint/AmbiguousRegexpLiteral:
Exclude:
- features/support/step_definitions/**/*
# Only use shorthand hash syntax when all keys match the variables for better readability
Style/HashSyntax:
EnforcedShorthandSyntax: consistent
# Enforces 1234565789 as 123_456_789: While nice when dealing with actual big
# numbers, we're more likely to see it shout at us about barcodes.
Style/NumericLiterals:
Enabled: false
# Blocks are used to structure tests and are part of the shoulda dsl.
# The standard BlockLength limits are too stringent for this purpose.
# Block DSL is also used in routes
# We should be careful keeping rake tasks here, as large tasks are still an issue.
# Not sure if we need to split namespaces across several files though.
# We exclude builders, as they are concerned with rendering xml
Metrics/BlockLength:
Exclude:
- Gemfile
- "db/seeds/**/*"
- "**/*.builder"
CountAsOne:
- array
- hash
- heredoc
AllowedMethods:
- describe
- context
- background
- scenario
- namespace
- task
- included
- shared_context
- shared_examples
- shared_examples_for
- state_machine
- configure
- draw
- feature
- subject
- let
- let!
- factory
- define
- guard
- transient
- with_nested_has_many_association
- with_association
- it
- class_eval
- has_metadata
- resources
- aasm
- redefine_aasm
- model
- step
# We have a few custom find_by methods which we maintain.
# At least for now. find_by_id_or_name is a bit clunky.
Rails/DynamicFindBy:
Exclude:
- "app/sample_manifest_excel/**/*"
- "test/app/sample_manifest_excel/**/*"
AllowedMethods:
- find_by_sql
- find_by_id_or_name
- find_by_id_or_name!
- find_by_barcode
# Method length limits make little sense when you are describing a table schema
# or a view.
Metrics/MethodLength:
Exclude:
- "db/migrate/*"
CountAsOne:
- array
- hash
- heredoc
Style/ClassAndModuleChildren:
Enabled: false
Rails/UnknownEnv:
Environments:
- production
- development
- test
- cucumber
- profile
RSpec/ExampleLength:
inherit_mode:
merge:
- Exclude
CountAsOne:
- array
- hash
- heredoc
# Disable for features, as we might want to step through long processes
Exclude:
- "spec/features/**/*"
Metrics/ClassLength:
inherit_mode:
merge:
- Exclude
CountAsOne:
- array
- hash
- heredoc
# Disable for features and tests, we want lots of tests
Exclude:
- "spec/**/*"
- "test/**/*"
RSpecRails/AvoidSetupHook:
Exclude:
- "test/**/*"
RSpec/MultipleExpectations:
Exclude:
- "spec/features/**/*"
Lint/UnusedMethodArgument:
# Unused keyword arguments are good for maintaining API compatibility, and
# applying an underscore before the keyword name breaks that API.
AllowUnusedKeywordArguments: true
# This seems to be causing all sorts of issues with failing tests
Rails/RedundantPresenceValidationOnBelongsTo:
Enabled: false
Rails/UniqueValidationWithoutIndex:
Enabled: false
# Factory Bot
FactoryBot/FactoryAssociationWithStrategy:
Enabled: false
# Capybara
Capybara/ClickLinkOrButtonStyle:
Enabled: false
# Disabling newly introduced cops until we have time to sort out the offenses
Rails/I18nLocaleTexts: # new in 2.14
Enabled: false
RSpecRails/InferredSpecType: # new in 2.14
Enabled: false
Lint/NonAtomicFileOperation: # new in 1.31
Enabled: false
Rails/ActionControllerTestCase: # new in 2.14
Enabled: false
RSpec/NoExpectationExample: # new in 2.13
Enabled: false
# New in ruby 3 upgrade
RSpec/IndexedLet:
Enabled: false
RSpec/SpecFilePathFormat:
Enabled: false
RSpec/PendingWithoutReason:
Enabled: false
Performance/MapMethodChain:
Enabled: false
Rails/ThreeStateBooleanColumn:
Enabled: false
RSpec/ExpectInHook:
Enabled: false
# New in Ruby 3.2 upgrade
# Added to Rubocop Todo and handling from there
RSpec/MultipleMemoizedHelpers: # new in 1.43
Enabled: false # We don't see a benefit to limiting the number of memoized helpers.
RSpec/NestedGroups: # new in 1.7
Max: 6 # Set a more reasonable max. We've been happy with our existing nesting.