LengthRatioRule class
Warn when a translation is suspiciously much shorter or longer than the source. Out-of-band lengths are a strong signal of a truncated translation, a swap-bug (wrong locale's text), or an AI that hallucinated extra prose.
Per-locale min, max multipliers are read from dialect.yaml:
length_ratio:
ja: [0.4, 1.5] # Japanese is consistently shorter
de: [0.5, 2.8] # German is consistently longer
Default for unlisted locales: [0.3, 2.5]. Very short source strings
(< 8 chars) skip the check entirely — "OK" → "はい" is a 1x
ratio that's meaningless to police.
Severity is warning. --strict-length (separate from --strict)
promotes it to an error for CI gating.
Constructors
- LengthRatioRule()
-
const
Properties
- defaultSeverity → IssueSeverity
-
Default severity. May be overridden per-issue.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
Stable rule identifier (snake_case). Used by the report formatter
to group findings and by users to silence/ack via state file
(post-v1.0).
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
run(
DialectProject project) → List< Issue> -
Inspect
projectand return findings. May return an empty list. Should NOT throw — turn unexpected conditions into Issues so the report surfaces them rather than crashing.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
defaultRange
→ const List<
double> -
Default multiplier band when no per-locale override is set in
dialect.yaml. - minSourceLength → const int
- Source strings shorter than this skip the check — short strings' ratios are too noisy to be a useful signal.