Skip to content

Skip yamllint warnings #2248

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

Closed

Conversation

dthomson-triumf
Copy link

Hi, I saw that #1794 was marked with a "good first issue" tag, so I thought I'd try doing a small fix for this bug that I just ran up against.

The PR should be fairly straightforward to read, though I'm not sure if this is along the lines of what you might be looking for with a solution. Comments, suggestions and concerns are all welcome.

Thanks!

Set match.ignored to True on all sub-error level issues that get
reported from yamllint
@dthomson-triumf dthomson-triumf requested a review from a team as a code owner July 25, 2022 20:45
@dthomson-triumf dthomson-triumf requested review from a team, ssbarnea, ganeshrn and priyamsahoo July 25, 2022 20:45
@ssbarnea
Copy link
Member

@dthomson-triumf I do have the impression that you are trying to fix something that does not need to be fixed.

As far the linter is concerned any message from yamllint is an error. We do not care if yamllint is configured to treat them as errors or warnings, for us all of them are violations.

If you want to make ansible-lint to treat a specific yamllint rule as a warning, you can add these to warn_list as yaml[some-rule] and it should work.

@dthomson-triumf
Copy link
Author

I thought that #1794 indicated that this was a bug that needs fixing?

Regardless, using the yaml[some-rule] entry in the warn_list doesn't seem to work for me with ansible-lint 6.3.0 and yamllint 1.27.1, but maybe I'm misunderstanding something.

The following setup:

# playbook.yml
---
- hosts: localhost
  tasks:
    - name: Here is a long task
      ansible.builtin.command: echo "This is the output from a very long command that's not going to make ansible-lint very happy"
      changed_when: false
# .ansible-lint
---
warn_list:
  - yaml[list-length]
# .yamllint
---
rules:
  line-length:
    level: warning
    max: 80

Still gives me:

me@myhost:~/ansible-lint-warns$ ansible-lint 
WARNING  Listing 1 violation(s) that are fatal
yaml: line too long (130 > 80 characters) (yaml[line-length])
playbook.yml:5

You can skip specific rules or tags by adding them to your configuration file:
# .config/ansible-lint.yml
warn_list:  # or 'skip_list' to silence them completely
  - yaml  # Violations reported by yamllint.

Finished with 1 failure(s), 0 warning(s) on 1 files.

Only using:

warn_list:
  - yaml

Treats the yamllint issues as warnings, but that means every single reported result from yamllint, including those that are being listed as errors and not just warnings will be treated as warnings by ansible-lint.

ssbarnea added a commit to ssbarnea/ansible-lint that referenced this pull request Jul 27, 2022
You can now add entries like `yaml[document-start]` to the skip_list
or warn_list, instead of adding the entire rule, allowing you to have
more granular filtering.

Closes: ansible#2248
Closes: ansible#1794
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this pull request Jul 27, 2022
You can now add entries like `yaml[document-start]` to the skip_list
or warn_list, instead of adding the entire rule, allowing you to have
more granular filtering.

Closes: ansible#2248
Closes: ansible#1794
ssbarnea added a commit that referenced this pull request Jul 27, 2022
* Add ability to use use sub-rule matches on skip or warn lists

You can now add entries like `yaml[document-start]` to the skip_list
or warn_list, instead of adding the entire rule, allowing you to have
more granular filtering.

Closes: #2248
Closes: #1794

* Update src/ansiblelint/rules/yaml.md

Co-authored-by: Jacob Floyd <[email protected]>

* Update .ansible-lint

Co-authored-by: Jacob Floyd <[email protected]>

* Update src/ansiblelint/app.py

Co-authored-by: Jacob Floyd <[email protected]>

Co-authored-by: Jacob Floyd <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants