uneven_digit_groups
Reports a number literal whose digit separators make groups of different sizes, as in 1_000_00. Group the digits evenly.
- Tier
- advisory
- Scope
- Dart
- Lowest preset
- strict
- Fix
- none
What it reports
Section titled “What it reports”A number literal whose digit separators cut its digits into groups of different sizes: 1_000_00, 0xFF_FF_FFF, 3.141_59_2. The violation covers the literal.
- Before the point, every group but the first has one size, and the first is not longer.
- After the point, the same from the left, so only the last group may be shorter.
- A run of separators counts as one. An exponent is not judged.
It does not report:
- even groups;
- a shorter first group:
12_345; - a shorter last group after the point:
1.123_456_78; - numbers without separators.
A grouping that is uneven on purpose, such as lakhs and crores (10_00_000) or a date (2024_01_15), is reported: suppress it with the reason.
A reader takes the groups to be thousands, bytes or whatever the regular size says, and misreads the value.
Example
Section titled “Example”const price = 1_000_00;const price = 100_000;Rule parameters
Section titled “Rule parameters”Set under the assay: key of the project’s root analysis_options.yaml.
| Rule parameter | Default | Effect |
|---|---|---|
enabled |
true |
false switches the rule off for the whole project. |
exclude |
[] |
Path globs where the rule is silent. |
Suppressing it
Section titled “Suppressing it”Write why on the line directly above the suppression:
// Why it stays as written here.// ignore: assay/uneven_digit_groups// ignore_for_file: assay/uneven_digit_groups silences it in a whole file, and // ignore: uneven_digit_groups without the prefix works too. See Suppressions.