rubocop-airbnb 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +2 -0
  3. data/Gemfile +7 -0
  4. data/LICENSE.md +9 -0
  5. data/README.md +68 -0
  6. data/config/default.yml +39 -0
  7. data/config/rubocop-airbnb.yml +96 -0
  8. data/config/rubocop-bundler.yml +8 -0
  9. data/config/rubocop-gemspec.yml +9 -0
  10. data/config/rubocop-layout.yml +514 -0
  11. data/config/rubocop-lint.yml +315 -0
  12. data/config/rubocop-metrics.yml +47 -0
  13. data/config/rubocop-naming.yml +68 -0
  14. data/config/rubocop-performance.yml +143 -0
  15. data/config/rubocop-rails.yml +193 -0
  16. data/config/rubocop-rspec.yml +281 -0
  17. data/config/rubocop-security.yml +13 -0
  18. data/config/rubocop-style.yml +953 -0
  19. data/lib/rubocop-airbnb.rb +11 -0
  20. data/lib/rubocop/airbnb.rb +16 -0
  21. data/lib/rubocop/airbnb/inflections.rb +14 -0
  22. data/lib/rubocop/airbnb/inject.rb +20 -0
  23. data/lib/rubocop/airbnb/rails_autoloading.rb +55 -0
  24. data/lib/rubocop/airbnb/version.rb +8 -0
  25. data/lib/rubocop/cop/airbnb/class_name.rb +47 -0
  26. data/lib/rubocop/cop/airbnb/class_or_module_declared_in_wrong_file.rb +138 -0
  27. data/lib/rubocop/cop/airbnb/const_assigned_in_wrong_file.rb +74 -0
  28. data/lib/rubocop/cop/airbnb/continuation_slash.rb +25 -0
  29. data/lib/rubocop/cop/airbnb/default_scope.rb +20 -0
  30. data/lib/rubocop/cop/airbnb/factory_attr_references_class.rb +74 -0
  31. data/lib/rubocop/cop/airbnb/factory_class_use_string.rb +39 -0
  32. data/lib/rubocop/cop/airbnb/mass_assignment_accessible_modifier.rb +18 -0
  33. data/lib/rubocop/cop/airbnb/module_method_in_wrong_file.rb +104 -0
  34. data/lib/rubocop/cop/airbnb/no_timeout.rb +19 -0
  35. data/lib/rubocop/cop/airbnb/opt_arg_parameters.rb +38 -0
  36. data/lib/rubocop/cop/airbnb/phrase_bundle_keys.rb +67 -0
  37. data/lib/rubocop/cop/airbnb/risky_activerecord_invocation.rb +63 -0
  38. data/lib/rubocop/cop/airbnb/rspec_describe_or_context_under_namespace.rb +114 -0
  39. data/lib/rubocop/cop/airbnb/rspec_environment_modification.rb +58 -0
  40. data/lib/rubocop/cop/airbnb/simple_modifier_conditional.rb +23 -0
  41. data/lib/rubocop/cop/airbnb/spec_constant_assignment.rb +55 -0
  42. data/lib/rubocop/cop/airbnb/unsafe_yaml_marshal.rb +47 -0
  43. data/rubocop-airbnb.gemspec +32 -0
  44. data/spec/rubocop/cop/airbnb/class_name_spec.rb +78 -0
  45. data/spec/rubocop/cop/airbnb/class_or_module_declared_in_wrong_file_spec.rb +174 -0
  46. data/spec/rubocop/cop/airbnb/const_assigned_in_wrong_file_spec.rb +178 -0
  47. data/spec/rubocop/cop/airbnb/continuation_slash_spec.rb +162 -0
  48. data/spec/rubocop/cop/airbnb/default_scope_spec.rb +38 -0
  49. data/spec/rubocop/cop/airbnb/factory_attr_references_class_spec.rb +160 -0
  50. data/spec/rubocop/cop/airbnb/factory_class_use_string_spec.rb +26 -0
  51. data/spec/rubocop/cop/airbnb/mass_assignment_accessible_modifier_spec.rb +28 -0
  52. data/spec/rubocop/cop/airbnb/module_method_in_wrong_file_spec.rb +181 -0
  53. data/spec/rubocop/cop/airbnb/no_timeout_spec.rb +30 -0
  54. data/spec/rubocop/cop/airbnb/opt_arg_parameter_spec.rb +103 -0
  55. data/spec/rubocop/cop/airbnb/phrase_bundle_keys_spec.rb +74 -0
  56. data/spec/rubocop/cop/airbnb/risky_activerecord_invocation_spec.rb +54 -0
  57. data/spec/rubocop/cop/airbnb/rspec_describe_or_context_under_namespace_spec.rb +284 -0
  58. data/spec/rubocop/cop/airbnb/rspec_environment_modification_spec.rb +64 -0
  59. data/spec/rubocop/cop/airbnb/simple_modifier_conditional_spec.rb +122 -0
  60. data/spec/rubocop/cop/airbnb/spec_constant_assignment_spec.rb +80 -0
  61. data/spec/rubocop/cop/airbnb/unsafe_yaml_marshal_spec.rb +50 -0
  62. data/spec/spec_helper.rb +35 -0
  63. metadata +150 -0
