rubocop-dev_doc 0.2.0 → 0.3.1
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.
- checksums.yaml +4 -4
- data/config/default.yml +235 -61
- data/lib/dev_doc/test/best_practice_lints.rb +31 -0
- data/lib/dev_doc/test/lints/cron_schedule.rb +345 -0
- data/lib/dev_doc/test/lints/duplicate_snapshot.rb +197 -0
- data/lib/dev_doc/test/lints/no_file_excludes.rb +128 -0
- data/lib/rubocop/cop/dev_doc/auth/current_user_branching.rb +203 -0
- data/lib/rubocop/cop/dev_doc/auth/load_resource_current_user_guard.rb +287 -0
- data/lib/rubocop/cop/dev_doc/migration/avoid_conditional_schema_changes.rb +89 -0
- data/lib/rubocop/cop/dev_doc/migration/avoid_non_null.rb +121 -0
- data/lib/rubocop/cop/dev_doc/rails/application_record_transaction.rb +1 -1
- data/lib/rubocop/cop/dev_doc/rails/bang_save_in_transaction.rb +127 -0
- data/lib/rubocop/cop/dev_doc/rails/enum_column_not_null.rb +99 -0
- data/lib/rubocop/cop/dev_doc/rails/enum_must_be_symbolized.rb +2 -2
- data/lib/rubocop/cop/dev_doc/rails/no_block_predicate_on_relation.rb +236 -0
- data/lib/rubocop/cop/dev_doc/rails/strong_parameters_expect.rb +137 -0
- data/lib/rubocop/cop/dev_doc/route/no_custom_actions.rb +171 -0
- data/lib/rubocop/cop/dev_doc/route/resource_name_number.rb +77 -0
- data/lib/rubocop/cop/dev_doc/style/avoid_send.rb +31 -4
- data/lib/rubocop/cop/dev_doc/style/minimize_variable_scope.rb +158 -0
- data/lib/rubocop/cop/dev_doc/style/no_unscoped_method_definitions.rb +129 -0
- data/lib/rubocop/cop/dev_doc/style/repeated_bracket_read.rb +150 -0
- data/lib/rubocop/cop/dev_doc/style/repeated_safe_navigation_receiver.rb +118 -0
- data/lib/rubocop/cop/dev_doc/test/avoid_glib_travel_freeze.rb +53 -0
- data/lib/rubocop/cop/dev_doc/test/avoid_unit_test.rb +66 -0
- data/lib/rubocop/cop/dev_doc/test/response_assert_equal.rb +179 -0
- data/lib/rubocop/dev_doc/version.rb +1 -1
- metadata +58 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 163ac4a232d22f5d731e680d4ae882172570cdcf3085a07be7d6c3195223e365
|
|
4
|
+
data.tar.gz: a3eae8c77dcb707ddc4875be90255bea2fa33bcaeba370c7aff06436cd045661
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a605681c5f22058138abe3d8bdcd1e12eb94073f74e02fde30bc1f1df0baa538022b69fe33c4f83279cfaed995e60e5c9a4936de43cad7a89f07105c4b6e7a24
|
|
7
|
+
data.tar.gz: 0e845bcf2236245a8c4b0289a02d7731e12c9ac0023732f6135127f02f436c78f349012b98bd18127e89cdb4e70736597c2fc5313229ed3faaf572294e847168
|
data/config/default.yml
CHANGED
|
@@ -3,88 +3,121 @@
|
|
|
3
3
|
|
|
4
4
|
# Department-level settings: DocumentationBaseURL lets RuboCop construct per-cop
|
|
5
5
|
# URLs automatically. DocumentationExtension matches the generated file format.
|
|
6
|
+
DevDoc/Auth:
|
|
7
|
+
DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
|
|
8
|
+
DocumentationExtension: ".md"
|
|
9
|
+
|
|
6
10
|
DevDoc/Migration:
|
|
7
11
|
DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
|
|
8
|
-
DocumentationExtension:
|
|
12
|
+
DocumentationExtension: ".md"
|
|
9
13
|
|
|
10
14
|
DevDoc/Rails:
|
|
11
15
|
DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
|
|
12
|
-
DocumentationExtension:
|
|
16
|
+
DocumentationExtension: ".md"
|
|
13
17
|
|
|
14
18
|
DevDoc/Route:
|
|
15
19
|
DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
|
|
16
|
-
DocumentationExtension:
|
|
20
|
+
DocumentationExtension: ".md"
|
|
17
21
|
|
|
18
22
|
DevDoc/Style:
|
|
19
23
|
DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
|
|
20
|
-
DocumentationExtension:
|
|
24
|
+
DocumentationExtension: ".md"
|
|
25
|
+
|
|
26
|
+
DevDoc/Test:
|
|
27
|
+
DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
|
|
28
|
+
DocumentationExtension: ".md"
|
|
21
29
|
|
|
22
30
|
DevDoc/Migration/AvoidJsonColumn:
|
|
23
|
-
Description:
|
|
31
|
+
Description: "Use `jsonb` instead of `json` for column types."
|
|
24
32
|
Enabled: true
|
|
25
33
|
Include:
|
|
26
|
-
-
|
|
27
|
-
-
|
|
34
|
+
- "db/migrate/*.rb"
|
|
35
|
+
- "db/migrate/**/*.rb"
|
|
28
36
|
|
|
29
37
|
DevDoc/Migration/RequireTimestamps:
|
|
30
|
-
Description:
|
|
38
|
+
Description: "Always include `t.timestamps` in every `create_table` migration."
|
|
31
39
|
Enabled: false
|
|
32
40
|
Include:
|
|
33
|
-
-
|
|
34
|
-
-
|
|
41
|
+
- "db/migrate/*.rb"
|
|
42
|
+
- "db/migrate/**/*.rb"
|
|
35
43
|
|
|
36
44
|
DevDoc/Migration/PreferBelongsTo:
|
|
37
|
-
Description:
|
|
45
|
+
Description: "Use `t.belongs_to` instead of `t.references` for foreign keys."
|
|
38
46
|
Enabled: true
|
|
39
47
|
Include:
|
|
40
|
-
-
|
|
41
|
-
-
|
|
48
|
+
- "db/migrate/*.rb"
|
|
49
|
+
- "db/migrate/**/*.rb"
|
|
42
50
|
|
|
43
51
|
DevDoc/Migration/AvoidColumnDefault:
|
|
44
|
-
Description:
|
|
52
|
+
Description: "Avoid setting `default:` in migrations; keep business logic in the application layer."
|
|
45
53
|
Enabled: true
|
|
46
54
|
Include:
|
|
47
|
-
-
|
|
48
|
-
-
|
|
55
|
+
- "db/migrate/*.rb"
|
|
56
|
+
- "db/migrate/**/*.rb"
|
|
57
|
+
|
|
58
|
+
DevDoc/Migration/AvoidNonNull:
|
|
59
|
+
Description: "Avoid `null: false` on regular columns; keep presence rules in the application layer."
|
|
60
|
+
Enabled: true
|
|
61
|
+
Include:
|
|
62
|
+
- "db/migrate/*.rb"
|
|
63
|
+
- "db/migrate/**/*.rb"
|
|
49
64
|
|
|
50
65
|
# Intentionally global (no Include) — these patterns are risky in any file, not only migrations.
|
|
51
66
|
# Add project-specific Exclude entries (e.g. db/seeds.rb, lib/tasks/**/*.rb) in your .rubocop.yml
|
|
52
67
|
# for places where bulk operations are intentional and performance-critical.
|
|
53
68
|
DevDoc/Migration/AvoidBypassingValidation:
|
|
54
|
-
Description:
|
|
69
|
+
Description: "Avoid methods that bypass validations and callbacks (`update_column`, `update_all`, `insert_all`, etc.)."
|
|
55
70
|
Enabled: false
|
|
56
71
|
Exclude:
|
|
57
|
-
-
|
|
72
|
+
- "spec/**/*"
|
|
58
73
|
|
|
59
74
|
DevDoc/Migration/DateColumnNaming:
|
|
60
|
-
Description:
|
|
75
|
+
Description: "Date columns should end with `_on`; datetime columns should end with `_at`."
|
|
61
76
|
Enabled: true
|
|
62
77
|
Include:
|
|
63
|
-
-
|
|
64
|
-
-
|
|
78
|
+
- "db/migrate/*.rb"
|
|
79
|
+
- "db/migrate/**/*.rb"
|
|
65
80
|
|
|
66
81
|
DevDoc/Migration/AvoidVagueColumnNames:
|
|
67
|
-
Description:
|
|
82
|
+
Description: "Avoid vague column names like `status` or `group`. Use more specific names."
|
|
68
83
|
Enabled: true
|
|
69
84
|
VagueNames:
|
|
70
85
|
- status
|
|
71
86
|
- group
|
|
72
87
|
Include:
|
|
73
|
-
-
|
|
74
|
-
-
|
|
88
|
+
- "db/migrate/*.rb"
|
|
89
|
+
- "db/migrate/**/*.rb"
|
|
75
90
|
|
|
76
91
|
DevDoc/Route/ResourcesRequireOnly:
|
|
77
|
-
Description:
|
|
92
|
+
Description: "Always use `only:` or `except:` when defining `resources` or `resource` routes."
|
|
78
93
|
Enabled: true
|
|
79
94
|
# RequireOnly: true (default) — only `only:` is accepted; `except:` is flagged.
|
|
80
95
|
# RequireOnly: false — both `only:` and `except:` are accepted; only the bare form is flagged.
|
|
81
96
|
RequireOnly: true
|
|
82
97
|
Include:
|
|
83
|
-
-
|
|
84
|
-
-
|
|
98
|
+
- "config/routes.rb"
|
|
99
|
+
- "config/routes/**/*.rb"
|
|
100
|
+
|
|
101
|
+
DevDoc/Rails/BangSaveInTransaction:
|
|
102
|
+
Description: "Use bang (`save!`/`update!`/`create!`) inside a `transaction` block, or check the return value."
|
|
103
|
+
Enabled: true
|
|
104
|
+
|
|
105
|
+
DevDoc/Route/NoCustomActions:
|
|
106
|
+
Description: "Avoid custom `member`/`collection` actions; model them as RESTful sub-resources."
|
|
107
|
+
Enabled: true
|
|
108
|
+
Include:
|
|
109
|
+
- "config/routes.rb"
|
|
110
|
+
- "config/routes/**/*.rb"
|
|
111
|
+
|
|
112
|
+
DevDoc/Route/ResourceNameNumber:
|
|
113
|
+
Description: "Use a plural name for `resources` and a singular name for `resource`."
|
|
114
|
+
Enabled: true
|
|
115
|
+
Include:
|
|
116
|
+
- "config/routes.rb"
|
|
117
|
+
- "config/routes/**/*.rb"
|
|
85
118
|
|
|
86
119
|
DevDoc/Rails/NoDeliverLaterInTransaction:
|
|
87
|
-
Description:
|
|
120
|
+
Description: "Avoid `deliver_later`/`perform_later` inside a `transaction` block; the job may use stale data."
|
|
88
121
|
Enabled: true
|
|
89
122
|
KnownAsyncWrappers:
|
|
90
123
|
- send_verification_email!
|
|
@@ -93,26 +126,62 @@ DevDoc/Rails/NoDeliverLaterInTransaction:
|
|
|
93
126
|
- send_unlock_instructions
|
|
94
127
|
|
|
95
128
|
DevDoc/Rails/NoPerformLaterInModel:
|
|
96
|
-
Description:
|
|
129
|
+
Description: "Avoid `perform_later` inside model files; use explicit methods called from the controller."
|
|
97
130
|
Enabled: true
|
|
98
131
|
Include:
|
|
99
|
-
-
|
|
132
|
+
- "app/models/**/*.rb"
|
|
100
133
|
|
|
101
134
|
DevDoc/Rails/EnumMustBeSymbolized:
|
|
102
|
-
Description:
|
|
135
|
+
Description: "Pair every `enum :foo` with `enum_symbolize :foo` so the reader returns a symbol."
|
|
103
136
|
Enabled: true
|
|
104
137
|
Include:
|
|
105
|
-
-
|
|
138
|
+
- "app/models/**/*.rb"
|
|
139
|
+
|
|
140
|
+
DevDoc/Rails/EnumColumnNotNull:
|
|
141
|
+
Description: "Enum columns must be backed by a `null: false` database column."
|
|
142
|
+
Enabled: true
|
|
143
|
+
Include:
|
|
144
|
+
- "app/models/**/*.rb"
|
|
145
|
+
|
|
146
|
+
DevDoc/Rails/NoBlockPredicateOnRelation:
|
|
147
|
+
Description: "Avoid block-form `count`/`reject`/`select`/`find`/`any?` on AR relations; push the predicate into SQL with `.where(...)` or a scope."
|
|
148
|
+
Enabled: true
|
|
149
|
+
Exclude:
|
|
150
|
+
- "spec/**/*"
|
|
151
|
+
- "test/**/*"
|
|
152
|
+
- "db/seeds.rb"
|
|
153
|
+
- "db/seeds/**/*.rb"
|
|
154
|
+
- "lib/tasks/**/*.rb"
|
|
155
|
+
|
|
156
|
+
DevDoc/Style/NoUnscopedMethodDefinitions:
|
|
157
|
+
Description: "Define methods inside an explicit `module` or `class`; bare `def` outside a class/module body lands on `Object`."
|
|
158
|
+
Enabled: true
|
|
159
|
+
# SafeDSLReceivers: list of constant names whose `.new { }` blocks are safe
|
|
160
|
+
# (methods inside them do NOT land on Object). Struct, Class, Module are
|
|
161
|
+
# included by default.
|
|
162
|
+
SafeDSLReceivers: []
|
|
106
163
|
|
|
107
164
|
DevDoc/Style/AvoidSend:
|
|
108
|
-
Description:
|
|
165
|
+
Description: "Avoid `send`/`public_send` with an explicit receiver; prefer direct calls or safer alternatives."
|
|
166
|
+
Enabled: true
|
|
167
|
+
|
|
168
|
+
DevDoc/Style/RepeatedSafeNavigationReceiver:
|
|
169
|
+
Description: "Avoid using `&.` on the same receiver more than once in a method body — assign once and use `.` after."
|
|
170
|
+
Enabled: true
|
|
171
|
+
|
|
172
|
+
DevDoc/Style/RepeatedBracketRead:
|
|
173
|
+
Description: "Avoid reading `obj[key]` more than once with the same receiver and key in a method body — assign once and reuse."
|
|
174
|
+
Enabled: true
|
|
175
|
+
|
|
176
|
+
DevDoc/Style/MinimizeVariableScope:
|
|
177
|
+
Description: "Assign a variable inside the `if` condition that guards it, to keep its scope local to the branch."
|
|
109
178
|
Enabled: true
|
|
110
179
|
|
|
111
180
|
DevDoc/Style/AvoidHeadResponse:
|
|
112
|
-
Description:
|
|
181
|
+
Description: "Avoid `head()` with error statuses; delegate error handling to Rails exceptions or model validations."
|
|
113
182
|
Enabled: true
|
|
114
183
|
Include:
|
|
115
|
-
-
|
|
184
|
+
- "app/controllers/**/*.rb"
|
|
116
185
|
FlaggedStatuses:
|
|
117
186
|
- not_found
|
|
118
187
|
- unprocessable_entity
|
|
@@ -122,34 +191,41 @@ DevDoc/Style/AvoidHeadResponse:
|
|
|
122
191
|
- conflict
|
|
123
192
|
- gone
|
|
124
193
|
- method_not_allowed
|
|
125
|
-
-
|
|
126
|
-
-
|
|
127
|
-
-
|
|
128
|
-
-
|
|
129
|
-
-
|
|
130
|
-
-
|
|
131
|
-
-
|
|
132
|
-
-
|
|
194
|
+
- "404"
|
|
195
|
+
- "422"
|
|
196
|
+
- "403"
|
|
197
|
+
- "401"
|
|
198
|
+
- "400"
|
|
199
|
+
- "409"
|
|
200
|
+
- "410"
|
|
201
|
+
- "405"
|
|
202
|
+
|
|
203
|
+
DevDoc/Migration/AvoidConditionalSchemaChanges:
|
|
204
|
+
Description: "Avoid conditional schema helpers (`add_column_if_not_exists`, `column_exists?`, etc.) in migrations."
|
|
205
|
+
Enabled: true
|
|
206
|
+
Include:
|
|
207
|
+
- "db/migrate/*.rb"
|
|
208
|
+
- "db/migrate/**/*.rb"
|
|
133
209
|
|
|
134
210
|
DevDoc/Migration/RequirePrimaryKey:
|
|
135
|
-
Description:
|
|
211
|
+
Description: "Every `create_table` must have a primary key. Avoid `id: false`."
|
|
136
212
|
Enabled: true
|
|
137
213
|
Include:
|
|
138
|
-
-
|
|
139
|
-
-
|
|
214
|
+
- "db/migrate/*.rb"
|
|
215
|
+
- "db/migrate/**/*.rb"
|
|
140
216
|
|
|
141
217
|
DevDoc/Migration/NoCreateJoinTable:
|
|
142
|
-
Description:
|
|
218
|
+
Description: "Avoid `create_join_table` — define an explicit join model with `has_many :through` instead."
|
|
143
219
|
Enabled: true
|
|
144
220
|
Include:
|
|
145
|
-
-
|
|
146
|
-
-
|
|
221
|
+
- "db/migrate/*.rb"
|
|
222
|
+
- "db/migrate/**/*.rb"
|
|
147
223
|
|
|
148
224
|
# This cop is heuristic: it matches column names whose last segment is a known
|
|
149
225
|
# monetary word. Enable it in your project's .rubocop.yml and extend MonetaryNames
|
|
150
226
|
# if your domain uses different names. Disabled by default to avoid false positives.
|
|
151
227
|
DevDoc/Migration/AmountColumnInCents:
|
|
152
|
-
Description:
|
|
228
|
+
Description: "Monetary columns must be stored as integer cents with an `_in_cents` suffix."
|
|
153
229
|
Enabled: false
|
|
154
230
|
MonetaryNames:
|
|
155
231
|
- amount
|
|
@@ -162,36 +238,134 @@ DevDoc/Migration/AmountColumnInCents:
|
|
|
162
238
|
- discount
|
|
163
239
|
- tax
|
|
164
240
|
Include:
|
|
165
|
-
-
|
|
166
|
-
-
|
|
241
|
+
- "db/migrate/*.rb"
|
|
242
|
+
- "db/migrate/**/*.rb"
|
|
167
243
|
|
|
168
244
|
DevDoc/Rails/AvoidRailsCallbacks:
|
|
169
|
-
Description:
|
|
245
|
+
Description: "Avoid Rails callback DSL (`after_create`, `before_save`, etc.) — use explicit methods instead."
|
|
170
246
|
Enabled: true
|
|
171
247
|
Include:
|
|
172
|
-
-
|
|
248
|
+
- "app/models/**/*.rb"
|
|
173
249
|
|
|
174
250
|
DevDoc/Rails/ApplicationRecordTransaction:
|
|
175
|
-
Description:
|
|
251
|
+
Description: "Use `ApplicationRecord.transaction` instead of `SomeModel.transaction` outside model files."
|
|
176
252
|
Enabled: true
|
|
177
253
|
Exclude:
|
|
178
|
-
-
|
|
254
|
+
- "app/models/**/*.rb"
|
|
179
255
|
|
|
180
256
|
DevDoc/Style/AvoidOptionsHash:
|
|
181
|
-
Description:
|
|
257
|
+
Description: "Use keyword arguments instead of `**options` — typos raise `ArgumentError`; options hashes swallow them silently."
|
|
182
258
|
Enabled: true
|
|
183
259
|
|
|
184
260
|
DevDoc/Style/StringSymbolComparison:
|
|
185
|
-
Description:
|
|
261
|
+
Description: "Comparing a known-string source (params, request.headers, ENV) to a symbol literal is always false."
|
|
262
|
+
Enabled: true
|
|
263
|
+
|
|
264
|
+
DevDoc/Test/ResponseAssertEqual:
|
|
265
|
+
Description: "Controller tests that assert on `response.body` should also snapshot the full response with `response_assert_equal`."
|
|
266
|
+
# Enabled by default. A project adopting the gem with an existing backlog will
|
|
267
|
+
# see offenses immediately — fix them (preferred) or inline-`disable` the few
|
|
268
|
+
# that genuinely can't snapshot (non-JSON / non-deterministic responses).
|
|
186
269
|
Enabled: true
|
|
270
|
+
Include:
|
|
271
|
+
- "test/controllers/**/*_test.rb"
|
|
187
272
|
|
|
188
273
|
Rails/CreateTableWithTimestamps:
|
|
189
274
|
Enabled: true
|
|
190
275
|
Include:
|
|
191
|
-
-
|
|
192
|
-
-
|
|
276
|
+
- "db/migrate/*.rb"
|
|
277
|
+
- "db/migrate/**/*.rb"
|
|
193
278
|
|
|
194
279
|
Rails/SkipsModelValidations:
|
|
195
280
|
Enabled: true
|
|
196
281
|
Exclude:
|
|
197
|
-
-
|
|
282
|
+
- "spec/**/*"
|
|
283
|
+
|
|
284
|
+
# Upstream cop stays off — its scalar-form autocorrect produces false positives
|
|
285
|
+
# on optional query params (e.g. `params[:status]&.to_sym || :draft`).
|
|
286
|
+
# Our narrower replacement below flags only the hash-form rewrite.
|
|
287
|
+
Rails/StrongParametersExpect:
|
|
288
|
+
Enabled: false
|
|
289
|
+
|
|
290
|
+
# Narrower replacement for Rails/StrongParametersExpect — flags only the
|
|
291
|
+
# hash-form rewrite (`params.require(:foo).permit(...)` → `params.expect(foo: [...])`).
|
|
292
|
+
# Does not flag scalar `params[:foo]` in any context.
|
|
293
|
+
DevDoc/Rails/StrongParametersExpect:
|
|
294
|
+
Description: "Use `params.expect(foo: [...])` instead of `params.require(:foo).permit(...)`."
|
|
295
|
+
Enabled: true
|
|
296
|
+
Include:
|
|
297
|
+
- "app/controllers/**/*.rb"
|
|
298
|
+
|
|
299
|
+
# `save!` / `update!` raise on persistence failure, which is what
|
|
300
|
+
# we want in jobs/services/rake tasks — silent `false` returns
|
|
301
|
+
# hide bugs. Excluded for controllers, which lean on `save`
|
|
302
|
+
# returning false so `json_model_response` (and similar) can
|
|
303
|
+
# render the form with errors instead of crashing to 500.
|
|
304
|
+
Rails/SaveBang:
|
|
305
|
+
Enabled: true
|
|
306
|
+
Exclude:
|
|
307
|
+
- "app/controllers/**/*"
|
|
308
|
+
|
|
309
|
+
Style/MissingElse:
|
|
310
|
+
Enabled: true
|
|
311
|
+
EnforcedStyle: case
|
|
312
|
+
|
|
313
|
+
# Core default is `Max: 2`, which permits `a&.b&.c`. Tightened to `Max: 1`:
|
|
314
|
+
# in `a&.b&.c`, the second `&.` is ambiguous — the reader can't tell whether
|
|
315
|
+
# it's there because `b.c` can genuinely be nil on its own, or merely because
|
|
316
|
+
# the first `&.` already short-circuits the chain when `a` is nil. Splitting
|
|
317
|
+
# the chain (`if (b = a&.b); b.c; end`) makes each nullable source explicit.
|
|
318
|
+
# See best_practices/backend/en/01a_defensive_programming.md #4.
|
|
319
|
+
Style/SafeNavigationChainLength:
|
|
320
|
+
Enabled: true
|
|
321
|
+
Max: 1
|
|
322
|
+
|
|
323
|
+
# `has_X?` reads more naturally than the cop's preferred `X?` in many cases —
|
|
324
|
+
# `has_active_subscription?` vs `active_subscription?`, `has_assignee?(member)`
|
|
325
|
+
# vs `assignee?(member)`. Disabled cross-project so individual `.rubocop.yml`
|
|
326
|
+
# files don't have to repeat the same decision.
|
|
327
|
+
DevDoc/Test/AvoidGlibTravelFreeze:
|
|
328
|
+
Description: "Avoid `glib_travel_freeze` in test files — use `glib_travel` instead."
|
|
329
|
+
Enabled: true
|
|
330
|
+
Include:
|
|
331
|
+
- "test/**/*.rb"
|
|
332
|
+
- "spec/**/*.rb"
|
|
333
|
+
|
|
334
|
+
DevDoc/Test/AvoidUnitTest:
|
|
335
|
+
Description: "Prefer controller tests; unit tests (`< ActiveSupport::TestCase`) are a rare, justified exception."
|
|
336
|
+
Enabled: true
|
|
337
|
+
Include:
|
|
338
|
+
- "test/**/*.rb"
|
|
339
|
+
- "spec/**/*.rb"
|
|
340
|
+
|
|
341
|
+
Naming/PredicatePrefix:
|
|
342
|
+
Enabled: false
|
|
343
|
+
|
|
344
|
+
# Enforces that every `has_many` / `has_one` declares a `dependent:` option.
|
|
345
|
+
# Aligns with best_practices/backend/en/03_model.md #1 which prescribes
|
|
346
|
+
# `dependent: :restrict_with_exception` as the default.
|
|
347
|
+
Rails/HasManyOrHasOneDependent:
|
|
348
|
+
Enabled: true
|
|
349
|
+
|
|
350
|
+
DevDoc/Auth/LoadResourceCurrentUserGuard:
|
|
351
|
+
Description: "Require a `return unless current_user` (or `assert_current_user_present`) guard before using `current_user` inside `glib_load_resource`, and forbid `current_user&.`."
|
|
352
|
+
Enabled: true
|
|
353
|
+
# LoadResourceMethodNames: list of method names where the guard rule applies.
|
|
354
|
+
# Extend if your project uses a different lifecycle hook name.
|
|
355
|
+
LoadResourceMethodNames:
|
|
356
|
+
- glib_load_resource
|
|
357
|
+
# CurrentUserAssertionMethodNames: calls that raise when current_user is nil
|
|
358
|
+
# (e.g. glib's assert_current_user_present). A call to one before the first
|
|
359
|
+
# current_user use satisfies the guard. Add custom assertion helpers here.
|
|
360
|
+
CurrentUserAssertionMethodNames:
|
|
361
|
+
- assert_current_user_present
|
|
362
|
+
|
|
363
|
+
DevDoc/Auth/CurrentUserBranching:
|
|
364
|
+
Description: "Avoid branching on `current_user` / `user_signed_in?` in page-specific code. Use shared layouts or an inline disable with a reason for genuinely dual-state pages."
|
|
365
|
+
Enabled: true
|
|
366
|
+
Exclude:
|
|
367
|
+
- "app/policies/**/*.rb"
|
|
368
|
+
- "app/helpers/**/*.rb"
|
|
369
|
+
- "app/controllers/concerns/**/*.rb"
|
|
370
|
+
- "app/views/layouts/**/*"
|
|
371
|
+
- "app/controllers/application_controller.rb"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require_relative 'lints/cron_schedule'
|
|
2
|
+
require_relative 'lints/duplicate_snapshot'
|
|
3
|
+
require_relative 'lints/no_file_excludes'
|
|
4
|
+
|
|
5
|
+
module DevDoc
|
|
6
|
+
module Test
|
|
7
|
+
# Aggregator that pulls in every dev-doc best-practice lint as a set of
|
|
8
|
+
# Minitest `test_*` methods. Include this in a single test class in
|
|
9
|
+
# each project; new lints added here automatically apply to all
|
|
10
|
+
# consuming projects on the next `bundle update`.
|
|
11
|
+
#
|
|
12
|
+
# Per-project integration (one file, never needs editing):
|
|
13
|
+
#
|
|
14
|
+
# # test/linters/best_practice_lints_test.rb
|
|
15
|
+
# require 'dev_doc/test/best_practice_lints'
|
|
16
|
+
#
|
|
17
|
+
# class BestPracticeLintsTest < ActiveSupport::TestCase
|
|
18
|
+
# include DevDoc::Test::BestPracticeLints
|
|
19
|
+
# end
|
|
20
|
+
#
|
|
21
|
+
# To opt out of a specific lint in a project, redefine the offending
|
|
22
|
+
# `test_*` method in that test class as a `skip 'reason'`.
|
|
23
|
+
module BestPracticeLints
|
|
24
|
+
def self.included(base)
|
|
25
|
+
base.include Lints::CronSchedule
|
|
26
|
+
base.include Lints::DuplicateSnapshot
|
|
27
|
+
base.include Lints::NoFileExcludes
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|