-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy path.rubocop-rails.yml
309 lines (265 loc) · 8.58 KB
/
.rubocop-rails.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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
inherit_from:
- .rubocop.yml
#################### Rails #################################
Rails:
Enabled: true
Rails/ActionFilter:
Description: 'Enforces consistent use of action filter methods.'
Enabled: true
EnforcedStyle: action
SupportedStyles:
- action
- filter
Include:
- app/controllers/**/*.rb
Rails/ActiveRecordAliases:
Description: >-
Avoid Active Record aliases:
Use `update` instead of `update_attributes`.
Use `update!` instead of `update_attributes!`.
Enabled: true
Rails/ActiveSupportAliases:
Description: >-
Avoid ActiveSupport aliases of standard ruby methods:
`String#starts_with?`, `String#ends_with?`,
`Array#append`, `Array#prepend`.
Enabled: true
Rails/ApplicationJob:
Description: 'Check that jobs subclass ApplicationJob.'
Enabled: true
Rails/ApplicationRecord:
Description: 'Check that models subclass ApplicationRecord.'
Enabled: true
Rails/Blank:
Description: 'Enforce using `blank?` and `present?`.'
Enabled: true
# Convert usages of `nil? || empty?` to `blank?`
NilOrEmpty: true
# Convert usages of `!present?` to `blank?`
NotPresent: true
# Convert usages of `unless present?` to `if blank?`
UnlessPresent: true
Rails/CreateTableWithTimestamps:
Description: >-
Checks the migration for which timestamps are not included
when creating a new table.
Enabled: true
Include:
- db/migrate/*.rb
Rails/Date:
Description: >-
Checks the correct usage of date aware methods,
such as Date.today, Date.current etc.
Enabled: true
EnforcedStyle: flexible
SupportedStyles:
- strict
- flexible
Rails/Delegate:
Description: 'Prefer delegate method for delegations.'
Enabled: true
EnforceForPrefixed: true
Rails/DelegateAllowBlank:
Description: 'Do not use allow_blank as an option to delegate.'
Enabled: true
Rails/DynamicFindBy:
Description: 'Use `find_by` instead of dynamic `find_by_*`.'
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find_by'
Enabled: true
Whitelist:
- find_by_sql
Rails/EnumUniqueness:
Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
Enabled: true
Include:
- app/models/**/*.rb
Rails/EnvironmentComparison:
Description: "Favor `Rails.env.production?` over `Rails.env == 'production'`"
Enabled: true
Rails/Exit:
Description: >-
Favor `fail`, `break`, `return`, etc. over `exit` in
application or library code outside of Rake files to avoid
exits during unit testing or running in production.
Enabled: true
Include:
- app/**/*.rb
- config/**/*.rb
- lib/**/*.rb
Exclude:
- lib/**/*.rake
Rails/FilePath:
Description: 'Use `Rails.root.join` for file path joining.'
Enabled: true
Rails/FindBy:
Description: 'Prefer find_by over where.first.'
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find_by'
Enabled: true
Include:
- app/models/**/*.rb
Rails/FindEach:
Description: 'Prefer all.find_each over all.find.'
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find-each'
Enabled: true
Include:
- app/models/**/*.rb
Rails/HasAndBelongsToMany:
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
Enabled: true
Include:
- app/models/**/*.rb
Rails/HasManyOrHasOneDependent:
Description: 'Define the dependent option to the has_many and has_one associations.'
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has_many-has_one-dependent-option'
Enabled: true
Include:
- app/models/**/*.rb
Rails/HttpPositionalArguments:
Description: 'Use keyword arguments instead of positional arguments in http method calls.'
Enabled: true
Include:
- 'spec/**/*'
- 'test/**/*'
Rails/HttpStatus:
Description: 'Enforces use of symbolic or numeric value to define HTTP status.'
Enabled: true
EnforcedStyle: symbolic
SupportedStyles:
- numeric
- symbolic
Rails/InverseOf:
Description: 'Checks for associations where the inverse cannot be determined automatically.'
Enabled: true
Include:
- app/models/**/*.rb
Rails/LexicallyScopedActionFilter:
Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the controller."
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#lexically-scoped-action-filter'
Enabled: true
Include:
- app/controllers/**/*.rb
Rails/NotNullColumn:
Description: 'Do not add a NOT NULL column without a default value'
Enabled: true
Include:
- db/migrate/*.rb
Rails/Output:
Description: 'Checks for calls to puts, print, etc.'
Enabled: true
Include:
- app/**/*.rb
- config/**/*.rb
- db/**/*.rb
- lib/**/*.rb
Rails/OutputSafety:
Description: 'The use of `html_safe` or `raw` may be a security risk.'
Enabled: true
Rails/PluralizationGrammar:
Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
Enabled: true
Rails/Presence:
Description: 'Checks code that can be written more easily using `Object#presence` defined by Active Support.'
Enabled: true
Rails/Present:
Description: 'Enforce using `blank?` and `present?`.'
Enabled: true
# Convert usages of `!nil? && !empty?` to `present?`
NotNilAndNotEmpty: true
# Convert usages of `!blank?` to `present?`
NotBlank: true
# Convert usages of `unless blank?` to `if present?`
UnlessBlank: true
Rails/ReadWriteAttribute:
Description: >-
Checks for read_attribute(:attr) and
write_attribute(:attr, val).
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#read-attribute'
Enabled: true
Include:
- app/models/**/*.rb
Rails/RedundantReceiverInWithOptions:
Description: 'Checks for redundant receiver in `with_options`.'
Enabled: true
Rails/RelativeDateConstant:
Description: 'Do not assign relative date to constants.'
Enabled: true
Rails/RequestReferer:
Description: 'Use consistent syntax for request.referer.'
Enabled: true
EnforcedStyle: referer
SupportedStyles:
- referer
- referrer
Rails/ReversibleMigration:
Description: 'Checks whether the change method of the migration file is reversible.'
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#reversible-migration'
Reference: 'http://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
Enabled: true
Include:
- db/migrate/*.rb
Rails/SafeNavigation:
Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
Enabled: true
# This will convert usages of `try` to use safe navigation as well as `try!`.
# `try` and `try!` work slightly differently. `try!` and safe navigation will
# both raise a `NoMethodError` if the receiver of the method call does not
# implement the intended method. `try` will not raise an exception for this.
ConvertTry: false
Rails/SaveBang:
Enabled: false
Description: Identifies possible cases where Active Record save! or related should
be used.
StyleGuide: https://github.com/bbatsov/rails-style-guide#save-bang
Rails/ScopeArgs:
Description: 'Checks the arguments of ActiveRecord scopes.'
Enabled: true
Include:
- app/models/**/*.rb
Rails/SkipsModelValidations:
Description: >-
Use methods that skips model validations with caution.
See reference for more information.
Reference: 'http://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
Enabled: true
Blacklist:
- decrement!
- decrement_counter
- increment!
- increment_counter
- toggle!
- touch
- update_all
- update_attribute
- update_column
- update_columns
- update_counters
Rails/TimeZone:
Description: 'Checks the correct usage of time zone aware methods.'
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
Enabled: true
EnforcedStyle: flexible
SupportedStyles:
- strict
- flexible
Rails/UniqBeforePluck:
Description: 'Prefer the use of uniq or distinct before pluck.'
Enabled: true
EnforcedStyle: conservative
SupportedStyles:
- conservative
- aggressive
AutoCorrect: false
Rails/UnknownEnv:
Description: 'Use correct environment name.'
Enabled: true
Environments:
- development
- test
- production
Rails/Validation:
Description: 'Use validates :attribute, hash of validations.'
Enabled: true
Include:
- app/models/**/*.rb