@@ -0,0 +1,193 @@
1
+ # before_action doesn't seem to exist, so this doesn't make sense.
2
+ Rails/ActionFilter:
3
+ Enabled: false
4
+
5
+ Rails/ActiveSupportAliases:
6
+ Enabled: false
7
+
8
+ Rails/ApplicationJob:
9
+ Enabled: false
10
+
11
+ Rails/ApplicationRecord:
12
+ Enabled: false
13
+
14
+ Rails/Blank:
15
+ Description: 'Enforce using `blank?` and `present?`.'
16
+ Enabled: true
17
+ # Convert checks for `nil` or `empty?` to `blank?`
18
+ NilOrEmpty: true
19
+ # Convert usages of not `present?` to `blank?`
20
+ NotPresent: true
21
+ # Convert usages of `unless` `present?` to `if` `blank?`
22
+ UnlessPresent: true
23
+
24
+ Rails/CreateTableWithTimestamps:
25
+ Description: Checks the migration for which timestamps are not included when creating a new table.
26
+ Enabled: true
27
+
28
+ Rails/Date:
29
+ Description: Checks the correct usage of date aware methods, such as Date.today, Date.current
30
+ etc.
31
+ Enabled: false
32
+ EnforcedStyle: flexible
33
+ SupportedStyles:
34
+ - strict
35
+ - flexible
36
+
37
+ # Supports --auto-correct
38
+ Rails/Delegate:
39
+ Description: Prefer delegate method for delegations.
40
+ Enabled: false
41
+
42
+ Rails/DelegateAllowBlank:
43
+ Enabled: false
44
+
45
+ Rails/DynamicFindBy:
46
+ Enabled: false
47
+
48
+ Rails/EnumUniqueness:
49
+ Enabled: false
50
+
51
+ Rails/EnvironmentComparison:
52
+ Description: "Favor `Rails.env.production?` over `Rails.env == 'production'`"
53
+ Enabled: true
54
+
55
+ Rails/Exit:
56
+ Description: >-
57
+ Favor `fail`, `break`, `return`, etc. over `exit` in
58
+ application or library code outside of Rake files to avoid
59
+ exits during unit testing or running in production.
60
+ Enabled: false
61
+
62
+ Rails/FilePath:
63
+ Enabled: false
64
+
65
+ # Supports --auto-correct
66
+ Rails/FindBy:
67
+ Description: Prefer find_by over where.first.
68
+ Enabled: false
69
+ Include:
70
+ - app/models/**/*.rb
71
+
72
+ # Supports --auto-correct
73
+ Rails/FindEach:
74
+ Description: Prefer all.find_each over all.find.
75
+ Enabled: false
76
+ Include:
77
+ - app/models/**/*.rb
78
+
79
+ Rails/HasAndBelongsToMany:
80
+ Description: Prefer has_many :through to has_and_belongs_to_many.
81
+ Enabled: false
82
+ Include:
83
+ - app/models/**/*.rb
84
+
85
+ Rails/HasManyOrHasOneDependent:
86
+ Enabled: false
87
+
88
+ Rails/HttpPositionalArguments:
89
+ Enabled: false
90
+
91
+ Rails/InverseOf:
92
+ Description: 'Checks for associations where the inverse cannot be determined automatically.'
93
+ Enabled: false
94
+
95
+ Rails/LexicallyScopedActionFilter:
96
+ Description: Checks that methods specified in the filter's `only` or `except` options are
97
+ explicitly defined in the controller.
98
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#lexically-scoped-action-filter'
99
+ Enabled: false
100
+
101
+ Rails/NotNullColumn:
102
+ Enabled: false
103
+
104
+ Rails/Output:
105
+ Description: Checks for calls to puts, print, etc.
106
+ Enabled: false
107
+ Include:
108
+ - app/**/*.rb
109
+ - config/**/*.rb
110
+ - db/**/*.rb
111
+ - lib/**/*.rb
112
+
113
+ Rails/OutputSafety:
114
+ Description: 'The use of `html_safe` or `raw` may be a security risk.'
115
+ Enabled: false
116
+
117
+ # Supports --auto-correct
118
+ Rails/PluralizationGrammar:
119
+ Description: Checks for incorrect grammar when using methods like `3.day.ago`.
120
+ Enabled: false
121
+
122
+ Rails/Presence:
123
+ Description: Checks code that can be written more easily using `Object#presence` defined by
124
+ Active Support.
125
+ Enabled: false
126
+
127
+ Rails/Present:
128
+ Description: 'Enforce using `blank?` and `present?`.'
129
+ Enabled: true
130
+ NotNilAndNotEmpty: true
131
+ # Convert checks for not `nil` and not `empty?` to `present?`
132
+ NotBlank: true
133
+ # Convert usages of not `blank?` to `present?`
134
+ UnlessBlank: true
135
+ # Convert usages of `unless` `blank?` to `if` `present?`
136
+
137
+ # Supports --auto-correct
138
+ Rails/ReadWriteAttribute:
139
+ Description: Checks for read_attribute(:attr) and write_attribute(:attr, val).
140
+ Enabled: false
141
+ Include:
142
+ - app/models/**/*.rb
143
+
144
+ Rails/RedundantReceiverInWithOptions:
145
+ Description: 'Checks for redundant receiver in `with_options`.'
146
+ Enabled: true
147
+
148
+ Rails/RelativeDateConstant:
149
+ Enabled: false
150
+
151
+ Rails/RequestReferer:
152
+ Description: 'Use consistent syntax for request.referer.'
153
+ Enabled: false
154
+
155
+ Rails/ReversibleMigration:
156
+ Enabled: false
157
+
158
+ Rails/SafeNavigation:
159
+ Enabled: false
160
+
161
+ Rails/SaveBang:
162
+ Enabled: false
163
+
164
+ Rails/ScopeArgs:
165
+ Description: Checks the arguments of ActiveRecord scopes.
166
+ Enabled: true
167
+ Include:
168
+ - app/models/**/*.rb
169
+
170
+ Rails/SkipsModelValidations:
171
+ Enabled: false
172
+
173
+ Rails/TimeZone:
174
+ Description: Checks the correct usage of time zone aware methods.
175
+ StyleGuide: https://github.com/bbatsov/rails-style-guide#time
176
+ Reference: http://danilenko.org/2012/7/6/rails_timezones
177
+ Enabled: false
178
+ EnforcedStyle: flexible
179
+ SupportedStyles:
180
+ - strict
181
+ - flexible
182
+
183
+ Rails/UniqBeforePluck:
184
+ Enabled: false
185
+
186
+ Rails/UnknownEnv:
187
+ Enabled: false
188
+
189
+ Rails/Validation:
190
+ Description: Use validates :attribute, hash of validations.
191
+ Enabled: false
192
+ Include:
193
+ - app/models/**/*.rb
@@ -0,0 +1,281 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ RSpec/AlignLeftLetBrace:
5
+ Description: Checks that left braces for adjacent single line lets are aligned.
6
+ Enabled: false
7
+
8
+ RSpec/AlignRightLetBrace:
9
+ Description: Checks that right braces for adjacent single line lets are aligned.
10
+ Enabled: false
11
+
12
+ RSpec/AnyInstance:
13
+ Description: 'Prefer instance doubles over stubbing any instance of a class'
14
+ Enabled: false
15
+
16
+ RSpec/AroundBlock:
17
+ Description: Checks that around blocks actually run the test.
18
+ Enabled: true
19
+
20
+ RSpec/BeEql:
21
+ Description: Check for expectations where `be(...)` can replace `eql(...)`.
22
+ Enabled: false
23
+
24
+ RSpec/BeforeAfterAll:
25
+ Description: Check that before/after(:all) isn't being used.
26
+ Enabled: true
27
+ Exclude:
28
+ - spec/spec_helper.rb
29
+ - spec/rails_helper.rb
30
+ - spec/support/**/*.rb
31
+
32
+ RSpec/ContextWording:
33
+ Enabled: false
34
+
35
+ RSpec/DescribeClass:
36
+ Description: 'Check that the first argument to the top level describe is the tested class or module.'
37
+ Enabled: false
38
+
39
+ RSpec/DescribeMethod:
40
+ Description: 'Checks that the second argument to top level describe is the tested method name.'
41
+ Enabled: false
42
+
43
+ RSpec/DescribeSymbol:
44
+ Description: Avoid describing symbols.
45
+ Enabled: true
46
+
47
+ RSpec/DescribedClass:
48
+ Description: 'Use `described_class` for tested class / module'
49
+ Enabled: false
50
+
51
+ RSpec/EmptyExampleGroup:
52
+ Description: Checks if an example group does not include any tests.
53
+ Enabled: true
54
+ CustomIncludeMethods: []
55
+
56
+ RSpec/EmptyLineAfterFinalLet:
57
+ Description: Checks if there is an empty line after the last let block.
58
+ Enabled: true
59
+
60
+ RSpec/EmptyLineAfterSubject:
61
+ Description: Checks if there is an empty line after subject block.
62
+ Enabled: true
63
+
64
+ RSpec/ExampleLength:
65
+ Description: >-
66
+ A long example is usually more difficult to understand.
67
+ Consider extracting out some behaviour, e.g. with a `let` block, or a helper method.
68
+ Enabled: false
69
+
70
+ RSpec/ExampleWording:
71
+ Description: 'Do not use should when describing your tests.'
72
+ Enabled: true
73
+ CustomTransform:
74
+ be: is
75
+ have: has
76
+ not: does not
77
+ NOT: does not
78
+ automatically: automatically
79
+ correctly: correctly
80
+ successfully: successfully
81
+ only: only
82
+ properly: properly
83
+ response: responds
84
+ be redirect: redirects
85
+ IgnoredWords: []
86
+
87
+ RSpec/ExpectActual:
88
+ Description: Checks for `expect(...)` calls containing literal values.
89
+ Enabled: true
90
+ Exclude:
91
+ - spec/routing/**/*
92
+
93
+ RSpec/ExpectInHook:
94
+ Enabled: true
95
+ Description: Do not use `expect` in hooks such as `before`.
96
+
97
+ RSpec/ExpectOutput:
98
+ Description: Checks for opportunities to use `expect { ... }.to output`.
99
+ Enabled: false
100
+
101
+ RSpec/FilePath:
102
+ Description: 'Checks the file and folder naming of the spec file.'
103
+ Enabled: false
104
+ CustomTransform:
105
+ RuboCop: rubocop
106
+ RSpec: rspec
107
+
108
+ RSpec/Focus:
109
+ Description: Checks if examples are focused.
110
+ Enabled: false
111
+
112
+ RSpec/HookArgument:
113
+ Description: Checks the arguments passed to `before`, `around`, and `after`.
114
+ Enabled: false
115
+ EnforcedStyle: implicit
116
+ SupportedStyles:
117
+ - implicit
118
+ - each
119
+ - example
120
+
121
+ RSpec/ImplicitExpect:
122
+ Description: Check that a consistent implicit expectation style is used.
123
+ Enabled: false
124
+ EnforcedStyle: is_expected
125
+ SupportedStyles:
126
+ - is_expected
127
+ - should
128
+
129
+ RSpec/InstanceSpy:
130
+ Description: Checks for `instance_double` used with `have_received`.
131
+ Enabled: false
132
+
133
+ RSpec/InstanceVariable:
134
+ Description: 'Checks for the usage of instance variables.'
135
+ Enabled: false
136
+
137
+ RSpec/InvalidPredicateMatcher:
138
+ Description: Checks invalid usage for predicate matcher.
139
+ Enabled: false
140
+
141
+ RSpec/ItBehavesLike:
142
+ Description: Checks that only one `it_behaves_like` style is used.
143
+ Enabled: false
144
+ EnforcedStyle: it_behaves_like
145
+ SupportedStyles:
146
+ - it_behaves_like
147
+ - it_should_behave_like
148
+
149
+ RSpec/IteratedExpectation:
150
+ Description: Check that `all` matcher is used instead of iterating over an array.
151
+ Enabled: false
152
+
153
+ RSpec/LeadingSubject:
154
+ Description: Checks for `subject` definitions that come after `let` definitions.
155
+ Enabled: true
156
+
157
+ RSpec/LetBeforeExamples:
158
+ Description: Checks for `let` definitions that come after an example.
159
+ Enabled: true
160
+
161
+ RSpec/LetSetup:
162
+ Enabled: false
163
+
164
+ RSpec/MessageChain:
165
+ Description: Check that chains of messages are not being stubbed.
166
+ Enabled: false
167
+
168
+ RSpec/MessageExpectation:
169
+ Description: Checks for consistent message expectation style.
170
+ Enabled: false
171
+ EnforcedStyle: allow
172
+ SupportedStyles:
173
+ - allow
174
+ - expect
175
+
176
+ RSpec/MessageSpies:
177
+ Description: Checks that message expectations are set using spies.
178
+ Enabled: false
179
+ EnforcedStyle: have_received
180
+ SupportedStyles:
181
+ - have_received
182
+ - receive
183
+
184
+ RSpec/MultipleDescribes:
185
+ Description: 'Checks for multiple top level describes.'
186
+ Enabled: true
187
+
188
+ RSpec/MultipleExpectations:
189
+ Description: Checks if examples contain too many `expect` calls.
190
+ Enabled: false
191
+ Max: 1
192
+
193
+ RSpec/MultipleSubjects:
194
+ Description: Checks if an example group defines `subject` multiple times.
195
+ Enabled: true
196
+
197
+ RSpec/NamedSubject:
198
+ Description: Checks for explicitly referenced test subjects.
199
+ Enabled: false
200
+
201
+ RSpec/NestedGroups:
202
+ Description: Checks for nested example groups.
203
+ Enabled: false
204
+ Max: 3
205
+
206
+ RSpec/NotToNot:
207
+ Description: 'Enforces the usage of the same method on all negative message expectations.'
208
+ Enabled: true
209
+ EnforcedStyle: not_to
210
+ SupportedStyles:
211
+ - not_to
212
+ - to_not
213
+
214
+ RSpec/OverwritingSetup:
215
+ Enabled: false
216
+ Description: Checks if there is a let/subject that overwrites an existing one.
217
+
218
+ RSpec/PredicateMatcher:
219
+ Description: Prefer using predicate matcher over using predicate method directly.
220
+ Enabled: false
221
+ Strict: true
222
+ EnforcedStyle: inflected
223
+ SupportedStyles:
224
+ - inflected
225
+ - explicit
226
+
227
+ RSpec/RepeatedDescription:
228
+ Enabled: true
229
+ Description: Check for repeated description strings in example groups.
230
+
231
+ RSpec/RepeatedExample:
232
+ Enabled: true
233
+ Description: Check for repeated examples within example groups.
234
+
235
+ RSpec/ReturnFromStub:
236
+ Enabled: true
237
+ Description: Checks for consistent style of stub's return setting.
238
+ EnforcedStyle: and_return
239
+ SupportedStyles:
240
+ - and_return
241
+ - block
242
+
243
+ RSpec/ScatteredLet:
244
+ Description: Checks for let scattered across the example group.
245
+ Enabled: true
246
+
247
+ RSpec/ScatteredSetup:
248
+ Description: Checks for setup scattered across multiple hooks in an example group.
249
+ Enabled: true
250
+
251
+ RSpec/SharedContext:
252
+ Description: Checks for proper shared_context and shared_examples usage.
253
+ Enabled: false
254
+
255
+ RSpec/SingleArgumentMessageChain:
256
+ Description: Checks that chains of messages contain more than one element.
257
+ Enabled: true
258
+
259
+ RSpec/SubjectStub:
260
+ Description: Checks for stubbed test subjects.
261
+ Enabled: false
262
+
263
+ RSpec/VerifiedDoubles:
264
+ Description: 'Prefer using verifying doubles over normal doubles.'
265
+ Enabled: false
266
+
267
+ RSpec/VoidExpect:
268
+ Description: This cop checks void `expect()`.
269
+ Enabled: false
270
+
271
+ Capybara/CurrentPathExpectation:
272
+ Description: Checks that no expectations are set on Capybara's `current_path`.
273
+ Enabled: false
274
+
275
+ Capybara/FeatureMethods:
276
+ Description: Checks for consistent method usage in feature specs.
277
+ Enabled: false
278
+
279
+ FactoryBot/DynamicAttributeDefinedStatically:
280
+ Description: Prefer declaring dynamic attribute values in a block.
281
+ Enabled: true