yaml
YAML files: valid syntax, unique keys, used anchors, quoted ambiguous values, and the .yml extension.
Selected when
Section titled “Selected when”Always.
Checks
Section titled “Checks”syntax
Section titled “syntax”Checks YAML syntax, duplicate keys, anchors, ambiguous scalar values, and file conventions.
Runs at the commit stage.
A YAML file that parses differently between consumers can silently change the values that the program reads.
What to do
Section titled “What to do”Fix the reported YAML value or layout.
Example
Section titled “Example”Two enabled keys in one YAML mapping report a duplicate key. Keep one, and delete the other.
Lint rules
Section titled “Lint rules”| Rule | What it checks | What to do |
|---|---|---|
syntax |
YAML must parse without syntax errors. | Fix the syntax at the reported line. |
key-duplicates |
Each mapping key appears once. | Keep one definition of the key and remove the other. |
anchors |
Aliases name preceding anchors in the same document, and every anchor has a use. | Declare the anchor before its alias, or remove the unused anchor. |
truthy |
Boolean-looking strings are quoted, and booleans use lowercase true or false. | Quote this string, or write a boolean as true or false. |
octal-values |
Plain numbers have no leading zero or octal prefix. | Quote a value with a leading zero, or write the number in decimal without leading zeros. |
documents |
A file contains one YAML document. | Keep one YAML document per file. Accept this rule with a reason only when the consumer requires a stream. |
merge-keys |
Mappings have explicit keys instead of the << merge key. | Do not use the << merge key. Write the mapping keys explicitly. |
anchor-names |
An anchor name describes the value it holds. | Rename the anchor and its aliases for their shared value. |
version-numbers |
A decimal-looking string with a trailing zero is quoted. | Quote this value to preserve its trailing zero. |
comments |
Comments sit above the key, except version comments after pinned actions. | Move this comment above the key. Only a version comment after a uses value pinned to a full commit is allowed. |
file-extension |
YAML files use .yml unless a consumer names the .yaml file. | Use the .yml extension unless the consumer requires this .yaml file name. |
Turn it off
Section titled “Turn it off”gspot ignore yaml/syntax --paths "<path>" --reason "<why>"gspot ignore yaml/syntax --rule syntax --reason "<why>"