-
Notifications
You must be signed in to change notification settings - Fork 59
feat: provide Codeclimate compatible report fromat #367
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
feat: provide Codeclimate compatible report fromat #367
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #367 +/- ##
==========================================
+ Coverage 84.89% 87.10% +2.21%
==========================================
Files 8 9 +1
Lines 695 636 -59
==========================================
- Hits 590 554 -36
+ Misses 81 56 -25
- Partials 24 26 +2 ☔ View full report in Codecov by Sentry. |
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.
Looks generally good and like it adheres to the specification you left in the comment. Thanks for turning that ugly if...elseif..else
into a switch
- I totally forgot to think about if that feature is available in golang when writing it.. ;)
However I'd like to see tests for demonstrating it in action and proving correctness.
Furthermore I think you should disable the verbose and debug logging when config.Format == codeclimate
- else anyone trying to debug will surround the JSON output with unparsable noise.
Also I thought about, if one should maybe turn the codeclimate generation into a method of ValidationErrors
, which only runs ConsolidateErrors
and returns the JSON.
In that regard, I was wondering lately, if it would be better to split FormatErrors
into per-output-format functions, and change their interface towards main()
to utilize an io.Writer. But that could easily be another PR once this one is merged.
👍
An easier solution from my perspective would be to just log non-standard messages (so debug, error, etc) on stderr instead of stdout. Then one can easily just use
I was also not really happy with how a single function would grow per added format but did not want to refactor that completely in my PR that just wants to add a single format. |
It's actually fairly easy to use: you just demonstrate calling your code in error_test.go and hand the result of calling |
1c5011d
to
b6d0ce5
Compare
Done 🙂 |
The ci is waiting for an approval before running? https://github.com/editorconfig-checker/editorconfig-checker/actions/runs/10736321284 |
Indeed, the CI is waiting to be approved by a maintainer of the repo (so sadly I cannot trigger it). |
Oh, just noticed you overlooked the same places in the README and cmd/main.go argument help as me, which show the available output formats. |
CI already ran so someone needs to have pressed the button. |
Provide code quality report as JSON according to Code Climate specificiation. This is need when using the editorconfig-checker in GitLab CI. editorconfig-checker#365 editorconfig-checker#365
b6d0ce5
to
dee883a
Compare
Thanks, I have fixed it and also provided a nicely formatted example output 🙂 |
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.
Thank you!
LGTM!
@@ -127,7 +127,9 @@ func main() { | |||
errorCount := len(formattedErrors) | |||
if errorCount != 0 { | |||
config.Logger.PrintLogMessages(formattedErrors) | |||
config.Logger.Error(fmt.Sprintf("\n%d errors found", errorCount)) | |||
if config.Format != "codeclimate" { |
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.
I would add a comment to explain why you disable the log
@@ -127,7 +127,9 @@ func main() { | |||
errorCount := len(formattedErrors) | |||
if errorCount != 0 { | |||
config.Logger.PrintLogMessages(formattedErrors) | |||
config.Logger.Error(fmt.Sprintf("\n%d errors found", errorCount)) | |||
if config.Format != "codeclimate" { |
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.
I would like to suggest adding a constant for code climate
This way code that relies on this value could be easily identified
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.
I would take it on me to split FormatErrors
into multiple independent functions once this PR is merged. Now with a fourth format supported this evergrowing function is too hard to read.
I also wondered if there was a neat way to represent the collection of possible output formats, so that the argument parsing code can discover the possible formats without us having to every time adjust it by hand.
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.
I would love that
It would help to have a type and a method to list all the formats.
The fact this code has to be maintained is q bit a pain
flag.StringVar(&c.Format, "format", "default", "specify the output format: default, gcc, github-actions, codeclimate")
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.
Opened #374 to remind me of the refactoring.
Reading up on golang, I somehow did not find any mention how to implement essentially an enum type. @ccoVeille do you have seen anything alike in the past?
I've merged this PR, as it seems like it was ready to go. 😄 Feel free to open follow up PRs for refactoring. |
…/cmd/editorconfig-checker to v3.1.1 (forgejo) (#6520) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) | minor | `v3.0.3` -> `v3.1.1` | --- ### Release Notes <details> <summary>editorconfig-checker/editorconfig-checker (github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker)</summary> ### [`v3.1.1`](https://github.com/editorconfig-checker/editorconfig-checker/releases/tag/v3.1.1) [Compare Source](editorconfig-checker/editorconfig-checker@v3.1.0...v3.1.1) ##### Bug Fixes - dockerfile expected binary at /, not /usr/bin/ [#​410](editorconfig-checker/editorconfig-checker#410) ([#​411](editorconfig-checker/editorconfig-checker#411)) ([2c82197](editorconfig-checker/editorconfig-checker@2c82197)) ### [`v3.1.0`](https://github.com/editorconfig-checker/editorconfig-checker/releases/tag/v3.1.0) [Compare Source](editorconfig-checker/editorconfig-checker@v3.0.3...v3.1.0) ##### Features - add zip version when compressing all binaries ([#​321](editorconfig-checker/editorconfig-checker#321)) ([#​362](editorconfig-checker/editorconfig-checker#362)) ([f1bb625](editorconfig-checker/editorconfig-checker@f1bb625)) - consolidate adjacent error messages ([#​360](editorconfig-checker/editorconfig-checker#360)) ([cf4ae1c](editorconfig-checker/editorconfig-checker@cf4ae1c)) - editorconfig-checker-disable-next-line ([#​363](editorconfig-checker/editorconfig-checker#363)) ([6116ec6](editorconfig-checker/editorconfig-checker@6116ec6)) - provide Codeclimate compatible report fromat ([#​367](editorconfig-checker/editorconfig-checker#367)) ([282c315](editorconfig-checker/editorconfig-checker@282c315)) - support `.editorconfig-checker.json` config ([#​375](editorconfig-checker/editorconfig-checker#375)) ([cb0039c](editorconfig-checker/editorconfig-checker@cb0039c)) ##### Bug Fixes - actually use the correct end marker ([#​405](editorconfig-checker/editorconfig-checker#405)) ([3c03499](editorconfig-checker/editorconfig-checker@3c03499)) - add `.ecrc` deprecation warning ([#​389](editorconfig-checker/editorconfig-checker#389)) ([d33b81c](editorconfig-checker/editorconfig-checker@d33b81c)) - this release-please marker ([#​403](editorconfig-checker/editorconfig-checker#403)) ([617c6d4](editorconfig-checker/editorconfig-checker@617c6d4)) - typo in config, `SpacesAftertabs` => `SpacesAfterTabs` ([#​386](editorconfig-checker/editorconfig-checker#386)) ([25e3542](editorconfig-checker/editorconfig-checker@25e3542)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "* 0-3 * * *" (UTC), Automerge - "* 0-3 * * *" (UTC). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS45My4wIiwidXBkYXRlZEluVmVyIjoiMzkuOTMuMCIsInRhcmdldEJyYW5jaCI6ImZvcmdlam8iLCJsYWJlbHMiOlsiZGVwZW5kZW5jeS11cGdyYWRlIiwidGVzdC9ub3QtbmVlZGVkIl19--> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6520 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Renovate Bot <forgejo-renovate-action@forgejo.org> Co-committed-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
Provide code quality report as JSON according to Code Climate specificiation. This is need when using the editorconfig-checker in GitLab CI.
More details: #365