rubocop-dev_doc 0.1.0 → 0.3.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.
- checksums.yaml +4 -4
- data/config/default.yml +318 -33
- 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 +230 -0
- data/lib/rubocop/cop/dev_doc/migration/amount_column_in_cents.rb +92 -0
- data/lib/rubocop/cop/dev_doc/migration/avoid_bypassing_validation.rb +86 -0
- data/lib/rubocop/cop/dev_doc/migration/avoid_column_default.rb +68 -13
- data/lib/rubocop/cop/dev_doc/migration/avoid_conditional_schema_changes.rb +89 -0
- data/lib/rubocop/cop/dev_doc/migration/avoid_json_column.rb +18 -3
- data/lib/rubocop/cop/dev_doc/migration/avoid_non_null.rb +121 -0
- data/lib/rubocop/cop/dev_doc/migration/no_create_join_table.rb +53 -0
- data/lib/rubocop/cop/dev_doc/migration/require_primary_key.rb +55 -0
- data/lib/rubocop/cop/dev_doc/migration/require_timestamps.rb +4 -13
- data/lib/rubocop/cop/dev_doc/rails/application_record_transaction.rb +56 -0
- data/lib/rubocop/cop/dev_doc/rails/avoid_rails_callbacks.rb +135 -0
- 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 +83 -0
- data/lib/rubocop/cop/dev_doc/rails/no_block_predicate_on_relation.rb +236 -0
- data/lib/rubocop/cop/dev_doc/rails/no_deliver_later_in_transaction.rb +22 -5
- 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/route/resources_require_only.rb +29 -15
- data/lib/rubocop/cop/dev_doc/style/avoid_head_response.rb +56 -22
- data/lib/rubocop/cop/dev_doc/style/avoid_options_hash.rb +102 -0
- data/lib/rubocop/cop/dev_doc/style/avoid_send.rb +42 -10
- 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/style/string_symbol_comparison.rb +91 -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
- data/lib/rubocop-dev_doc.rb +1 -0
- metadata +73 -10
- data/lib/rubocop/cop/dev_doc/migration/avoid_update_column.rb +0 -53
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cd15873d6ee53104760162aa0e5cced9dd69ef1297a70a014dd5643b9404703c
|
|
4
|
+
data.tar.gz: 25d0fa51436912d008625752269ff09ef93e78c14d6d1a941295c6afa47795b4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 516d5742aa468568e3884d779649164761f982391be0c5f7e5df474d64a933cf71148fe1fddb433c5cf1cd577debd7aadcb16bf22893963d721a3661a1f0fff0
|
|
7
|
+
data.tar.gz: 69a643cf2335d6c7bb365a4a2f8513e9a66d09a6cddb2bec5e44df861ebcb906de51d17fbbd1b591388c651c2f1cb662de5e5a887df7f11db3c9885e9d6ae597
|
data/config/default.yml
CHANGED
|
@@ -1,81 +1,366 @@
|
|
|
1
1
|
# Default configuration for rubocop-dev_doc cops.
|
|
2
|
-
# Cops are
|
|
2
|
+
# Cops are disabled by default; enable them in your project's .rubocop.yml.
|
|
3
|
+
|
|
4
|
+
# Department-level settings: DocumentationBaseURL lets RuboCop construct per-cop
|
|
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
|
+
|
|
10
|
+
DevDoc/Migration:
|
|
11
|
+
DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
|
|
12
|
+
DocumentationExtension: ".md"
|
|
13
|
+
|
|
14
|
+
DevDoc/Rails:
|
|
15
|
+
DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
|
|
16
|
+
DocumentationExtension: ".md"
|
|
17
|
+
|
|
18
|
+
DevDoc/Route:
|
|
19
|
+
DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
|
|
20
|
+
DocumentationExtension: ".md"
|
|
21
|
+
|
|
22
|
+
DevDoc/Style:
|
|
23
|
+
DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
|
|
24
|
+
DocumentationExtension: ".md"
|
|
25
|
+
|
|
26
|
+
DevDoc/Test:
|
|
27
|
+
DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
|
|
28
|
+
DocumentationExtension: ".md"
|
|
3
29
|
|
|
4
30
|
DevDoc/Migration/AvoidJsonColumn:
|
|
5
|
-
Description:
|
|
31
|
+
Description: "Use `jsonb` instead of `json` for column types."
|
|
6
32
|
Enabled: true
|
|
7
33
|
Include:
|
|
8
|
-
-
|
|
9
|
-
-
|
|
34
|
+
- "db/migrate/*.rb"
|
|
35
|
+
- "db/migrate/**/*.rb"
|
|
10
36
|
|
|
11
37
|
DevDoc/Migration/RequireTimestamps:
|
|
12
|
-
Description:
|
|
13
|
-
Enabled:
|
|
38
|
+
Description: "Always include `t.timestamps` in every `create_table` migration."
|
|
39
|
+
Enabled: false
|
|
14
40
|
Include:
|
|
15
|
-
-
|
|
16
|
-
-
|
|
41
|
+
- "db/migrate/*.rb"
|
|
42
|
+
- "db/migrate/**/*.rb"
|
|
17
43
|
|
|
18
44
|
DevDoc/Migration/PreferBelongsTo:
|
|
19
|
-
Description:
|
|
45
|
+
Description: "Use `t.belongs_to` instead of `t.references` for foreign keys."
|
|
20
46
|
Enabled: true
|
|
21
47
|
Include:
|
|
22
|
-
-
|
|
23
|
-
-
|
|
48
|
+
- "db/migrate/*.rb"
|
|
49
|
+
- "db/migrate/**/*.rb"
|
|
24
50
|
|
|
25
51
|
DevDoc/Migration/AvoidColumnDefault:
|
|
26
|
-
Description:
|
|
52
|
+
Description: "Avoid setting `default:` in migrations; keep business logic in the application layer."
|
|
27
53
|
Enabled: true
|
|
28
54
|
Include:
|
|
29
|
-
-
|
|
30
|
-
-
|
|
55
|
+
- "db/migrate/*.rb"
|
|
56
|
+
- "db/migrate/**/*.rb"
|
|
31
57
|
|
|
32
|
-
DevDoc/Migration/
|
|
33
|
-
Description:
|
|
58
|
+
DevDoc/Migration/AvoidNonNull:
|
|
59
|
+
Description: "Avoid `null: false` on regular columns; keep presence rules in the application layer."
|
|
34
60
|
Enabled: true
|
|
35
61
|
Include:
|
|
36
|
-
-
|
|
37
|
-
-
|
|
62
|
+
- "db/migrate/*.rb"
|
|
63
|
+
- "db/migrate/**/*.rb"
|
|
64
|
+
|
|
65
|
+
# Intentionally global (no Include) — these patterns are risky in any file, not only migrations.
|
|
66
|
+
# Add project-specific Exclude entries (e.g. db/seeds.rb, lib/tasks/**/*.rb) in your .rubocop.yml
|
|
67
|
+
# for places where bulk operations are intentional and performance-critical.
|
|
68
|
+
DevDoc/Migration/AvoidBypassingValidation:
|
|
69
|
+
Description: "Avoid methods that bypass validations and callbacks (`update_column`, `update_all`, `insert_all`, etc.)."
|
|
70
|
+
Enabled: false
|
|
71
|
+
Exclude:
|
|
72
|
+
- "spec/**/*"
|
|
38
73
|
|
|
39
74
|
DevDoc/Migration/DateColumnNaming:
|
|
40
|
-
Description:
|
|
75
|
+
Description: "Date columns should end with `_on`; datetime columns should end with `_at`."
|
|
41
76
|
Enabled: true
|
|
42
77
|
Include:
|
|
43
|
-
-
|
|
44
|
-
-
|
|
78
|
+
- "db/migrate/*.rb"
|
|
79
|
+
- "db/migrate/**/*.rb"
|
|
45
80
|
|
|
46
81
|
DevDoc/Migration/AvoidVagueColumnNames:
|
|
47
|
-
Description:
|
|
82
|
+
Description: "Avoid vague column names like `status` or `group`. Use more specific names."
|
|
48
83
|
Enabled: true
|
|
49
84
|
VagueNames:
|
|
50
85
|
- status
|
|
51
86
|
- group
|
|
52
87
|
Include:
|
|
53
|
-
-
|
|
54
|
-
-
|
|
88
|
+
- "db/migrate/*.rb"
|
|
89
|
+
- "db/migrate/**/*.rb"
|
|
55
90
|
|
|
56
91
|
DevDoc/Route/ResourcesRequireOnly:
|
|
57
|
-
Description:
|
|
92
|
+
Description: "Always use `only:` or `except:` when defining `resources` or `resource` routes."
|
|
58
93
|
Enabled: true
|
|
94
|
+
# RequireOnly: true (default) — only `only:` is accepted; `except:` is flagged.
|
|
95
|
+
# RequireOnly: false — both `only:` and `except:` are accepted; only the bare form is flagged.
|
|
96
|
+
RequireOnly: true
|
|
59
97
|
Include:
|
|
60
|
-
-
|
|
61
|
-
-
|
|
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"
|
|
62
118
|
|
|
63
119
|
DevDoc/Rails/NoDeliverLaterInTransaction:
|
|
64
|
-
Description:
|
|
120
|
+
Description: "Avoid `deliver_later`/`perform_later` inside a `transaction` block; the job may use stale data."
|
|
65
121
|
Enabled: true
|
|
122
|
+
KnownAsyncWrappers:
|
|
123
|
+
- send_verification_email!
|
|
124
|
+
- send_reset_password_instructions
|
|
125
|
+
- send_confirmation_instructions
|
|
126
|
+
- send_unlock_instructions
|
|
66
127
|
|
|
67
128
|
DevDoc/Rails/NoPerformLaterInModel:
|
|
68
|
-
Description:
|
|
129
|
+
Description: "Avoid `perform_later` inside model files; use explicit methods called from the controller."
|
|
130
|
+
Enabled: true
|
|
131
|
+
Include:
|
|
132
|
+
- "app/models/**/*.rb"
|
|
133
|
+
|
|
134
|
+
DevDoc/Rails/EnumMustBeSymbolized:
|
|
135
|
+
Description: "Pair every `enum :foo` with `enum_symbolize :foo` so the reader returns a symbol."
|
|
136
|
+
Enabled: true
|
|
137
|
+
Include:
|
|
138
|
+
- "app/models/**/*.rb"
|
|
139
|
+
|
|
140
|
+
DevDoc/Rails/EnumColumnNotNull:
|
|
141
|
+
Description: "Enum columns must be backed by a `null: false` database column."
|
|
69
142
|
Enabled: true
|
|
70
143
|
Include:
|
|
71
|
-
-
|
|
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: []
|
|
72
163
|
|
|
73
164
|
DevDoc/Style/AvoidSend:
|
|
74
|
-
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."
|
|
75
178
|
Enabled: true
|
|
76
179
|
|
|
77
180
|
DevDoc/Style/AvoidHeadResponse:
|
|
78
|
-
Description:
|
|
181
|
+
Description: "Avoid `head()` with error statuses; delegate error handling to Rails exceptions or model validations."
|
|
79
182
|
Enabled: true
|
|
80
183
|
Include:
|
|
81
|
-
-
|
|
184
|
+
- "app/controllers/**/*.rb"
|
|
185
|
+
FlaggedStatuses:
|
|
186
|
+
- not_found
|
|
187
|
+
- unprocessable_entity
|
|
188
|
+
- forbidden
|
|
189
|
+
- unauthorized
|
|
190
|
+
- bad_request
|
|
191
|
+
- conflict
|
|
192
|
+
- gone
|
|
193
|
+
- method_not_allowed
|
|
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"
|
|
209
|
+
|
|
210
|
+
DevDoc/Migration/RequirePrimaryKey:
|
|
211
|
+
Description: "Every `create_table` must have a primary key. Avoid `id: false`."
|
|
212
|
+
Enabled: true
|
|
213
|
+
Include:
|
|
214
|
+
- "db/migrate/*.rb"
|
|
215
|
+
- "db/migrate/**/*.rb"
|
|
216
|
+
|
|
217
|
+
DevDoc/Migration/NoCreateJoinTable:
|
|
218
|
+
Description: "Avoid `create_join_table` — define an explicit join model with `has_many :through` instead."
|
|
219
|
+
Enabled: true
|
|
220
|
+
Include:
|
|
221
|
+
- "db/migrate/*.rb"
|
|
222
|
+
- "db/migrate/**/*.rb"
|
|
223
|
+
|
|
224
|
+
# This cop is heuristic: it matches column names whose last segment is a known
|
|
225
|
+
# monetary word. Enable it in your project's .rubocop.yml and extend MonetaryNames
|
|
226
|
+
# if your domain uses different names. Disabled by default to avoid false positives.
|
|
227
|
+
DevDoc/Migration/AmountColumnInCents:
|
|
228
|
+
Description: "Monetary columns must be stored as integer cents with an `_in_cents` suffix."
|
|
229
|
+
Enabled: false
|
|
230
|
+
MonetaryNames:
|
|
231
|
+
- amount
|
|
232
|
+
- price
|
|
233
|
+
- balance
|
|
234
|
+
- cost
|
|
235
|
+
- fee
|
|
236
|
+
- total
|
|
237
|
+
- subtotal
|
|
238
|
+
- discount
|
|
239
|
+
- tax
|
|
240
|
+
Include:
|
|
241
|
+
- "db/migrate/*.rb"
|
|
242
|
+
- "db/migrate/**/*.rb"
|
|
243
|
+
|
|
244
|
+
DevDoc/Rails/AvoidRailsCallbacks:
|
|
245
|
+
Description: "Avoid Rails callback DSL (`after_create`, `before_save`, etc.) — use explicit methods instead."
|
|
246
|
+
Enabled: true
|
|
247
|
+
Include:
|
|
248
|
+
- "app/models/**/*.rb"
|
|
249
|
+
|
|
250
|
+
DevDoc/Rails/ApplicationRecordTransaction:
|
|
251
|
+
Description: "Use `ApplicationRecord.transaction` instead of `SomeModel.transaction` outside model files."
|
|
252
|
+
Enabled: true
|
|
253
|
+
Exclude:
|
|
254
|
+
- "app/models/**/*.rb"
|
|
255
|
+
|
|
256
|
+
DevDoc/Style/AvoidOptionsHash:
|
|
257
|
+
Description: "Use keyword arguments instead of `**options` — typos raise `ArgumentError`; options hashes swallow them silently."
|
|
258
|
+
Enabled: true
|
|
259
|
+
|
|
260
|
+
DevDoc/Style/StringSymbolComparison:
|
|
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).
|
|
269
|
+
Enabled: true
|
|
270
|
+
Include:
|
|
271
|
+
- "test/controllers/**/*_test.rb"
|
|
272
|
+
|
|
273
|
+
Rails/CreateTableWithTimestamps:
|
|
274
|
+
Enabled: true
|
|
275
|
+
Include:
|
|
276
|
+
- "db/migrate/*.rb"
|
|
277
|
+
- "db/migrate/**/*.rb"
|
|
278
|
+
|
|
279
|
+
Rails/SkipsModelValidations:
|
|
280
|
+
Enabled: true
|
|
281
|
+
Exclude:
|
|
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` 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
|
+
|
|
358
|
+
DevDoc/Auth/CurrentUserBranching:
|
|
359
|
+
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."
|
|
360
|
+
Enabled: true
|
|
361
|
+
Exclude:
|
|
362
|
+
- "app/policies/**/*.rb"
|
|
363
|
+
- "app/helpers/**/*.rb"
|
|
364
|
+
- "app/controllers/concerns/**/*.rb"
|
|
365
|
+
- "app/views/layouts/**/*"
|
|
366
|
+
- "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
|