SonarQube plugin to analyze YAML code based on yamllint.
The plugin comes with a default "Sonar way" profile with most common rules enabled:
- Anchors check
- Syntax error check
- Braces check
- Brackets check
- Colons check
- Commas check
- Comments check
- Comments indentation check
- Document start check
- Empty lines check
- Empty values check
- Hyphens check
- Indentation check
- Key duplicates check
- Line length check
- New line at end of file check
- New lines check
- Octal values check
- Trailing spaces check
- Truthy check
Some additional rules are provided but not enabled by default:
- Document end check
- Float values check
- Forbidden key check (template)
- Forbidden value check (template, new in 1.3.0)
- Key ordering check
- Quoted strings check (new in 1.4.0)
- Required key check (template, new in 1.5.0)
- Int value in range check (template, new in 1.8.0)
Once installed, you may go to the profile management screens to create your own profile and add or remove rules, change levels, and parameters, etc.
Plugin for SonarQube 8.1+ (including 8.9 LTS), 9.0+ (including SonarQube 9.2 as of version 1.7 and 9.9 LTS), 10.0+ (tested on 10.2 only).
Just download the plugin JAR file and copy it to the extensions/plugins
directory of SonarQube and restart.
Version 1.8.0 introduces included-ancestors and excluded-ancestors as regex rule properties, for the following template checks:
- forbidden key
- forbidden value
- required key and
- int value in range
This provides the possibility to apply the checks only in a certain scope 1 and/or only not in a certain scope 2. Current limitation: yaml list notation is not supported by ancestor matching.
Scan fails with "ERROR: Caused by: x is not a valid line offset for pointer. File xyz.yml has y character(s) at line z"
This may be due to issue #6: if your YAML file contains YAML-valid UTF-8 line break characters such as U+2028, SonarQube may just strip them, causing the character and lines references being different between the YAML parser and SonarQube.
If such an error is met, go to the main or project general settings of the YAML plugin and enable the option "Filter UTF-8 Line Breaks". This will make the plugin to ignore some valid UTF-8 line break characters (U+2028, U+2029 and U+0085) so that SonarQube and the plugin both use the same character and line indices and, the scan should complete.
This is due to the fact that SonarQube 9.2 has brought native support to the YAML language. See PR #58 and issue #63. To fix the issue, please install the plugin version 1.7+
This is due to the fact that some other plugin has already saved measures for the YAML files. See issue #70. This issue is fixed with version 1.8.0. If you cannot upgrade, you must disable this plugin or the other plugins that scan YAML files.