-
Notifications
You must be signed in to change notification settings - Fork 9
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: support severity threshold #155
Merged
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bd9230b
refactor: rename to remove typo
thisislawatts 10188fd
feat: filter findings output to remove items outside of target severity
thisislawatts ecba52f
fix: load severity-threshold from configuration
thisislawatts 08861e6
feat: filter output by supplied severity threshold
thisislawatts 16cc9d8
fix: unset config after usage
thisislawatts 94f9262
chore: apply formatting
thisislawatts 15052b3
fix: pass test_summary data out of output workflow
thisislawatts bf14419
feat: transform test_summary output to remove results below threshold…
thisislawatts ae09bc7
chore: formatting
thisislawatts 54e40a4
fix: introduce type assertation for getPayload
thisislawatts e803258
chore: centralize filtering and re-use it
PeterSchafer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,16 @@ func RenderTip(str string) string { | |
return fmt.Sprintf("\n💡 Tip\n\n%s", str) | ||
} | ||
|
||
func RenderSummary(summary *json_schemas.TestSummary, orgName string, testPath string) (string, error) { | ||
func reverseSlice(original []string) []string { | ||
reversed := make([]string, 0, len(original)) | ||
for i := len(original) - 1; i >= 0; i-- { | ||
reversed = append(reversed, original[i]) | ||
} | ||
|
||
return reversed | ||
} | ||
|
||
func RenderSummary(summary *json_schemas.TestSummary, orgName string, testPath string, severityMinLevel string) (string, error) { | ||
var buff bytes.Buffer | ||
var summaryTemplate = template.Must(template.New("summary").Parse(`Test Summary | ||
|
||
|
@@ -120,11 +129,18 @@ func RenderSummary(summary *json_schemas.TestSummary, orgName string, testPath s | |
openIssueLabelledCount := "" | ||
ignoredIssueLabelledCount := "" | ||
|
||
slices.Reverse(summary.SeverityOrderAsc) | ||
minLevelPointer := slices.Index(summary.SeverityOrderAsc, severityMinLevel) | ||
reversedSlice := reverseSlice(summary.SeverityOrderAsc) | ||
PeterSchafer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
for _, severity := range summary.SeverityOrderAsc { | ||
for _, severity := range reversedSlice { | ||
for _, result := range summary.Results { | ||
satisfyMinLevel := slices.Index(summary.SeverityOrderAsc, result.Severity) >= minLevelPointer | ||
if result.Severity == severity { | ||
if !satisfyMinLevel { | ||
openIssueLabelledCount += renderInSeverityColor(severity, fmt.Sprintf(" %d %s ", 0, strings.ToUpper(severity))) | ||
ignoredIssueLabelledCount += renderInSeverityColor(severity, fmt.Sprintf(" %d %s ", 0, strings.ToUpper(severity))) | ||
continue | ||
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. question: Design decision will be needed on whether we want to show |
||
} | ||
totalIssueCount += result.Total | ||
openIssueCount += result.Open | ||
ignoredIssueCount += result.Ignored | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
praise: Nice optimisation