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

Add rule violations from Yamllint #955

Merged
merged 1 commit into from Dec 31, 2020
Merged

Add rule violations from Yamllint #955

merged 1 commit into from Dec 31, 2020

Conversation

ssbarnea
Copy link
Member

@ssbarnea ssbarnea commented Aug 14, 2020

This detect yamllint rule violations when this is found as installed. This will allow us to remove a set of rules that
overlapped with general YAML syntax ones.

Fixes: #953
Release-Notes: #1150

@ssbarnea ssbarnea added the feedback-needed Divergent oppinions, additional feedback is desired in order to unblock it. label Aug 14, 2020
@ssbarnea ssbarnea changed the title POC: Make use of yamllint Add rule violations from Yamllint Dec 23, 2020
@ssbarnea ssbarnea force-pushed the feature/yamllint branch 2 times, most recently from 68fe7fd to 2bc5071 Compare December 23, 2020 18:00
@ssbarnea ssbarnea marked this pull request as ready for review December 23, 2020 18:04
@ssbarnea ssbarnea added major Used for release notes, requires major versioning bump and removed feedback-needed Divergent oppinions, additional feedback is desired in order to unblock it. labels Dec 23, 2020
@felixfontein
Copy link
Contributor

I've tried this PR in a role-only collection of mine, and found it ignores my .yamllint file.

@ssbarnea
Copy link
Member Author

@felixfontein Thanks for looking at it. Yep, I am aware that it ignores the in-repo yamllint config and that it uses a hardcoded configuration.

That is more or less by design as I wanted to fully control the results. I can see how this could get me into trouble and I guess I will have to make it use the embedded default only when a local config is not found.

One thing that you likely already know is that most Ansible content is not compatible with the yamllint-own-default-config and that the author has very strong opinions regarding what defaults should be.

Another feature that is currently missing is ability to fully disable this rule instead of ignoring or skipping it.

I do not expect to merge this very soon but getting early feedback is essential, as it would allow me to improve the implementation.

@felixfontein
Copy link
Contributor

@ssbarnea being able to disable that would be really helpful :) Does it make sense to make this configurable? I don't know if ansible-lint has other rules that can be configured (and not just disabled).

@ssbarnea ssbarnea force-pushed the feature/yamllint branch 2 times, most recently from 754d29e to d91c316 Compare December 27, 2020 12:07
ssbarnea added a commit that referenced this pull request Dec 30, 2020
Replace use of class with an instance of a Rule for MatchErrors, as
this will allows us to process rules that produce various different
error messages (aka meta-rules).

Prepares-For: #955
ssbarnea added a commit that referenced this pull request Dec 30, 2020
Replace use of class with an instance of a Rule for MatchErrors, as
this will allows us to process rules that produce various different
error messages (aka meta-rules).

Prepares-For: #955
ssbarnea added a commit that referenced this pull request Dec 30, 2020
ssbarnea added a commit that referenced this pull request Dec 30, 2020
@ssbarnea ssbarnea force-pushed the feature/yamllint branch 3 times, most recently from 082b510 to 3287ddd Compare December 30, 2020 13:51
@ssbarnea
Copy link
Member Author

@ssbarnea being able to disable that would be really helpful :) Does it make sense to make this configurable? I don't know if ansible-lint has other rules that can be configured (and not just disabled).

Now is configurable, it will respect user defined config. You can also skip entire rules with "YAML" tag, or specific ones with their named-tag reported by yamllint itself.

AFAIK, it is ready to be merged. I am just waiting for an approval. Once merged I will tag a pre-release in order to allow users to start consuming the newer changes.

.ansible-lint Outdated Show resolved Hide resolved
Also detect yamllint rule violations when this is found as
installed. This will allow us to remove a set of rules that
overlapped with general YAML syntax ones.

Fixes: #953
@ssbarnea ssbarnea merged commit a00e5e8 into master Dec 31, 2020
@ssbarnea ssbarnea deleted the feature/yamllint branch December 31, 2020 12:32
@felixfontein
Copy link
Contributor

@ssbarnea thanks for implementing this!

@ssbarnea
Copy link
Member Author

@felixfontein Thanks for reviewing it. I also have https://github.com/ansible-community/ansible-lint/pull/950/files ready for review, which is kinda similar: making use of ansible syntax check.

@ssbarnea ssbarnea added this to the 5.0.0 milestone Dec 31, 2020
DESCRIPTION = """\
Rule violations reported by YamlLint when this is installed.

You can fully disable all of them by adding 'YAML' to the 'skip_list'.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be sure: This is supposed to with YAML in the skip_list, not with yaml? To me it seems like the other way around?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is an error, correct key is 'yaml', I will fix it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixing via #1335

cavcrosby added a commit to cavcrosby/jenkins-docker-base that referenced this pull request Jun 17, 2022
Yaml not specific to Ansible will use a different linter as while
ansible-lint does detect yamllint violations (see
ansible/ansible-lint#955), I would prefer that
yaml not specific to Ansible be linted in a more generic sense.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature major Used for release notes, requires major versioning bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make use of yamllint for generic YAML issues
4 participants