float-style
What it does
Section titled “What it does”Restricts how plain floats are written. Every option is off until set: require_numeral_before_decimal reports .5, forbid_scientific_notation reports 1e3, forbid_nan reports .nan and forbid_inf reports .inf. Quoted and tagged scalars are not checked. The fix for .5 is 0.5.
Why it matters
Section titled “Why it matters”YAML 1.1 and 1.2 parsers read some float spellings differently (1e3 is a string in YAML 1.1, since it requires a dot), and .5 is hard to see. A project can choose the spellings that every parser it uses reads the same way.
Configuration
Section titled “Configuration”github-actions: lint: rules: float-style: level: warn # off (default), warn, error options: require_numeral_before_decimal: false forbid_scientific_notation: false forbid_nan: false forbid_inf: falseyaml: lint: rules: float-style: level: warn # off (default), warn, error options: require_numeral_before_decimal: false forbid_scientific_notation: false forbid_nan: false forbid_inf: false| Option | Type | Default | Description |
|---|---|---|---|
require_numeral_before_decimal |
bool | false |
Report .5, -.5e3: a digit must come before the decimal point. |
forbid_scientific_notation |
bool | false |
Report 1e3, 1.5E-2, .5e3. |
forbid_nan |
bool | false |
Report .nan, .NaN, .NAN. |
forbid_inf |
bool | false |
Report .inf, -.Inf, +.INF. |
Suppress one line with sudsy-disable-next-line float-style in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| yamllint | float-values |
full |
| yamllint | float-values.forbid-inf / forbid-nan / forbid-scientific-notation / require-numeral-before-decimal |
full |