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

Flake8 output file support. #10371

Merged
merged 10 commits into from Jul 21, 2020
Merged

Flake8 output file support. #10371

merged 10 commits into from Jul 21, 2020

Conversation

asherf
Copy link
Member

@asherf asherf commented Jul 15, 2020

Problem

CI Systems (among other things) can usually pick up output of linters and display them in a more use friendly way (similar idea to junitxml for tests)
Currently, there is no way to have flake8 write the violations it detects to a file (passthru args won't work due to pants engine isolation requirements)

Solution

Add explicit support for the flake8 --output-file paramter and extract the output and write it to the requested directory.
I added this on the top level linter since other linters (pylint & bandit) also have similar capabilities, so we will be able to add similar features to those rules down the line.

@asherf asherf marked this pull request as draft July 15, 2020 20:51
@asherf asherf force-pushed the jerry branch 2 times, most recently from 8d1eac7 to bd8b697 Compare July 15, 2020 23:20
@asherf asherf changed the title WIP Flake8 output file support. Flake8 output file support. Jul 16, 2020
@asherf
Copy link
Member Author

asherf commented Jul 16, 2020

Working on adding tests, but otherwise this is ready. Any feedback @Eric-Arellano @stuhood ?

@asherf asherf marked this pull request as ready for review July 16, 2020 18:02
@asherf
Copy link
Member Author

asherf commented Jul 16, 2020

test added. this is g2g.

Copy link
Sponsor Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Thanks! Just wondering if we can generalize this at all.

Comment on lines 40 to 47
register(
"--output-file",
type=str,
metavar="filename",
default=None,
advanced=True,
help="Redirect report to a file.",
)
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Rather than an output file, could this potentially be an output directory, located on the Lint Goal? That way each linter could emit its output in subdirectories of a shared output directory... and we could probably give it a reasonable default so that reports are always generated.

Since the LintOutputFile type is exposed to the Goal, it would be good to enable more linters to be able to use it (without specifying an output file per linter).

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, updated.
But keep in mind that now we hard code the report file name for each linter in the rule.
Which is not optimal, since each linter has other options to control the format of the file (using pass-thru args or by adding plugins to the requirements).
so the issue there is that the file name will not reflect the format of the file.
We can obviously expose the file name as an option on each linter, but then, a user will have to configure things in two places, which is confusing.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

True... but it feels like whether or not a linter has multiple file formats is a per linter concern... the linter can choose which filename it wants to within the directory. Fine either way.

@asherf asherf requested a review from stuhood July 19, 2020 20:01
@stuhood stuhood merged commit 22cc05f into pantsbuild:master Jul 21, 2020
@asherf asherf deleted the jerry branch July 21, 2020 04:37
Eric-Arellano pushed a commit that referenced this pull request Jul 29, 2020
Similar to #10371

### Problem

CI Systems (among other things) can usually pick up output of linters and display them in a more use friendly way (similar idea to junitxml for tests)
Currently, there is no way to have bandit write the violations it detects to a file (passthru args won't work due to pants engine isolation requirements)

### Solution
Add explicit support for the bandit --output paramter and extract the output and write it to the requested directory.

[ci skip-rust]
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.

None yet

2 participants