Module: LcpRuby::I18nCheck::Heuristics

Defined in:
lib/lcp_ruby/i18n_check/heuristics.rb

Constant Summary collapse

SNAKE_CASE =
/\A[a-z][a-z0-9_]*\z/.freeze
SHORT_ACRONYM =
/\A[A-Z]{1,4}\z/.freeze

Class Method Summary collapse

Class Method Details

.identifier_like?(value) ⇒ Boolean

Skip strings that look like code identifiers rather than UI text:

- empty / whitespace-only strings
- snake_case tokens (e.g. "draft", "in_review")
- short ALL-CAPS acronyms ≤ 4 chars (e.g. "ID", "URL")

Shared with ‘KeyDeriver#identifier_like?` — single source of truth for noise suppression on Tier 2 literals.

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
# File 'lib/lcp_ruby/i18n_check/heuristics.rb', line 16

def identifier_like?(value)
  return true if value.nil?
  s = value.to_s
  return true if s.strip.empty?
  return true if s.match?(SNAKE_CASE)
  return true if s.match?(SHORT_ACRONYM)
  false
end