https://pantsbuild.org/ logo
#general
Title
# general
l

loud-laptop-17949

11/01/2021, 11:40 PM
Is there any way to have pants write the results of shellcheck and shfmt to a file rather than stdout? I don't think either of those tools have a native option for doing so, and parsing structure results out of the pants output seems a bit tricky.
h

hundreds-father-404

11/01/2021, 11:45 PM
Pants does have generic support for linters/formatters writing "reports", although currently only integrated with tools that have native support like Bandit and MyPy Are you thinking Pants could generate the report for you based on std{out,err}? Definitely feasible
l

loud-laptop-17949

11/01/2021, 11:51 PM
yeah something like that
h

hundreds-father-404

11/01/2021, 11:55 PM
I don't think pantsbuild/pants wants to get in the business of maintaining a report generator for Shellcheck and Shfmt. But, I agree it's really useful and happy to help figure out how to get it working for you! I see two paths forward: 1) Upstream report generation to those tools 2) Create your own report generation logic and develop a Pants plugin that uses it. You'd basically be forking the specific rules for those two linter implementations (not Pants itself), and enriching with your reports. In your rule, you could do things like inspect
std{out,err}
, the changed files from shfmt, etc. And you can create any arbitrary report file(s) based on that
e

enough-analyst-54434

11/02/2021, 12:17 AM
shfmt has -f to write to a file. shellcheck does not but does have a -f --format option where you could pick json and several other formats.
We should probably have an option to use stdout as a "report"; aka report redirection.
👍 1
We could just tee it.
l

loud-laptop-17949

11/02/2021, 2:47 AM
@hundreds-father-404 I am not opposed to forking in principle, but generating reports seems like it would be a common need
2 Views