ansible-lint-ignore: add skip option #4614
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently file/rules listed in ansible-lint-ignore produce a warning in the output when matched. This is by design, as discussed in [1], the argument being that the error remains an error, and should be surfaced for visibility.
The "skip_list" and "noqa" options are available to silence warnings. There are two specific problems with this; the first acts globally and the second can not always be applied (for example; for role-names checks there's nowhere to put the "noqa" flag).
To use the role-name check as an example, it may be that a project wishes to incorporate this rule moving forward, but has a selection of existing roles that do not obey the naming rules which can not be modified for external-API reasons. There is no way to skip the current failures but flag any new occurrences as issues. Currently the warnings are always present in reported results such as sarif output that gets visualised by tools like GitLab. New contributors see a range of warnings for things the project is aware of but unable to practically fix.
This change proposes add an optional "skip" flag to the ansible-lint-ignore values to give no warning for the matched rule. This is an intermediate step between the never-warn-but-global skip_list and the always-warn ansible-lint-ignore entries, but leaves the default behaviour to surface the warning as is currently done.
I have implemented it with the idea that rules are strictly typed by converting users to an IgnoreRule named tuple. This uses typed flags with the flexibility to have other qualifiers in the future, although the only one supported for now is "skip".
Test cases and documentation is updated.
[1] #3068