rubocop-dev_doc 0.17.0 → 0.19.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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +461 -62
  3. data/config/obsoletion.yml +7 -3
  4. data/lib/dev_doc/i18n/pseudo_locale.rb +1 -1
  5. data/lib/dev_doc/i18n/tasks.rb +68 -0
  6. data/lib/dev_doc/railtie.rb +19 -0
  7. data/lib/dev_doc/test/lints/cross_tenant_canary_check.rb +1 -1
  8. data/lib/dev_doc/test/lints/cross_tenant_canary_sweep.rb +8 -3
  9. data/lib/dev_doc/test/lints/http_driven_controller_tests.rb +4 -0
  10. data/lib/dev_doc/test/lints/no_file_excludes.rb +1 -1
  11. data/lib/dev_doc/test/pseudo_i18n_crawler.rb +9 -0
  12. data/lib/rubocop/cop/dev_doc/auth/adjacent_justification.rb +44 -7
  13. data/lib/rubocop/cop/dev_doc/auth/load_resource_current_user_guard.rb +2 -2
  14. data/lib/rubocop/cop/dev_doc/auth/login_only_policy_justification.rb +1 -1
  15. data/lib/rubocop/cop/dev_doc/auth/unscoped_find_justification.rb +2 -2
  16. data/lib/rubocop/cop/dev_doc/bundler/conflicting_gem.rb +74 -0
  17. data/lib/rubocop/cop/dev_doc/exception_class_list.rb +32 -0
  18. data/lib/rubocop/cop/dev_doc/i18n/hardcoded_text.rb +243 -0
  19. data/lib/rubocop/cop/dev_doc/i18n/localizable_props.rb +69 -19
  20. data/lib/rubocop/cop/dev_doc/i18n/require_translation.rb +13 -17
  21. data/lib/rubocop/cop/dev_doc/i18n/text_shape.rb +94 -0
  22. data/lib/rubocop/cop/dev_doc/i18n/translation_key_prefix.rb +1 -1
  23. data/lib/rubocop/cop/dev_doc/migration/legacy_migration.rb +26 -0
  24. data/lib/rubocop/cop/dev_doc/migration/redundant_reference_index.rb +5 -15
  25. data/lib/rubocop/cop/dev_doc/migration/require_reference_index.rb +115 -0
  26. data/lib/rubocop/cop/dev_doc/rails/avoid_bypassing_validation.rb +81 -26
  27. data/lib/rubocop/cop/dev_doc/rails/avoid_lifecycle_method_override.rb +1 -1
  28. data/lib/rubocop/cop/dev_doc/rails/no_error_message_comparison.rb +178 -0
  29. data/lib/rubocop/cop/dev_doc/rails/no_errors_add_in_controller.rb +177 -0
  30. data/lib/rubocop/cop/dev_doc/rails/no_form_param_lookup_in_controller.rb +236 -0
  31. data/lib/rubocop/cop/dev_doc/style/avoid_kernel_array.rb +103 -0
  32. data/lib/rubocop/cop/dev_doc/style/in_memory_association_find.rb +162 -0
  33. data/lib/rubocop/cop/dev_doc/style/no_silent_rescue.rb +279 -0
  34. data/lib/rubocop/cop/dev_doc/style/no_unscoped_method_definitions.rb +1 -1
  35. data/lib/rubocop/cop/dev_doc/style/prefer_allowlist_symbol_param.rb +193 -0
  36. data/lib/rubocop/cop/dev_doc/style/rescue_justification.rb +330 -0
  37. data/lib/rubocop/cop/dev_doc/style/use_g_log.rb +133 -0
  38. data/lib/rubocop/cop/dev_doc/test/justification_covers.rb +216 -0
  39. data/lib/rubocop/cop/dev_doc/test/justification_header.rb +86 -5
  40. data/lib/rubocop/cop/dev_doc/test/prefer_find_sole_by.rb +146 -0
  41. data/lib/rubocop/cop/dev_doc/test/require_job_invocation_in_job_tests.rb +154 -0
  42. data/lib/rubocop/cop/dev_doc/test/require_unit_test_justification.rb +5 -24
  43. data/lib/rubocop/cop/dev_doc/test/test_file_placement.rb +30 -2
  44. data/lib/rubocop/cop/dev_doc/test/test_name_special_characters.rb +108 -0
  45. data/lib/rubocop/cop/dev_doc/view/prefer_prop_over_name.rb +11 -1
  46. data/lib/rubocop/dev_doc/version.rb +1 -1
  47. metadata +24 -4
  48. data/lib/rubocop/cop/dev_doc/i18n/report_text.rb +0 -76
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11175a594b0adb68ca20c3e2ff0ef414d1136d55152cd010a8d95ee26601a759
4
- data.tar.gz: 460f211f62e554bead8cd267a4c3e918159eccff748d2d03f0f06b56454d025e
3
+ metadata.gz: ff4f06f5a2bc2e22f493fdc53c810709df74c457ac08ce00b5db539a2947d74d
4
+ data.tar.gz: f709c72a76c989795d08156449a9ac166e44838f04217084c7bceb4da3072911
5
5
  SHA512:
6
- metadata.gz: 5b5a9ae0aed54ff1979d4deb8313ef53e0e8b3d831e9d3bbdabaf9c4d9c3897acd7486054cbd012222453c9e6dbcd0054821ea83ddac71c1231bc51d7be6072e
7
- data.tar.gz: e6acacc3e7f65769104c90d5043a08c6385983ab6c9f38db8088ff30193044ac1cd6e14b365c1cbf521de52d445b84e9c4312f75e2dcb6ab93370077a8134bed
6
+ metadata.gz: ce797e0cd5bda079b45274bb11c521055a65ff71dae446d9e293c1d838d2dde97563cfd13b677589bc79b3a550cc00b6943ff3b3e51311ca7c3ee5e5489d3565
7
+ data.tar.gz: fd06374240e731ac64d5be478e46ece5f8b3b86f4ebb7a114e980485db7b1d399a9c05e0737722325f65fba041bb63e20b40f35f018cbdf21501a98882c6c1a1
data/config/default.yml CHANGED
@@ -7,6 +7,10 @@ DevDoc/Auth:
7
7
  DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
8
8
  DocumentationExtension: ".md"
9
9
 
10
+ DevDoc/Bundler:
11
+ DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
12
+ DocumentationExtension: ".md"
13
+
10
14
  DevDoc/I18n:
11
15
  DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
12
16
  DocumentationExtension: ".md"
@@ -35,6 +39,26 @@ DevDoc/View:
35
39
  DocumentationBaseURL: https://github.com/hgani/dev-doc/blob/main/docs/cops
36
40
  DocumentationExtension: ".md"
37
41
 
42
+ DevDoc/Bundler/ConflictingGem:
43
+ Description: "Gems that duplicate a concern glib already provides (versioning, authorization, uploads, soft delete). Use the glib way instead."
44
+ Enabled: true
45
+ Include:
46
+ - "**/Gemfile"
47
+ - "**/gems.rb"
48
+ ConflictingGems:
49
+ paper_trail: "use Glib::SnapshotV2 (active_snapshot) for versioning and audit history."
50
+ audited: "use Glib::SnapshotV2 (active_snapshot) for versioning and audit history."
51
+ logidze: "use Glib::SnapshotV2 (active_snapshot) for versioning and audit history."
52
+ cancancan: "glib uses Pundit; write a policy."
53
+ action_policy: "glib uses Pundit; write a policy."
54
+ carrierwave: "use ActiveStorage; glib's file fields bind to attachments."
55
+ shrine: "use ActiveStorage; glib's file fields bind to attachments."
56
+ paperclip: "use ActiveStorage; glib's file fields bind to attachments."
57
+ kt-paperclip: "use ActiveStorage; glib's file fields bind to attachments."
58
+ paranoia: "soft deletion is project-specific; implement it in the model (see 01_basic.md item 7)."
59
+ acts_as_paranoid: "soft deletion is project-specific; implement it in the model (see 01_basic.md item 7)."
60
+ discard: "soft deletion is project-specific; implement it in the model (see 01_basic.md item 7)."
61
+
38
62
  DevDoc/Migration/AvoidJsonColumn:
39
63
  Description: "Use `jsonb` instead of `json` for column types."
40
64
  Enabled: true
@@ -199,6 +223,43 @@ DevDoc/Rails/NoCollectionIdsWriterInController:
199
223
  Include:
200
224
  - "app/controllers/**/*.rb"
201
225
 
226
+ # Route params are resource identity (a bad URL SHOULD 404), but a
227
+ # form-submitted attribute fed to a finder turns an expected form state
228
+ # (nothing picked yet) into RecordNotFound, and drags the validity check
229
+ # into the controller. The remedy is assignment: put the id on the model
230
+ # and let its validations render the failure.
231
+ DevDoc/Rails/NoFormParamLookupInController:
232
+ Description: "A record finder in a controller must not be fed by a form-submitted attribute (`params[:form][:attribute]`, `params.dig(:form, :attribute)`); assign the id to the model and let its validations decide."
233
+ Enabled: true
234
+ Include:
235
+ - "app/controllers/**/*.rb"
236
+
237
+ # The controller is the assignment bridge, not the validity judge: a
238
+ # controller-side `errors.add` is a validation living in the wrong layer,
239
+ # guarded once for one POST while every other write path skips it. The
240
+ # three delivery shapes (rescue, policy guard, verification bang) are
241
+ # auto-exempted — there the check already lives in the right layer and the
242
+ # line only renders its outcome.
243
+ DevDoc/Rails/NoErrorsAddInController:
244
+ Description: "Controllers must not write errors onto a model (`record.errors.add`); the rule belongs in a model validation or form-object PORO. Delivery of an outcome from a rescue, policy, or verification method is auto-exempted."
245
+ Enabled: true
246
+ Include:
247
+ - "app/controllers/**/*.rb"
248
+
249
+ # The text of an error message is written in two places — the `errors.add`
250
+ # that produces it and the branch that matches it — and only both copies
251
+ # staying identical keeps the branch alive; rewording, translating, or a
252
+ # second error silently breaks it. Add the error with a symbol type and
253
+ # branch on the type (`errors.of_kind?` / `errors.added?`), not the text.
254
+ # Measured over 13 consuming apps (one clone per origin, plus one non-glib
255
+ # Rails app): one offense, a true positive.
256
+ DevDoc/Rails/NoErrorMessageComparison:
257
+ Description: "Do not branch on the text of an ActiveModel error message (`errors.full_messages`, `errors[:attr]`, `errors.messages`, and their kin compared to a literal); add the error with a symbol type and check it with `errors.of_kind?` / `errors.added?`."
258
+ Enabled: true
259
+ Include:
260
+ - "app/**/*.rb"
261
+ - "app/**/*.jbuilder"
262
+
202
263
  DevDoc/Rails/EnumMustBeSymbolized:
