Skip to content
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

Utilize yamllint severity levels for rule severity #1530

Merged
merged 3 commits into from Apr 20, 2021

Conversation

FloSchwalm
Copy link
Contributor

yamllint allows to categorize found problems as "error" or "warning"
ansible-lint treats them all as having VERY_LOW severity anyway

I think that the rule categorization of yamllint shouldn't be lost, after all it can be configured with a .yamllint config file to fit the user's needs.

This PR keeps the VERY_LOW severity categorization for problems that yamllint reports as "warning" just as before, but uses MEDIUM severity for problems reported as "error".
Syntax errors reported by yamllint are raised to VERY_HIGH severity, though they won't be used as long as ansible-lint skips further rule checking after its own syntax check.

FloSchwalm and others added 2 commits April 13, 2021 20:57
yamllint allows to categorize found problems as "error" or "warning"
ansible-lint treats them all as having VERY_LOW severity anyway
This commit keeps the VERY_LOW severity categorization for problems
that yamllint reports as "warning", but uses MEDIUM severity for
problems reported as "error"
Syntax errors reported by yamllint are raised to VERY_HIGH severity
Copy link
Member

@ssbarnea ssbarnea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should have included some tests.

@FloSchwalm
Copy link
Contributor Author

Ideally we should have included some tests.

I guess I can try to add some. I'm no python developer, but I think I can figure it out from the existing tests.
What kind of test were you thinking of? Hardcoded ansible-lint output lines which are then tested if categorized correctly? Or would you rather include a test playbook and actually run ansible-lint in the test?

@ssbarnea
Copy link
Member

Create one extra file inside examples/playbooks that would raise all 3 types of yamllint severity issues when you lint it. After this you can add one extra test that verifies that the output is the expected one.

lookat def test_example_custom_module and copy it to test_example_yamllint_severity, test for number of failures reported and their content (especially severity levels). Print the result to see what it contains, or add a breakpoint() and run pytest -k test_example_yamllint_severity once you add it. Once inside the debugger you will be able to inspect what result contains.

To save your time: result is a List[MatchError], so you will know how to assert each entry has the expected severity level.

@ssbarnea ssbarnea enabled auto-merge (squash) April 20, 2021 10:33
@ssbarnea ssbarnea merged commit fd4b54a into ansible:master Apr 20, 2021
@FloSchwalm FloSchwalm deleted the use-yamllint-severity-levels branch April 24, 2021 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants