rubocop-highlands 1.0.0

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