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

Support to output result in multiple formats #481

Closed
fho opened this issue Apr 1, 2019 · 13 comments · Fixed by #2386
Closed

Support to output result in multiple formats #481

fho opened this issue Apr 1, 2019 · 13 comments · Fixed by #2386
Labels
area: config Related to .golangci.yml and/or cli options area: output Related to issue output enhancement New feature or improvement

Comments

@fho
Copy link

fho commented Apr 1, 2019

It would be great if it would be possible to produce results in multiple formats of a run.
This can be useful if you e.g. want to run golangci-lint in CI and send a human-readable output (line-number) in a plain-text report to the user and also have a checkstyle result to process it and show it in the CI tool.

Syntax could be like:

golangcilint run --out-format <FORMAT>:(<FILENAME>|stdout|stderr)[,<FORMAT>:(<FILENAME>|stdout|stderr)]..
@jirfag
Copy link
Member

jirfag commented Apr 20, 2019

Hi!
Looks useful. But I'm interested: did you check existing output formats?

@duckbrain
Copy link

I'm using it in GitLab CI. It displays the stdout in the web interface, and that's the easiest way to see it, but it also accepts the Code Climate output format to keep track of the differences and display how the code improved or regressed in code quality in a merge request. I'm currently doing something like

echo '[]' > codeclimate.json
golangcilint run || golangcilint run --out-format codeclimate > codeclimate.json

So it runs once if everything is good, but runs twice to generate the non empty code climate report otherwise.

@ergbouncex
Copy link

Likewise, it would be useful to have stdout show an easy to read output, and additional output to a file for CI to digest

@fho
Copy link
Author

fho commented Apr 23, 2019

@jirfag

Looks useful. But I'm interested: did you check existing output formats?

Yes, it's not possible to generate output of a single run in multiple formats, is it? :-)

@jirfag
Copy link
Member

jirfag commented Apr 23, 2019

got it, I didn't understand it properly first

@howardjohn
Copy link

+1, very useful as our CI has junit support but we also want standard output

@matoous matoous added the enhancement New feature or improvement label Sep 25, 2019
@tpounds tpounds added the area: config Related to .golangci.yml and/or cli options label Oct 3, 2019
@thaJeztah
Copy link
Contributor

👍 was looking for this as well (logging in human-readable format, and write a junit.xml for Jenkins).

One comment on the proposed format;

--out-format <FORMAT>:(<FILENAME>|stdout|stderr)[,<FORMAT>:(<FILENAME>|stdout|stderr)]..

Using colons (:) and commas as separators could be problematic (e.g, Windows paths will have a colon for the drive-letter, and commas (although unlikely) are valid in filenames. Not impossible to solve, but good to keep in mind.

Alternatives worth considering;

  • reserve --out-format for stderr/stdout, and introduce a new flag for writing to a file (e.g., --output-file junit-xml=C:\foo\junit-report.xml)
  • multiple --output-file flags can be specified, so that no comma separator is needed
  • alternatively, have one flag per format, e.g. --junitfile=/path/to/junit-report.xml (this will introduce many more flags, which may be undesirable)

@stale
Copy link

stale bot commented Apr 9, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale No recent correspondence or work activity label Apr 9, 2020
@fho
Copy link
Author

fho commented Apr 9, 2020

Dear stale bot,

please do not close this issue.

Best wishes,

Fabian

@stale stale bot removed the stale No recent correspondence or work activity label Apr 9, 2020
@jirfag jirfag added the good first issue Good for newcomers label May 17, 2020
@jirfag
Copy link
Member

jirfag commented May 17, 2020

We can add out-formats as a map option out-format: out-file. But it will be a bit complicated to parse it from command line.

Latest golangci-lint version use caching. Maybe it's better for us to focus on sub-second overhead for repeated runs? If we achieve that we can just run golangci-lint multiple times.

@jirfag jirfag removed the good first issue Good for newcomers label May 17, 2020
@fho
Copy link
Author

fho commented May 18, 2020

I think improving caching is definitely more important and running golangci-lint per output might be ok for a lot of users.

We are running golangci-lint per application in a monorepository with ~50x Go-Applications.
In the worst case CI runs the checks for all Go-Applications in a branch.
This would mean to have to run golangci-lint 100 times instead of 50x.
It feels hackish to me to rerun it per output-format without explicit support to only create another report for the last run.
I don't have any numbers to evaluate how big the overhead would be to judge if it really matters, though.

@ergbouncex
Copy link

Still hoping for this feature 🙏

@pseudo-su
Copy link

Is there any idea/indication of when a new release will be created that includes this?

@ldez ldez added the area: output Related to issue output label Jul 16, 2023
@ldez ldez removed this from the v2.0.0 milestone Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: config Related to .golangci.yml and/or cli options area: output Related to issue output enhancement New feature or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants