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

Fix get_yaml_files to return all configured files #1549

Closed

Conversation

sengaya
Copy link

@sengaya sengaya commented May 12, 2021

The issue was introduced with #1473 and only affects setups without a
git repo and when custom kinds are used.

The issue was introduced with ansible#1473 and only affects setups without a
git repo and when custom kinds are used.
@sengaya sengaya requested a review from ssbarnea as a code owner May 12, 2021 16:42
@ssbarnea ssbarnea added the bug label May 12, 2021
@ssbarnea
Copy link
Member

@sengaya Is not clear from the description but my impression is that this fixed the issue where get_yaml_files return only yaml files when run outside git repos and all files outside them.

If so, maybe we should also rename get_yaml_files to get_lintables in order to avoid confusing us.

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.

Fix the linting and explain the reasoning a little bit better. Other than this is looks like a good bugfix.

@sengaya
Copy link
Author

sengaya commented May 12, 2021

@ssbarnea thanks for the feedback. I would not rename it to get_lintables as it looks like the method should return only yaml files that might have a custom kind (e.g. something other than .yaml or . .yml), but the file itself has still yaml content. Also the method is called by a method get_lintables already.

But after looking again at get_yaml_files I'm a bit lost. I think the detection of yaml files is even more broken. You can create a failing test by adding and comitting a file to e.g. examples/roles/test-role/tasks/non-lintable.file and run the test test_get_yaml_files_silent. I would expect the file to be ignored, but the test fails. So to me it looks like the method currently just returns any file and neither the default kinds nor custom kinds are applied.

Apply the patterns defined in DEFAULT_KINDS as well as custom defined
yaml patterns and only return these files.
@sengaya
Copy link
Author

sengaya commented May 13, 2021

@ssbarnea After digging a bit deeper into the code base I could come up with a solution how to apply the default and custom yaml patterns. Let me know what you think.

@sengaya sengaya requested a review from ssbarnea May 13, 2021 22:55
ssbarnea added a commit that referenced this pull request May 19, 2021
Address bug related to detection of lintable files when run outside
a git repository.

- extend list of exclusions with few common directiories
- allow linter to identify any file type, not only those with
  yaml/yml extension (matches behavior of git ls-files variant)
- improve logging messages

Closes: #1549
@ssbarnea
Copy link
Member

Obsoleted by #1557

@ssbarnea ssbarnea closed this May 19, 2021
ssbarnea added a commit that referenced this pull request May 19, 2021
Address bug related to detection of lintable files when run outside
a git repository.

- extend list of exclusions with few common directiories
- allow linter to identify any file type, not only those with
  yaml/yml extension (matches behavior of git ls-files variant)
- improve logging messages

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

Successfully merging this pull request may close these issues.

None yet

2 participants