Skip to content

ansible-lint-ignore: add skip option #4614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ianw
Copy link
Contributor

@ianw ianw commented May 27, 2025

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

Copy link

Label error. Requires exactly 1 of: bug, chore, enhancement, major, minor, patch, skip-changelog. Found:

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] ansible#3068

Signed-off-by: Ian Wienand <[email protected]>
@ianw
Copy link
Contributor Author

ianw commented May 27, 2025

(The CI failures here appear to be related to a new release for ruamel - see #4615)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant