YAML lint written in Java.
Its main purpose is to provide an API and scripts to analyze YAML documents.
The YAML documents are syntactically checked as well as against rules. To get the list of rules, please refer to the classes
of the com.github.sbaudoin.yamllint.rules
package. Among
other we have a rule to check the presence of the start and end YAML document marker, the correct and consistent indentation, etc.
Maven dependency:
<dependency>
<groupId>com.github.sbaudoin</groupId>
<artifactId>yamllint</artifactId>
<version>1.2.0</version>
</dependency>
For use, please refer to the JavaDoc.
The class that will mostly interest you is com.github.sbaudoin.yamllint.Linter
: it contains static methods
that can be used to analyze a YAML string or a file.
3 errors levels have been defined: info, warning and error.
The linter can return only one syntax error per file (once a syntax error has been met we cannot expect a lot from the rest of the file with respect to the syntax). It is returned apart, not as part of the so called "cosmetic errors", that represent all other errors checked with specific rules.
Get the .zip
or .tar.gz
distribution archive, unpack and execute the script corresponding to your platform in the bin
directory:
bin/yamllint [options] files/directories
or
bin\yamllint [options] files/directories
Warning! The Unix version requires Bash. There is no guaranty that the script will work with other Shell interpreters.
Use the --help
(or -h
) option to get help. By default, if the terminal supports it, the output is colorized and has
the following output format:
file.yml
line:column level message (ruleId)
...
You can specify the -f parsable
on the command line to get a parsable output as follows:
file.yml:line:column:ruleId:level:message