203
264
  Description: "Declare enums with `enum_symbolize :foo, { … }` instead of a bare `enum`, so the attribute type is set before the enum and the reader returns a symbol."
204
265
  Enabled: true
@@ -240,6 +301,14 @@ DevDoc/Style/AvoidInsecureSend:
240
301
  Description: "Avoid insecure dynamic `send`/`public_send` — `send` is always flagged; `public_send` requires a prefix or trusted source (validator/mailer)."
241
302
  Enabled: true
242
303
 
304
+ DevDoc/Style/PreferAllowlistSymbolParam:
305
+ Description: "Flag a hand-rolled `find`/`detect` allow-list lookup against params/request.headers; use `glib_allowlist_symbol_param` instead."
306
+ Enabled: true
307
+
308
+ DevDoc/Style/InMemoryAssociationFind:
309
+ Description: "Flag block-form `find`/`detect` on an association declared in the same file; use `find_by` unless the in-memory view is required, or disable with a reason."
310
+ Enabled: true
311
+
243
312
  DevDoc/Style/PreferPublicSend:
244
313
  Description: "Prefer `public_send` over `send` — visibility-respecting dispatch surfaces typos/misconfig and documents intent."
245
314
  Enabled: true
@@ -328,11 +397,13 @@ DevDoc/Migration/NoBulkChangeTable:
328
397
  - "db/migrate/*.rb"
329
398
  - "db/migrate/**/*.rb"
330
399
 
331
- # The reference-options trio. Each of a reference's three options gets the
400
+ # The reference-option cops. Each of a reference's options gets the
332
401
  # enforcement shape its house position calls for:
333
402
  # - foreign_key: has one right value (constrain) -> enforce the VALUE.
334
403
  # - null: both values are legitimate -> enforce EXPLICITNESS (either passes).
335
- # - index: the default is already correct -> enforce SILENCE (flag redundancy).
404
+ # - index: the default is already correct -> enforce SILENCE (flag
405
+ # redundancy), and opting out is banned — every FK column carries its
406
+ # own index (see RequireReferenceIndex below for why).
336
407
  # Net effect: everything written on a reference line is a decision, everything
337
408
  # omitted is doctrine.
338
409
  DevDoc/Migration/RequireReferenceForeignKey:
@@ -342,6 +413,17 @@ DevDoc/Migration/RequireReferenceForeignKey:
342
413
  - "db/migrate/*.rb"
343
414
  - "db/migrate/**/*.rb"
344
415
 
416
+ # No autocorrect: removing `index: false` changes the migration's resulting
417
+ # schema (the index comes back), which is the developer's decision to make.
418
+ # Migration[4.2] classes are skipped (the default there is `index: false`, so
419
+ # the written option restates it rather than opting out).
420
+ DevDoc/Migration/RequireReferenceIndex:
421
+ Description: "References must not opt out of their default index (`index: false` is banned) — every FK column carries its own index."
422
+ Enabled: true
423
+ Include:
424
+ - "db/migrate/*.rb"
425
+ - "db/migrate/**/*.rb"
426
+
345
427
  DevDoc/Migration/ExplicitNullOnReference:
346
428
  Description: "References must state `null:` explicitly — optional and mandatory are both legitimate."
347
429
  Enabled: true
@@ -427,6 +509,22 @@ DevDoc/Style/AvoidSymbolizingBoundaryInput:
427
509
  Description: "Unvalidated `.to_sym` on params/request.headers lets any client value into the symbol domain; allow-list it (glib_allowlist_symbol_param) instead."
428
510
  Enabled: true
429
511
 
512
+ # Measured on one consuming app's app/ (2026-11-08: 21 hits in 1191 files —
513
+ # 17 drift/risky, 4 justified scalar-or-list inputs to keep via inline
514
+ # disables there) and on this repo's own lib (17 hits: 1 true positive
515
+ # converted to `|| []`, 16 genuine one-or-many shapes kept with inline
516
+ # disables — I18n scope args, mail recipients, persona tenant keys,
517
+ # cop-config values, an Exclude section). Tests are excluded because there `Array()` mostly
518
+ # walks rendered JSON output, where a silent coercion hides at worst a bad
519
+ # assertion, not data corruption (same Exclude shape as
520
+ # DevDoc/Rails/AvoidBypassingValidation).
521
+ DevDoc/Style/AvoidKernelArray:
522
+ Description: "Avoid `Array()` coercion; use `x || []` when nil is the only alternative. Do not enable stock Style/ArrayCoercion alongside."
523
+ Enabled: true
524
+ Exclude:
525
+ - "spec/**/*"
526
+ - "test/**/*"
527
+
430
528
  DevDoc/Style/LiteralOrInWhenClause:
431
529
  Description: "`||`/`&&` between literals in a `when` clause folds to one value — the other literal silently never matches; use comma-separated alternatives."
432
530
  Enabled: true
@@ -605,6 +703,29 @@ Style/SafeNavigationChainLength:
605
703
  Enabled: true
606
704
  Max: 1
607
705
 
706
+ # Early returns over nesting. Core default is already on; listed here because
707
+ # best_practices/backend/en/01a_defensive_programming.md #2 relies on it (the
708
+ # doc dropped its nested-vs-early-return example in favour of this cop and
709
+ # keeps only the guard-SHAPE guidance the cop cannot judge).
710
+ Style/GuardClause:
711
+ Enabled: true
712
+
713
+ # Core default is `MinNameLength: 1`, which never fires. Raised to 3 so a bare
714
+ # `|e|` / `|u|` / `|s|` block parameter is an offense — the reader should not
715
+ # have to infer the type from the receiver (see
716
+ # best_practices/intro/en/01_principle.md, Code Intent). The core AllowedNames
717
+ # for this cop is empty (the `at/by/id/…` list belongs to
718
+ # Naming/MethodParameterName); the one exemption here is `t`, the
719
+ # `create_table do |t|` idiom, which made up half of the hits when this was
720
+ # measured against a consuming app (2026-09-09: 87 offenses, 44 of them `|t|`
721
+ # in db/; the other 43 were real). AllowNamesEndingInNumbers stays at its core
722
+ # default (true), so `emp1` passes; `e1` still fails on length.
723
+ Naming/BlockParameterName:
724
+ Enabled: true
725
+ MinNameLength: 3
726
+ AllowedNames:
727
+ - t
728
+
608
729
  # `has_X?` reads more naturally than the cop's preferred `X?` in many cases —
609
730
  # `has_active_subscription?` vs `active_subscription?`, `has_assignee?(member)`
610
731
  # vs `assignee?(member)`. Disabled cross-project so individual `.rubocop.yml`
@@ -683,6 +804,22 @@ DevDoc/Test/RequireGlibIntegrationBase:
683
804
  - "test/mailers/**/*_test.rb"
684
805
  - "test/channels/**/*_test.rb"
685
806
 
807
+ # The entry-point check for the inbound-edge directory: a *Test class under
808
+ # test/jobs that never invokes the job (perform / perform_now / perform_later /
809
+ # perform_enqueued_jobs) is a service-flow test parked where the lints trust
810
+ # it — dispatch, guards and follow-up enqueues never run (observed 2026-10:
811
+ # ~18 integration-base cases in one consumer file drove a service .call and
812
+ # never the job). Same-file ancestor classes satisfy via their own bodies.
813
+ # The entry-point set lives in code, not here: config lists are droppable,
814
+ # code baselines are not. An enqueue-routing test whose trigger is not a
815
+ # job send (a request, a service call) takes an inline disable with a
816
+ # rationale.
817
+ DevDoc/Test/RequireJobInvocationInJobTests:
818
+ Description: "Every *Test class under test/jobs must invoke the job (perform/perform_now/perform_later/perform_enqueued_jobs) directly or via a same-file ancestor — a job test that drives a service instead never exercises dispatch, guards or follow-up enqueues."
819
+ Enabled: true
820
+ Include:
821
+ - "test/jobs/**/*_test.rb"
822
+
686
823
  # Previews render on every GET in development — persistence inside one mutates
687
824
  # the dev DB as a side effect of viewing an email. Also guards the preview
688
825
  # harness as a relocation target: mailer-body variants staged for snapshots
@@ -696,6 +833,40 @@ DevDoc/Test/NoPersistenceInMailerPreviews:
696
833
  - "spec/mailers/previews/**/*.rb"
697
834
  - "lib/mailer_previews/**/*.rb"
698
835
 
836
+ # A test name containing shell- or regex-significant characters breaks running
837
+ # that single test by name: unquoted `-n name` is mis-parsed by the shell
838
+ # (syntax error, redirect, expansion, substitution), and in the `/name/` regex
839
+ # filter form the regex-significant ones match nothing, so the runner reports
840
+ # 0 runs — which reads as a pass. Every character in the default set has a
841
+ # verified failure in at least one of the two forms (checked against a real
842
+ # minitest single-test run); `? { } / !` are deliberately NOT forbidden — see
843
+ # the cop docstring for their caveats. ForbiddenCharacters must list the same
844
+ # characters, in the same order, as the cop's DEFAULT_FORBIDDEN_CHARACTERS
845
+ # (specs enforce set parity; order keeps runtime messages matching specs).
846
+ DevDoc/Test/TestNameSpecialCharacters:
847
+ Description: "Test names must not contain characters that break single-test runs (shell mis-parse unquoted; `/name/` regex form runs 0 tests)."
848
+ Enabled: true
849
+ ForbiddenCharacters: "()[]*+^$\\&;|<>'\"`"
850
+ Include:
851
+ - "test/**/*.rb"
852
+ - "spec/**/*.rb"
853
+
854
+ # A bare-class `find_by` in a test returns whichever matching row the database
855
+ # yields first. When the attribute is not unique across the table (an email in
856
+ # a tenant-scoped membership table, a slug that repeats per country) the test
857
+ # binds to a different fixture per seed and fails far from the cause — the
858
+ # observed case reproduced only under one seed and read as a flake.
859
+ # `find_sole_by` raises unless exactly one row matches, turning the assumption
860
+ # into an assertion. `find_by!` autocorrects; `find_by` (nil-returning) does
861
+ # not, because a test may assert the nil — rewrite those to `exists?`.
862
+ # Requires Rails 7.0+ (`find_sole_by`); disable on older consumers.
863
+ DevDoc/Test/PreferFindSoleBy:
864
+ Description: "In tests, `Model.find_by`/`find_by!` on a bare class must be `find_sole_by` — an unscoped lookup by a non-unique attribute silently picks a row per run. Primary-key lookups and association-scoped receivers are not flagged."
865
+ Enabled: true
866
+ Include:
867
+ - "test/**/*.rb"
868
+ - "spec/**/*.rb"
869
+
699
870
  DevDoc/Test/RequireUnitTestJustification:
700
871
  Description: "Every test file must live in a recognized directory; unit-test directories additionally require a justification header (marker phrase: 'deliberate exception')."
701
872
  Enabled: true
@@ -763,6 +934,32 @@ DevDoc/Test/RequireUnitTestJustification:
763
934
  Include:
764
935
  - "test/**/*_test.rb"
765
936
 
937
+ DevDoc/Test/JustificationCovers:
938
+ Description: "A justification header must list the methods its claim covers (Covers: line), and every test in the file must call one of them."
939
+ Enabled: true
940
+ CoversPhrase: "covers:"
941
+ # The marker phrase gates this cop: files without it are
942
+ # RequireUnitTestJustification's to report — this cop never double-reports
943
+ # a missing header.
944
+ MarkerPhrase: "deliberate exception"
945
+ # Applicability is the shared justification_header_required? predicate
946
+ # (in the cops' TestFilePlacement module), which reads the base and
947
+ # directory keys below — mirror them from
948
+ # DevDoc/Test/RequireUnitTestJustification and keep the two entries in
949
+ # sync, or the cops police different file sets.
950
+ NonHttpBaseClasses:
951
+ - Glib::NonHttpIntegrationTest
952
+ UnitTestDirectories:
953
+ - models
954
+ - services
955
+ - helpers
956
+ NonHttpDirectories:
957
+ - jobs
958
+ - mailers
959
+ - channels
960
+ Include:
961
+ - "test/**/*_test.rb"
962
+
766
963
  Naming/PredicatePrefix:
767
964
  Enabled: false
768
965
 
@@ -915,6 +1112,159 @@ DevDoc/I18n/AvoidTitleizeHumanize:
915
1112
  - "app/views/**/*.jbuilder"
916
1113
  - "app/views/**/*.rb"
917
1114
 
