-
Notifications
You must be signed in to change notification settings - Fork 546
🌱 Format the JSON output #2251
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
🌱 Format the JSON output #2251
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -265,6 +265,7 @@ func fillJSONRawResults(r *jsonScorecardRawResult, raw *checker.RawResults) erro | |
// AsRawJSON exports results as JSON for raw results. | ||
func AsRawJSON(r *pkg.ScorecardResult, writer io.Writer) error { | ||
encoder := json.NewEncoder(writer) | ||
encoder.SetIndent("", " ") | ||
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. same as above comment |
||
out := jsonScorecardRawResult{ | ||
Repo: jsonRepoV2{ | ||
Name: r.Repo.Name, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,7 @@ type JSONScorecardResultV2 struct { | |
// AsJSON exports results as JSON for new detail format. | ||
func (r *ScorecardResult) AsJSON(showDetails bool, logLevel log.Level, writer io.Writer) error { | ||
encoder := json.NewEncoder(writer) | ||
encoder.SetIndent("", " ") | ||
|
||
out := jsonScorecardResult{ | ||
Repo: r.Repo.Name, | ||
|
@@ -125,6 +126,7 @@ func (r *ScorecardResult) AsJSON2(showDetails bool, | |
} | ||
|
||
encoder := json.NewEncoder(writer) | ||
encoder.SetIndent("", " ") | ||
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. There are tools like BigQuery transfers that expect the JSON output to be on a single line. I'm not sure it's our job to prettify the result (breaking change). I fully agree we need more human-friendly results for the badges; but is this the right place for the fix? 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. This is a start. @azeemshaikh38 will this cause breaking charges for BigQuery? 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. For BQ we JSONify the results in a different file (under cron/). Some users may be using this output, though. I would be OK with that since it's not exposed publicly. 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. +1. Very likely that some users get broken by this. 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. OK, If that is the case. I will close it 👍 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. So @azeemshaikh38 If I change the BQ will it be an issue? 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. @azeemshaikh38 We discussed this in our bi-weekly. We agreed formatting the JSON output shouldn't be an issue. |
||
out := JSONScorecardResultV2{ | ||
Repo: jsonRepoV2{ | ||
Name: r.Repo.Name, | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
As far as I know, yes. BQ expects newline delimited JSON and refers to the linked spec.
"Each Line is a Valid JSON Value". I can try to confirm with a test upload, but I expect this to break the BQ transfer. Yeah this breaks BQ transfer:
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.
The files in the API bucket don't get transferred as far as I can tell. Would a pretty-print argument (bool?) be acceptable?