-
Notifications
You must be signed in to change notification settings - Fork 658
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
Adds experimental stdin support #1355
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ class LintResult: | |
"""Class that tracks result of linting.""" | ||
|
||
matches: List[MatchError] | ||
files: Set[str] | ||
files: Set[Lintable] | ||
|
||
|
||
class Runner: | ||
|
@@ -41,7 +41,7 @@ def __init__( | |
skip_list: List[str] = [], | ||
exclude_paths: List[str] = [], | ||
verbosity: int = 0, | ||
checked_files: Optional[Set[str]] = None | ||
checked_files: Optional[Set[Lintable]] = None | ||
) -> None: | ||
"""Initialize a Runner instance.""" | ||
self.rules = rules | ||
|
@@ -127,7 +127,7 @@ def worker(lintable: Lintable) -> List[MatchError]: | |
files = [value for n, value in enumerate(files) if value not in files[:n]] | ||
|
||
for file in self.lintables: | ||
if str(file.path) in self.checked_files: | ||
if file in self.checked_files: | ||
continue | ||
_logger.debug( | ||
"Examining %s of type %s", | ||
|
@@ -140,7 +140,7 @@ def worker(lintable: Lintable) -> List[MatchError]: | |
) | ||
|
||
# update list of checked files | ||
self.checked_files.update([str(x.path) for x in self.lintables]) | ||
self.checked_files.update(self.lintables) | ||
|
||
# remove any matches made inside excluded files | ||
matches = list( | ||
|
@@ -174,7 +174,7 @@ def _get_matches(rules: "RulesCollection", options: "Namespace") -> LintResult: | |
lintables = ansiblelint.utils.get_lintables(options=options, args=options.lintables) | ||
|
||
matches = list() | ||
checked_files: Set[str] = set() | ||
checked_files: Set[Lintable] = set() | ||
runner = Runner( | ||
*lintables, | ||
rules=rules, | ||
|
@@ -189,4 +189,12 @@ def _get_matches(rules: "RulesCollection", options: "Namespace") -> LintResult: | |
# Assure we do not print duplicates and the order is consistent | ||
matches = sorted(set(matches)) | ||
|
||
# Convert reported filenames into human redable ones, so we hide the | ||
# fact we used temporary files when processing input from stdin. | ||
for match in matches: | ||
for lintable in lintables: | ||
Comment on lines
+194
to
+195
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about using an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really as I do also have the break. |
||
if match.filename == lintable.filename: | ||
match.filename = lintable.name | ||
break | ||
|
||
return LintResult(matches=matches, files=checked_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be kept in-memory instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope because I do need to feed
ansible-playbook --syntax-check
a file. The rest of the linter code could work fine with in-memory files, but not ansible itself.