-
Notifications
You must be signed in to change notification settings - Fork 654
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
"noqa" comment is ignored when using auto-detection mode #1368
Comments
@imomaliev are you 100% sure that the noqa comment is on exact line number on which the error is reported from? Double check, try to move it to next and let me know. In line noqa in YAML is really a PITA as the noqa comes from one parser and the linting errors come from another one. |
@ssbarnea Hi, ansible-lint itself highlighted me this line.
If I check on previous version and use on same line |
Hi, I'm also seeing this regression/issue - honoring inline noqa - with ansible-lint 5.0.0/1 and I can add some more information; I'm able to trigger the issue by using directories paths instead of full path names of playbooks:
Increasing the verbosity level (-vv) shows that in the first case (using directories paths) the YAML files are not promoted to playbooks and are checked as files of type yaml. In the second case, the YAML files are promoted and checked as files of type playbook. Log messages: Directories
Playbooks pathnames
Regards, |
Additional information:
|
When running in auto-detection mode, the linter looks only at tracked git-files. Anything that is not tracked by git will be ignored. This means that if you add a new file on disk and you run the linter without arguments, it will ignore the new file. Dealing with this case can be tricky so I am considering failing to run the linter if git reports dirty status may be seen as an improvement, as users will be less likely to get confused by the results. |
I have a similar case: Directly specifying the file works, it discovers the file correctly as play.
But only specifying the directory doesn't, it discovers xzy/test.yml as yaml and xzy as role and the error can't be supressed:
Content of xzy/test.yml:
The directory xzy is empty and I did a Version:
|
I am closing this because it there were 4 more releases since, and at least some of the mentioned issues were addressed. Please use discussions if you still have issues with latest release and I will open a bug once I get confirmation is not the expected behavior. |
Issue is still present. Used same steps from initial post and also created git repository and commit Ansible and Ansible Lint details$ ansible --version
ansible 2.10.5
config file = None
configured module search path = ['/Users/batiskaf/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /Users/batiskaf/.local/share/pipx/venvs/ansible/lib/python3.8/site-packages/ansible
executable location = /Users/batiskaf/.local/bin/ansible
python version = 3.8.2 (default, Sep 24 2020, 19:37:08) [Clang 12.0.0 (clang-1200.0.32.21)]
$ ansible-lint --version
ansible-lint 5.0.4 using ansible 2.10.5
OS / ENVIRONMENTmacOS 10.15.7 $ uname -v
Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 STEPS TO REPRODUCE$ mkdir noqa-test && cd noqa-test
$ echo '---
- name: Setup
hosts: host
tasks:
# package-latest: Package installs should not use latest
- name: Upgrade all yum packages # noqa package-latest
yum:
name: "*"
state: latest
' > site.yml
$ git init
$ git add site.yml
$ git commit -m 'add site.yml'
$ ansible-lint -v Desired BehaviourWarning $ ansible-lint -v
INFO Discovering files to lint: git ls-files -z
INFO Discovering files to lint: git ls-files -z Actual BehaviourGetting ansible-lint warning
|
Reopening, I confirm it. |
Fixes bug where matchtasks() was called for file kinds that may not be containers for task. Fixes: #1368
Fixes bug where matchtasks() was called for file kinds that may not be containers for task. Fixes: #1368
Summary
"noqa" comment is not working properly when using auto-detection mode
Issue Type
Ansible and Ansible Lint details
OS / ENVIRONMENT
macOS 10.15.7
STEPS TO REPRODUCE
Desired Behaviour
Warning
package-latest
should be ignoredActual Behaviour
Getting ansible-lint warning
The text was updated successfully, but these errors were encountered: