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
@@ -135,7 +135,6 @@ module RuboCop
135
135
 
136
136
  FORBIDDEN_BASES = %w[ActionDispatch::IntegrationTest Glib::IntegrationTest].freeze
137
137
  EXEMPT_DIRS = %w[controllers integration jobs mailers channels system linters tasks].freeze
138
- NON_HTTP_DIRS = %w[jobs mailers channels].freeze
139
138
 
140
139
  def on_new_investigation
141
140
  return if processed_source.blank?
@@ -149,11 +148,11 @@ module RuboCop
149
148
  private
150
149
 
151
150
  def enforce_directory_rules(dir)
151
+ check_justification if justification_header_required?
152
+
152
153
  if exempt_directories.include?(dir)
153
154
  check_confined_bases(dir)
154
- check_justification if non_http_base_in_non_http_dir?(dir)
155
155
  elsif unit_test_directories.include?(dir)
156
- check_justification
157
156
  check_base_classes
158
157
  check_confined_bases(dir)
159
158
  else
@@ -161,13 +160,6 @@ module RuboCop
161
160
  end
162
161
  end
163
162
 
164
- # Landing on the non-HTTP side-effect base is a conscious exception
165
- # too (the class opted out of HTTP inside an integration-shaped
166
- # home), so it carries the same header contract as a unit directory.
167
- def non_http_base_in_non_http_dir?(dir)
168
- non_http_directories.include?(dir) && class_with_base?(non_http_base_classes)
169
- end
170
-
171
163
  # A justified unit test must also DECLARE itself truthfully. Two
172
164
  # tiers: integration bases get the tailored lie-about-type message;
173
165
  # any other base outside UnitBaseClasses (e.g. plain
@@ -221,26 +213,15 @@ module RuboCop
221
213
 
222
214
  def unit_base_classes = cop_config.fetch('UnitBaseClasses', %w[Glib::LastResortUnitTest])
223
215
 
224
- def non_http_base_classes = cop_config.fetch('NonHttpBaseClasses', %w[Glib::NonHttpIntegrationTest])
225
-
226
216
  def require_unit_base? = cop_config.fetch('RequireUnitBase', true)
227
217
 
228
- def unit_test_directories = cop_config.fetch('UnitTestDirectories', %w[models services helpers])
229
-
230
- def non_http_directories = cop_config.fetch('NonHttpDirectories', NON_HTTP_DIRS)
231
-
232
218
  def exempt_directories = cop_config.fetch('ExemptDirectories', EXEMPT_DIRS)
233
219
 
234
- def known_directories = (exempt_directories + unit_test_directories).map { |d| "test/#{d}/" }.join(', ')
220
+ def known_directories = (exempt_directories + unit_test_directories).map { |dir| "test/#{dir}/" }.join(', ')
235
221
 
236
- def unit_directories_list = unit_test_directories.map { |d| "test/#{d}/" }.join(', ')
222
+ def unit_directories_list = unit_test_directories.map { |dir| "test/#{dir}/" }.join(', ')
237
223
 
238
- def non_http_directories_list = non_http_directories.map { |d| "test/#{d}/" }.join(', ')
239
-
240
- def offense_range
241
- range = processed_source.ast&.source_range || processed_source.comments.first&.source_range
242
- range.with(end_pos: range.begin_pos + [range.source_line.length, 1].max)
243
- end
224
+ def non_http_directories_list = non_http_directories.map { |dir| "test/#{dir}/" }.join(', ')
244
225
  end
245
226
  end
246
227
  end
@@ -3,9 +3,13 @@ module RuboCop
3
3
  module DevDoc
4
4
  module Test
5
5
  # Helpers shared by test-placement cops: classifying which test/
6
- # subdirectory a file belongs to, and scanning its classes for base
7
- # classes that placement rules key on.
6
+ # subdirectory a file belongs to, scanning its classes for base
7
+ # classes that placement rules key on, and the shared
8
+ # justification-header applicability predicate (which files require
9
+ # a header at all).
8
10
  module TestFilePlacement
11
+ NON_HTTP_DIRS = %w[jobs mailers channels].freeze
12
+
9
13
  private
10
14
 
11
15
  # First path segment after the (last) `test/` component; nil when the
@@ -67,6 +71,30 @@ module RuboCop
67
71
  each_class_with_base(bases) { |_superclass, _base| found = true }
68
72
  found
69
73
  end
74
+
75
+ # Config keys the applicability predicate below reads. The header
76
+ # cops mirror these keys in their config entries; keep them in
77
+ # sync or the cops police different file sets.
78
+ def unit_test_directories = cop_config.fetch('UnitTestDirectories', %w[models services helpers])
79
+
80
+ def non_http_directories = cop_config.fetch('NonHttpDirectories', NON_HTTP_DIRS)
81
+
82
+ def non_http_base_classes = cop_config.fetch('NonHttpBaseClasses', %w[Glib::NonHttpIntegrationTest])
83
+
84
+ # Exactly the files whose justification header
85
+ # RequireUnitTestJustification polices: every file in a unit-test
86
+ # directory, plus a non-HTTP-base class inside its own directories
87
+ # (landing on the side-effect base is a conscious opt-out of HTTP,
88
+ # so it carries the same header contract as a unit directory).
89
+ # Header piggyback cops (JustificationCovers) run on this same set
90
+ # so their rules fire exactly where a header can exist.
91
+ def justification_header_required?
92
+ dir = test_subdirectory
93
+ return false if dir.nil?
94
+
95
+ unit_test_directories.include?(dir) ||
96
+ (non_http_directories.include?(dir) && class_with_base?(non_http_base_classes))
97
+ end
70
98
  end
71
99
  end
72
100
  end
@@ -0,0 +1,108 @@
1
+ module RuboCop
2
+ module Cop
3
+ module DevDoc
4
+ module Test
5
+ # Disallows characters in `test '...'` names that break running that
6
+ # single test by name. Rails derives the method name from the
7
+ # description almost verbatim (only whitespace becomes `_`), so every
8
+ # other character lands in the name a developer or agent must type to
9
+ # run one test:
10
+ #
11
+ # bin/rails test test/models/user_test.rb -n test_creates_(admin)_user
12
+ # bin/rails test test/models/user_test.rb -n /test_creates_[admin]_user/
13
+ #
14
+ # ## Rationale
15
+ # Both spellings of the `-n`/`--name` filter fail on such names, and
16
+ # every character in the default set has a VERIFIED failure in at
17
+ # least one of the two forms (checked against a real minitest
18
+ # single-test run, not reasoned about):
19
+ #
20
+ # 1. **Unquoted, the shell mis-parses the filter before the runner
21
+ # sees it.** `(`, `)`, `;`, `&`, `|`, `<`, `>`, `'`, `"`, `` ` ``,
22
+ # `$`, and `\` are shell grammar: a parenthesised name dies with
23
+ # `syntax error near unexpected token '('`; `<`/`>` silently
24
+ # redirect and pass the runner an empty filter; `$` expands;
25
+ # backtick substitutes. The test is never invoked.
26
+ # 2. **The `/name/` regex filter matches nothing.** The usual workaround
27
+ # for (1) — wrapping the name in slashes — makes the runner treat the
28
+ # string as an unanchored regex, so `[admin]` becomes a character
29
+ # class, `?`/`*`/`+` become quantifiers, `^`/`$` anchor, `(...)`
30
+ # groups. The result is `Nothing ran for filter`, `0 runs, 0
31
+ # failures` — output that reads as a pass while zero tests
32
+ # executed. Verified zero-run for: `[ ] ( ) * + ^ $ \`.
33
+ #
34
+ # The failure hides from review because writing the test and running
35
+ # the whole file both work; only running the test BY NAME breaks —
36
+ # which is exactly what an agent iterating on a failure does.
37
+ #
38
+ # ## Allowed punctuation — and its caveats
39
+ # `# . , - : %` break neither form. Also allowed, with a caveat each:
40
+ #
41
+ # * `?` and `{ }`: verified runnable in BOTH forms on bash (an
42
+ # unanchored regex still matches around them; braces without a
43
+ # comma are literal to both bash and regex). On zsh, an unquoted
44
+ # `?` aborts with `no matches found` — quote the `-n` argument
45
+ # rather than renaming the test.
46
+ # * `/`: verified runnable in both forms — the `/name/` filter pairs
47
+ # the FIRST and LAST slash as delimiters, interior slashes are
48
+ # regex-literal content.
49
+ # * `!`: literal to non-interactive shells and to regex, but
50
+ # INTERACTIVE bash/zsh history-expand it (`!_` becomes the previous
51
+ # command's last argument, silently running a different filter) —
52
+ # quote the argument when running such a test from a terminal.
53
+ #
54
+ # ## Exception
55
+ # Interpolated names (`test "creates #{kind}"`) are not flagged — the
56
+ # matcher only sees string literals, and interpolated test names are
57
+ # their own anti-pattern (the method name varies with runtime data).
58
+ # RSpec `it`/`describe` strings are out of scope: the RSpec runner
59
+ # takes `-e` as a plain (quoted) exact string, which none of these
60
+ # characters break.
61
+ #
62
+ # NOTE: no stock cop covers this — rubocop-minitest's naming cops check
63
+ # the `test_` prefix convention, not the name's content. The matcher
64
+ # recognises implicit-receiver `test` with a string-literal name;
65
+ # explicit receivers (`self.test`, `helper.test`) and non-literal name
66
+ # arguments (`test 'name'.freeze`) are out of reach.
67
+ #
68
+ # @example
69
+ # # bad — shell syntax error unquoted; regex misparse in /name/ form
70
+ # test 'creates (admin) user' do
71
+ # test 'creates [admin] user' do
72
+ # test 'copies a*b of the record' do
73
+ #
74
+ # # good
75
+ # test 'creates admin user via dashboard' do
76
+ # test 'User#name returns full name' do
77
+ class TestNameSpecialCharacters < Base
78
+ MSG = 'Test name contains %<chars>s — these break running the single test by name: unquoted, the ' \
79
+ 'shell mis-parses the `-n` filter; in the `/name/` form, regex-significant ones match nothing ' \
80
+ '(0 runs). Rename using letters, digits, spaces, and allowed punctuation (see cop docs).'.freeze
81
+
82
+ RESTRICT_ON_SEND = %i[test].freeze
83
+
84
+ DEFAULT_FORBIDDEN_CHARACTERS = '()[]*+^$\\&;|<>\'"`'.freeze
85
+
86
+ def_node_matcher :test_name, <<~PATTERN
87
+ (send nil? :test $(str $_) ...)
88
+ PATTERN
89
+
90
+ def on_send(node)
91
+ test_name(node) do |name_node, name|
92
+ forbidden = forbidden_characters.chars.select { |char| name.include?(char) }
93
+ next if forbidden.empty?
94
+
95
+ add_offense(name_node, message: format(MSG, chars: forbidden.map { |c| "`#{c}`" }.join(' ')))
96
+ end
97
+ end
98
+
99
+ private
100
+
101
+ # `.to_s` so an explicit `ForbiddenCharacters:` with no value (YAML
102
+ # null) means "nothing forbidden" instead of raising on nil.chars.
103
+ def forbidden_characters = cop_config.fetch('ForbiddenCharacters', DEFAULT_FORBIDDEN_CHARACTERS).to_s
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
@@ -36,6 +36,16 @@ module RuboCop
36
36
  # structural array-param key for the group's rows, not a labelled
37
37
  # model attribute — the row template's inner fields are where
38
38
  # `prop:` belongs.
39
+ # - `fields_file` is exempt by default: the (deprecated) File field's
40
+ # `prop:` machinery calls `.attached?` on the bound model value
41
+ # (glib-web fields.rb `File#created` / `#determine_value`), so a
42
+ # bound prop must be an ActiveStorage attachment. A `fields_file`
43
+ # that posts a raw upload the controller parses and discards (CSV
44
+ # imports, server-side processing) has no attachment to bind —
45
+ # converting it to `prop:` raises at render (`nil.attached?` /
46
+ # `field_assert_respond_to`), and the unsafe autocorrect would
47
+ # produce exactly that. Attachment-backed uploads belong on
48
+ # `fields_upload`, which binds `prop:` fine.
39
49
  # ## How to fix — the decision ladder
40
50
  # Work down this ladder before even considering a disable. A full
41
51
  # convert-or-justify sweep of a mature codebase (27 offenses) ended
@@ -153,7 +163,7 @@ module RuboCop
153
163
  end
154
164
 
155
165
  def exempt_field_methods
156
- cop_config.fetch('ExemptFieldMethods', %w[fields_hidden fields_creditCard fields_dynamicGroup])
166
+ cop_config.fetch('ExemptFieldMethods', %w[fields_hidden fields_creditCard fields_dynamicGroup fields_file])
157
167
  end
158
168
  end
159
169
  end
@@ -1,5 +1,5 @@
1
1
  module RuboCop
2
2
  module DevDoc
3
- VERSION = "0.17.0".freeze
3
+ VERSION = "0.19.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-dev_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dev-doc contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-29 00:00:00.000000000 Z
11
+ date: 2026-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -89,6 +89,8 @@ files:
89
89
  - config/default.yml
90
90
  - config/obsoletion.yml
91
91
  - lib/dev_doc/i18n/pseudo_locale.rb
92
+ - lib/dev_doc/i18n/tasks.rb
93
+ - lib/dev_doc/railtie.rb
92
94
  - lib/dev_doc/test/best_practice_lints.rb
93
95
  - lib/dev_doc/test/lints/cop_drift_check.rb
94
96
  - lib/dev_doc/test/lints/cop_drift_test.rb
@@ -111,11 +113,14 @@ files:
111
113
  - lib/rubocop/cop/dev_doc/auth/no_record_presence_in_policy.rb
112
114
  - lib/rubocop/cop/dev_doc/auth/role_predicate_outside_policy.rb
113
115
  - lib/rubocop/cop/dev_doc/auth/unscoped_find_justification.rb
116
+ - lib/rubocop/cop/dev_doc/bundler/conflicting_gem.rb
117
+ - lib/rubocop/cop/dev_doc/exception_class_list.rb
114
118
  - lib/rubocop/cop/dev_doc/hash_pair_removal.rb
115
119
  - lib/rubocop/cop/dev_doc/i18n/avoid_titleize_humanize.rb
120
+ - lib/rubocop/cop/dev_doc/i18n/hardcoded_text.rb
116
121
  - lib/rubocop/cop/dev_doc/i18n/localizable_props.rb
117
- - lib/rubocop/cop/dev_doc/i18n/report_text.rb
118
122
  - lib/rubocop/cop/dev_doc/i18n/require_translation.rb
123
+ - lib/rubocop/cop/dev_doc/i18n/text_shape.rb
119
124
  - lib/rubocop/cop/dev_doc/i18n/translation_key_prefix.rb
120
125
  - lib/rubocop/cop/dev_doc/migration/amount_column_in_cents.rb
121
126
  - lib/rubocop/cop/dev_doc/migration/avoid_boolean_column.rb
@@ -127,12 +132,14 @@ files:
127
132
  - lib/rubocop/cop/dev_doc/migration/boolean_column_not_null.rb
128
133
  - lib/rubocop/cop/dev_doc/migration/date_column_naming.rb
129
134
  - lib/rubocop/cop/dev_doc/migration/explicit_null_on_reference.rb
135
+ - lib/rubocop/cop/dev_doc/migration/legacy_migration.rb
130
136
  - lib/rubocop/cop/dev_doc/migration/no_bulk_change_table.rb
131
137
  - lib/rubocop/cop/dev_doc/migration/no_create_join_table.rb
132
138
  - lib/rubocop/cop/dev_doc/migration/prefer_belongs_to.rb
133
139
  - lib/rubocop/cop/dev_doc/migration/redundant_reference_index.rb
134
140
  - lib/rubocop/cop/dev_doc/migration/require_primary_key.rb
135
141
  - lib/rubocop/cop/dev_doc/migration/require_reference_foreign_key.rb
142
+ - lib/rubocop/cop/dev_doc/migration/require_reference_index.rb
136
143
  - lib/rubocop/cop/dev_doc/migration/require_timestamps.rb
137
144
  - lib/rubocop/cop/dev_doc/rails/application_model_base.rb
138
145
  - lib/rubocop/cop/dev_doc/rails/application_record_transaction.rb
@@ -147,6 +154,9 @@ files:
147
154
  - lib/rubocop/cop/dev_doc/rails/no_block_predicate_on_relation.rb
148
155
  - lib/rubocop/cop/dev_doc/rails/no_collection_ids_writer_in_controller.rb
149
156
  - lib/rubocop/cop/dev_doc/rails/no_deliver_later_in_transaction.rb
157
+ - lib/rubocop/cop/dev_doc/rails/no_error_message_comparison.rb
158
+ - lib/rubocop/cop/dev_doc/rails/no_errors_add_in_controller.rb
159
+ - lib/rubocop/cop/dev_doc/rails/no_form_param_lookup_in_controller.rb
150
160
  - lib/rubocop/cop/dev_doc/rails/no_manual_record_invalid.rb
151
161
  - lib/rubocop/cop/dev_doc/rails/no_perform_later_in_model.rb
152
162
  - lib/rubocop/cop/dev_doc/rails/no_persistence_in_service.rb
@@ -158,30 +168,40 @@ files:
158
168
  - lib/rubocop/cop/dev_doc/route/resources_require_only.rb
159
169
  - lib/rubocop/cop/dev_doc/style/avoid_head_response.rb
160
170
  - lib/rubocop/cop/dev_doc/style/avoid_insecure_send.rb
171
+ - lib/rubocop/cop/dev_doc/style/avoid_kernel_array.rb
161
172
  - lib/rubocop/cop/dev_doc/style/avoid_options_hash.rb
162
173
  - lib/rubocop/cop/dev_doc/style/avoid_symbolizing_boundary_input.rb
163
174
  - lib/rubocop/cop/dev_doc/style/case_else_decision.rb
175
+ - lib/rubocop/cop/dev_doc/style/in_memory_association_find.rb
164
176
  - lib/rubocop/cop/dev_doc/style/literal_operator_in_condition.rb
165
177
  - lib/rubocop/cop/dev_doc/style/literal_or_in_when_clause.rb
166
178
  - lib/rubocop/cop/dev_doc/style/minimize_variable_scope.rb
179
+ - lib/rubocop/cop/dev_doc/style/no_silent_rescue.rb
167
180
  - lib/rubocop/cop/dev_doc/style/no_unscoped_method_definitions.rb
181
+ - lib/rubocop/cop/dev_doc/style/prefer_allowlist_symbol_param.rb
168
182
  - lib/rubocop/cop/dev_doc/style/prefer_public_send.rb
169
183
  - lib/rubocop/cop/dev_doc/style/redundant_guard_after_bang.rb
170
184
  - lib/rubocop/cop/dev_doc/style/repeated_bracket_read.rb
171
185
  - lib/rubocop/cop/dev_doc/style/repeated_safe_navigation_receiver.rb
186
+ - lib/rubocop/cop/dev_doc/style/rescue_justification.rb
172
187
  - lib/rubocop/cop/dev_doc/style/string_symbol_comparison.rb
173
188
  - lib/rubocop/cop/dev_doc/style/tap_block_ignores_value.rb
189
+ - lib/rubocop/cop/dev_doc/style/use_g_log.rb
174
190
  - lib/rubocop/cop/dev_doc/test/avoid_glib_travel_freeze.rb
175
191
  - lib/rubocop/cop/dev_doc/test/avoid_unit_test.rb
192
+ - lib/rubocop/cop/dev_doc/test/justification_covers.rb
176
193
  - lib/rubocop/cop/dev_doc/test/justification_header.rb
177
194
  - lib/rubocop/cop/dev_doc/test/no_persistence_in_mailer_previews.rb
178
195
  - lib/rubocop/cop/dev_doc/test/no_unit_idioms_in_integration_tests.rb
196
+ - lib/rubocop/cop/dev_doc/test/prefer_find_sole_by.rb
179
197
  - lib/rubocop/cop/dev_doc/test/require_glib_integration_base.rb
180
198
  - lib/rubocop/cop/dev_doc/test/require_glib_travel.rb
181
199
  - lib/rubocop/cop/dev_doc/test/require_glib_travel_block.rb
200
+ - lib/rubocop/cop/dev_doc/test/require_job_invocation_in_job_tests.rb
182
201
  - lib/rubocop/cop/dev_doc/test/require_unit_test_justification.rb
183
202
  - lib/rubocop/cop/dev_doc/test/response_assert_equal.rb
184
203
  - lib/rubocop/cop/dev_doc/test/test_file_placement.rb
204
+ - lib/rubocop/cop/dev_doc/test/test_name_special_characters.rb
185
205
  - lib/rubocop/cop/dev_doc/view/prefer_prop_over_name.rb
186
206
  - lib/rubocop/dev_doc.rb
187
207
  - lib/rubocop/dev_doc/plugin.rb
@@ -206,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
226
  - !ruby/object:Gem::Version
207
227
  version: '0'
208
228
  requirements: []
209
- rubygems_version: 3.4.6
229
+ rubygems_version: 3.5.22
210
230
  signing_key:
211
231
  specification_version: 4
212
232
  summary: RuboCop cops enforcing dev-doc best practices
@@ -1,76 +0,0 @@
1
- require_relative 'localizable_props'
2
-
3
- module RuboCop
4
- module Cop
5
- module DevDoc
6
- module I18n
7
- # Report every user-facing text in a glib JSON-UI text prop — both
8
- # hardcoded strings and already-localized `t(...)` calls.
9
- #
10
- # ## Rationale
11
- # `DevDoc/I18n/RequireTranslation` flags only *hardcoded* strings; it
12
- # stays silent once a value is localized. This cop is the opposite: it
13
- # fires on **every** text value, localized or not, so you can sweep a
14
- # codebase and collect the full list of user-facing strings (e.g. to
15
- # seed a translation catalog or audit coverage).
16
- #
17
- # It is a tooling aid, not a lint — **disabled by default** and runs at
18
- # `info` severity. Run it during a localization pass; it is not meant
19
- # for every commit.
20
- #
21
- # Both the hardcoded form (`view.p text: 'Welcome'`) and the localized
22
- # form (`view.p text: t('home.welcome')`) are reported. Blank/whitespace
23
- # strings and pure dynamic values (`user.name`) carry no static text and
24
- # are skipped.
25
- #
26
- # The watched method names and localizable keys are configurable via
27
- # `WatchedMethods:` and `LocalizableKeys:`.
28
- #
29
- # 📋 Reported — hardcoded text
30
- # view.p text: 'Welcome'
31
- #
32
- # 📋 Reported — localized text
33
- # view.p text: t('home.welcome')
34
- #
35
- # @example
36
- # # info (hardcoded text)
37
- # view.p text: 'Welcome'
38
- #
39
- # # info (localized text — still reported)
40
- # view.p text: t('home.welcome')
41
- #
42
- # # info (interpolated string)
43
- # view.p text: "Hi #{name}"
44
- #
45
- # # ignored (blank — no text)
46
- # view.fields_text label: ''
47
- #
48
- # # ignored (pure dynamic — no static text)
49
- # view.p text: user.name
50
- class ReportText < Base
51
- include LocalizableProps
52
-
53
- MSG = 'Text for `%<key>s:`: review/collect this for localization.'.freeze
54
-
55
- private
56
-
57
- def inspect_localizable(key, value)
58
- return unless text?(value)
59
-
60
- add_offense(value, message: format(MSG, key: key))
61
- end
62
-
63
- # Any value that carries static user-facing text: a non-blank string
64
- # literal, an interpolated string, or a translation call. Blank strings
65
- # and pure dynamic values (`user.name`) carry no text and are skipped.
66
- def text?(node)
67
- return true if node.dstr_type?
68
- return !node.value.strip.empty? if node.str_type?
69
-
70
- translation_call?(node)
71
- end
72
- end
73
- end
74
- end
75
- end
76
- end