1115
+ DevDoc/I18n/HardcodedText:
1116
+ Description: "Warn on any string literal that reads like user-facing copy, in any position — not only glib text props. Use `t(...)`."
1117
+ # A review aid, not a clean lint: it judges strings by shape (prose vs
1118
+ # identifier) and position, so it cannot tell copy a user sees from prose
1119
+ # that never leaves the server. Off by default and `warning` severity; run
1120
+ # it during a localization pass alongside RequireTranslation, which is
1121
+ # precise for glib props but blind to ternary/`||` fallbacks, hashes built in
1122
+ # locals, controller/model/mailer strings and constants.
1123
+ Enabled: false
1124
+ Severity: warning
1125
+ # ExemptKeys: hash keys whose values are never copy (style, routing, model
1126
+ # metadata, i18n plumbing). Every value under them is skipped.
1127
+ ExemptKeys:
1128
+ - styleClass
1129
+ - styleClasses
1130
+ - style
1131
+ - class
1132
+ - id
1133
+ - targetId
1134
+ - name
1135
+ - url
1136
+ - href
1137
+ - src
1138
+ - path
1139
+ - partial
1140
+ - template
1141
+ - layout
1142
+ - controller
1143
+ - action
1144
+ - as
1145
+ - format
1146
+ - content_type
1147
+ - mime_type
1148
+ - accept
1149
+ - class_name
1150
+ - source_type
1151
+ - foreign_key
1152
+ - primary_key
1153
+ - table_name
1154
+ - inverse_of
1155
+ - scope
1156
+ - locale
1157
+ # ExemptMethods: string receivers and direct arguments of these are
1158
+ # patterns, SQL, lookup keys or formats rather than copy.
1159
+ ExemptMethods:
1160
+ - "where"
1161
+ - "rewhere"
1162
+ - "not"
1163
+ - "or"
1164
+ - "having"
1165
+ - "order"
1166
+ - "reorder"
1167
+ - "group"
1168
+ - "select"
1169
+ - "joins"
1170
+ - "left_joins"
1171
+ - "from"
1172
+ - "pluck"
1173
+ - "pick"
1174
+ - "find_by_sql"
1175
+ - "count_by_sql"
1176
+ - "exec_query"
1177
+ - "execute"
1178
+ - "sql"
1179
+ - "sanitize_sql"
1180
+ - "sanitize_sql_array"
1181
+ - "sanitize_sql_for_conditions"
1182
+ - "=="
1183
+ - "!="
1184
+ - "==="
1185
+ - "eql?"
1186
+ - "equal?"
1187
+ - "=~"
1188
+ - "!~"
1189
+ - "include?"
1190
+ - "in?"
1191
+ - "start_with?"
1192
+ - "end_with?"
1193
+ - "match?"
1194
+ - "match"
1195
+ - "casecmp"
1196
+ - "casecmp?"
1197
+ - "gsub"
1198
+ - "gsub!"
1199
+ - "sub"
1200
+ - "sub!"
1201
+ - "tr"
1202
+ - "tr_s"
1203
+ - "delete"
1204
+ - "delete_prefix"
1205
+ - "delete_suffix"
1206
+ - "split"
1207
+ - "squeeze"
1208
+ - "partition"
1209
+ - "rpartition"
1210
+ - "[]"
1211
+ - "[]="
1212
+ - "dig"
1213
+ - "fetch"
1214
+ - "key?"
1215
+ - "has_key?"
1216
+ - "slice"
1217
+ - "except"
1218
+ - "values_at"
1219
+ - "fetch_values"
1220
+ - "send"
1221
+ - "public_send"
1222
+ - "__send__"
1223
+ - "respond_to?"
1224
+ - "const_get"
1225
+ - "const_defined?"
1226
+ - "instance_variable_get"
1227
+ - "instance_variable_set"
1228
+ - "attribute"
1229
+ - "require"
1230
+ - "require_relative"
1231
+ - "load"
1232
+ - "autoload"
1233
+ - "strftime"
1234
+ - "strptime"
1235
+ - "parse"
1236
+ - "header"
1237
+ - "set_header"
1238
+ - "add_header"
1239
+ - "image_url"
1240
+ - "image_path"
1241
+ - "image_tag"
1242
+ - "asset_url"
1243
+ - "asset_path"
1244
+ # DeveloperFacingMethods: receiver-less calls whose whole subtree is
1245
+ # developer-facing (exception and console text). `logger.*` calls are
1246
+ # always skipped.
1247
+ DeveloperFacingMethods:
1248
+ - raise
1249
+ - fail
1250
+ - warn
1251
+ - abort
1252
+ - puts
1253
+ - print
1254
+ - p
1255
+ - pp
1256
+ # DeveloperFacingReceivers: constants whose every call reports to developers
1257
+ # (error trackers), so string arguments to them are never copy.
1258
+ DeveloperFacingReceivers:
1259
+ - Rollbar
1260
+ - Sentry
1261
+ - Honeybadger
1262
+ - Bugsnag
1263
+ - Airbrake
1264
+ Include:
1265
+ - "app/**/*.rb"
1266
+ - "app/**/*.jbuilder"
1267
+
918
1268
  DevDoc/View/PreferPropOverName:
919
1269
  Description: "Bind form fields to model attributes with `prop:` (i18n-resolved label/placeholder) instead of a raw `name: 'model[attr]'` with hardcoded text."
920
1270
  # Disabled by default (new department) — enable per consumer .rubocop.yml.
@@ -929,10 +1279,17 @@ DevDoc/View/PreferPropOverName:
929
1279
  # credit-card fields capture transient credentials that must never bind to
930
1280
  # a persisted model, and dynamic-group names are array-param structural keys
931
1281
  # with no label/placeholder to derive.
1282
+ # fields_file (deprecated field class) posts a raw upload the controller
1283
+ # often parses and discards (CSV imports, server-side processing) — its
1284
+ # prop: machinery calls `.attached?` on the bound model value, so a
1285
+ # conversion of a non-attachment param raises at render and the unsafe
1286
+ # autocorrect would produce exactly that. Attachment-backed uploads belong
1287
+ # on fields_upload, which binds prop: fine.
932
1288
  ExemptFieldMethods:
933
1289
  - fields_hidden
934
1290
  - fields_creditCard
935
1291
  - fields_dynamicGroup
1292
+ - fields_file
936
1293
  Include:
937
1294
  - "app/views/**/*.jbuilder"
938
1295
  - "app/views/**/*.rb"
@@ -961,17 +1318,35 @@ DevDoc/I18n/RequireTranslation:
961
1318
  - shareButton
962
1319
  - fields_text
963
1320
  - fields_number
964
- - fields_select
1321
+ - fields_email
1322
+ - fields_url
965
1323
  - fields_password
1324
+ - fields_timer
1325
+ - fields_submit
966
1326
  - fields_textarea
1327
+ - fields_richText
1328
+ - fields_select
1329
+ - fields_dynamicSelect
1330
+ - fields_dynamicGroup
967
1331
  - fields_check
968
1332
  - fields_checkGroup
969
1333
  - fields_chipGroup
970
- - fields_timeZone
1334
+ - fields_radio
971
1335
  - fields_radioGroup
1336
+ - fields_timeZone
972
1337
  - fields_date
973
1338
  - fields_datetime
1339
+ - fields_file
974
1340
  - fields_upload
1341
+ - fields_sign
1342
+ - fields_location
1343
+ - fields_phone
1344
+ - fields_otp
1345
+ - fields_captcha
1346
+ - fields_rating
1347
+ - fields_creditCard
1348
+ - fields_stripeToken
1349
+ - fields_stripeExternalAccount
975
1350
  - dialogs_alert
976
1351
  - dialogs_notification
977
1352
  - snackbars_alert
@@ -984,6 +1359,7 @@ DevDoc/I18n/RequireTranslation:
984
1359
  - subsubtitle
985
1360
  - label
986
1361
  - placeholder
1362
+ - hint
987
1363
  - text
988
1364
  - message
989
1365
  - description
@@ -1021,62 +1397,85 @@ DevDoc/Rails/NoManualRecordInvalid:
1021
1397
  Include:
1022
1398
  - "app/models/**/*.rb"
1023
1399
 
1024
- DevDoc/I18n/ReportText:
1025
- Description: "Report every user-facing glib text prop — hardcoded and already-localized — to collect all possible texts."
1026
- # A tooling aid, not a lint: unlike RequireTranslation it fires on *every*
1027
- # text value (including `t(...)` calls) so you can sweep the codebase and
1028
- # collect the full list of user-facing strings. Off by default and `info`
1029
- # severity. Mirrors RequireTranslation's WatchedMethods/LocalizableKeys.
1030
- Enabled: false
1031
- Severity: info
1032
- WatchedMethods:
1033
- - h1
1034
- - h2
1035
- - h3
1036
- - h4
1037
- - h5
1038
- - h6
1039
- - p
1040
- - label
1041
- - markdown
1042
- - html
1043
- - button
1044
- - switch
1045
- - chip
1046
- - progressCircle
1047
- - shareButton
1048
- - fields_text
1049
- - fields_number
1050
- - fields_select
1051
- - fields_password
1052
- - fields_textarea
1053
- - fields_check
1054
- - fields_checkGroup
1055
- - fields_chipGroup
1056
- - fields_timeZone
1057
- - fields_radioGroup
1058
- - fields_date
1059
- - fields_datetime
1060
- - fields_upload
1061
- - dialogs_alert
1062
- - dialogs_notification
1063
- - snackbars_alert
1064
- - snackbars_select
1065
- - banners_alert
1066
- - banners_select
1067
- LocalizableKeys:
1068
- - title
1069
- - subtitle
1070
- - subsubtitle
1071
- - label
1072
- - placeholder
1073
- - text
1074
- - message
1075
- - description
1076
- - uploadText
1077
- - leftText
1078
- - rightText
1079
- - onLabel
1400
+ # Strict superset of Lint/SuppressedException at its default settings — disable
1401
+ # the stock cop when enabling this one (see the cop docstring). Modifier
1402
+ # rescues stay out of scope: Style/RescueModifier owns them.
1403
+ DevDoc/Style/NoSilentRescue:
1404
+ Description: "A rescue body must re-raise, report the failure (a logger/error-monitor call), or state a justification — never swallow it silently."
1405
+ Enabled: true
1080
1406
  Include:
1081
- - "app/views/**/*.jbuilder"
1082
- - "app/views/**/*.rb"
1407
+ - "app/**/*.rb"
1408
+ - "lib/**/*.rb"
1409
+ JustificationMarker: "silent-rescue:"
1410
+ ReportingMethods:
1411
+ - "log"
1412
+ - "warn"
1413
+ - "error"
1414
+ - "errors"
1415
+ - "exception"
1416
+ - "fatal"
1417
+ - "critical"
1418
+ - "notify"
1419
+ - "notice"
1420
+ - "report"
1421
+ - "capture"
1422
+ - "track"
1423
+ - "instrument"
1424
+ - "monitor"
1425
+ - "alert"
1426
+ - "breadcrumb"
1427
+ - "handle"
1428
+ # A clause rescuing only these is an expected outcome (a lost race), not a
1429
+ # swallowed failure, and may stay silent. I/O failures are not here: they
1430
+ # are still failures and must be reported.
1431
+ ExpectedOutcomeClasses:
1432
+ - "ActiveRecord::RecordNotUnique"
1433
+ - "ActiveRecord::Deadlocked"
1434
+ - "ActiveRecord::LockWaitTimeout"
1435
+ - "ActiveRecord::StaleObjectError"
1436
+ - "ActiveRecord::SerializationFailure"
1437
+
1438
+ DevDoc/Style/RescueJustification:
1439
+ Description: "Every rescue clause either rescues only failures no validator can prevent (races, I/O), propagates, or states its reason in a `rescue-reason: <category>: <why>` comment."
1440
+ Enabled: true
1441
+ Include:
1442
+ - "app/**/*.rb"
1443
+ - "lib/**/*.rb"
1444
+ JustificationMarker: "rescue-reason:"
1445
+ # Failures no validator of ours can prevent. A trailing `::` matches a namespace.
1446
+ ExpectedErrorClasses:
1447
+ # concurrency verdicts — validation is point-in-time, the constraint is the check
1448
+ - "ActiveRecord::RecordNotUnique"
1449
+ - "ActiveRecord::Deadlocked"
1450
+ - "ActiveRecord::LockWaitTimeout"
1451
+ - "ActiveRecord::StaleObjectError"
1452
+ - "ActiveRecord::SerializationFailure"
1453
+ # I/O to another system
1454
+ - "ActiveRecord::ConnectionNotEstablished"
1455
+ - "ActiveRecord::NoDatabaseError"
1456
+ - "ActiveRecord::ConnectionTimeoutError"
1457
+ - "Errno::"
1458
+ - "Net::"
1459
+ - "Timeout::Error"
1460
+ - "IOError"
1461
+ - "EOFError"
1462
+ - "SocketError"
1463
+ - "OpenSSL::SSL::SSLError"
1464
+ Categories:
1465
+ bulkhead:
1466
+ Meaning: "one failure unit of a batch or async sweep must not abort the rest; one per unit of work, reported"
1467
+ side-effect:
1468
+ Meaning: "a secondary effect that must not fail the primary action it rides on"
1469
+ degrade:
1470
+ Meaning: "a user-facing path that degrades to a fallback and reports (01a item 5)"
1471
+ boundary-parse:
1472
+ Meaning: "untrusted external input parsed here; the parse is the validation"
1473
+ surface:
1474
+ Meaning: "a non-bang wrapper turning a bang method's exception into the contract's failure channel (false + errors)"
1475
+ delivery:
1476
+ Meaning: "a controller rendering a domain error raised below it"
1477
+ Path: "app/controllers/"
1478
+
1479
+ DevDoc/Style/UseGLog:
1480
+ Description: "Route logging through GLog (glib-web) — flag Rails.logger.<any> and Rollbar's reporting methods (error/warning/info/debug/critical/log) outside the facade; Rollbar.configure and other setup calls are not reporting."
1481
+ Enabled: true
@@ -1,5 +1,9 @@
1
- # Cop renames across rubocop-dev_doc versions. RuboCop surfaces these as
2
- # actionable "has been renamed" errors when a project's config or inline
3
- # directives use the old name.
1
+ # Cop renames and removals across rubocop-dev_doc versions. RuboCop surfaces
2
+ # these as actionable "has been renamed"/"has been removed" errors when a
3
+ # project's config or inline directives use the old name.
4
4
  renamed:
5
5
  DevDoc/Migration/AvoidBypassingValidation: DevDoc/Rails/AvoidBypassingValidation
6
+
7
+ removed:
8
+ DevDoc/I18n/ReportText:
9
+ alternatives: DevDoc/I18n/HardcodedText
@@ -142,7 +142,7 @@ module DevDoc
142
142
  private
143
143
 
144
144
  def skip?(key, scope)
145
- head = Array(scope).first || key.to_s[/\A[^.]+/]
145
+ head = Array(scope).first || key.to_s[/\A[^.]+/] # rubocop:disable DevDoc/Style/AvoidKernelArray -- I18n's scope arg is one key or a key list by API contract
146
146
  SKIP_NAMESPACES.include?(head.to_s)
147
147
  end
148
148