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

✨ Add aggregate score to cron JSON #1050

Merged
merged 4 commits into from
Sep 23, 2021
Merged

Conversation

laurentsimon
Copy link
Contributor

@laurentsimon laurentsimon commented Sep 22, 2021

  • Please check if the PR fulfills these requirements

Copy link
Contributor Author

@laurentsimon laurentsimon left a comment

Choose a reason for hiding this comment

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

test

@@ -69,10 +69,21 @@ type jsonScorecardV2 struct {
Commit string `json:"commit"`
}

type jsonFloatScore float64

func (s jsonFloatScore) MarshalJSON() ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might skip this, just X.0 is fine for even ints.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1. Given how floats are represented I'm unsure this will work reliability in every case either.

Copy link
Contributor Author

@laurentsimon laurentsimon Sep 22, 2021

Choose a reason for hiding this comment

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

sure, can do that. I thought it was cleaner without the 0 if it's an int :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

why not keep everything float ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

JSON does not understand the distinction between float and int in general. The schema we export (if users use it) has the field typed as number and not an integer.. so it's not an integer. Removing the .X was mostly esthetic when a human being looks at it. I'm fine to keep all X.Y... it may even be better: I can imagine users make it an int by mistake and only later realize it should be a float.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes that is what i meant, keep everything float.

@@ -128,6 +145,7 @@ func AsJSON2(r *pkg.ScorecardResult, showDetails bool,
},
Date: r.Date.Format("2006-01-02"),
Metadata: r.Metadata,
AggScore: jsonFloatScore(score),
Copy link
Contributor

Choose a reason for hiding this comment

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

AggregateScore in full might be better to avoid confusion.

Copy link
Contributor Author

@laurentsimon laurentsimon Sep 22, 2021

Choose a reason for hiding this comment

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

sure. Note this is not the JSON field name, but just the structure field name. The JSON field is currently called just score. Is that ok?

@@ -69,10 +69,21 @@ type jsonScorecardV2 struct {
Commit string `json:"commit"`
}

type jsonFloatScore float64

func (s jsonFloatScore) MarshalJSON() ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

+1. Given how floats are represented I'm unsure this will work reliability in every case either.

Copy link
Contributor

@inferno-chromium inferno-chromium left a comment

Choose a reason for hiding this comment

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

Thanks for changes.

@@ -69,10 +69,21 @@ type jsonScorecardV2 struct {
Commit string `json:"commit"`
}

type jsonFloatScore float64

func (s jsonFloatScore) MarshalJSON() ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes that is what i meant, keep everything float.

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.

3 participants