Skip to content

Commit

Permalink
✨ Add links to rules and issues reports. (#434)
Browse files Browse the repository at this point in the history
Adds `Links` to both: /rules and /applications/:id/issues reports.
hack script adds markdown issue description and links.

Signed-off-by: Jeff Ortel <jortel@redhat.com>
  • Loading branch information
jortel committed Jul 5, 2023
1 parent 36d729b commit 6c00008
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
10 changes: 10 additions & 0 deletions api/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ func (h AnalysisHandler) RuleReports(ctx *gin.Context) {
"i.Category",
"i.Effort",
"i.Labels",
"i.Links",
"COUNT(distinct a.ID) Applications")
q = q.Table("Issue i,")
q = q.Joins("Analysis a")
Expand Down Expand Up @@ -816,6 +817,9 @@ func (h AnalysisHandler) RuleReports(ctx *gin.Context) {
if m.Labels != nil {
_ = json.Unmarshal(m.Labels, &r.Labels)
}
if m.Links != nil {
_ = json.Unmarshal(m.Links, &r.Links)
}
r.Effort += m.Effort
}

Expand Down Expand Up @@ -888,6 +892,7 @@ func (h AnalysisHandler) AppIssueReports(ctx *gin.Context) {
"i.Category",
"i.Effort",
"i.Labels",
"i.Links",
"COUNT(distinct n.File) Files")
q = q.Table("Issue i,")
q = q.Joins("Incident n")
Expand Down Expand Up @@ -937,6 +942,9 @@ func (h AnalysisHandler) AppIssueReports(ctx *gin.Context) {
if m.Labels != nil {
_ = json.Unmarshal(m.Labels, &r.Labels)
}
if m.Links != nil {
_ = json.Unmarshal(m.Links, &r.Links)
}
r.Effort += m.Effort
}

Expand Down Expand Up @@ -1884,6 +1892,7 @@ type RuleReport struct {
Category string `json:"category"`
Effort int `json:"effort"`
Labels []string `json:"labels"`
Links []Link `json:"links"`
Applications int `json:"applications"`
}

Expand All @@ -1898,6 +1907,7 @@ type IssueReport struct {
Category string `json:"category"`
Effort int `json:"effort"`
Labels []string `json:"labels"`
Links []Link `json:"links"`
Files int `json:"files"`
}

Expand Down
18 changes: 17 additions & 1 deletion hack/add/analysis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,30 @@ echo -n "---
ruleset: ruleSet-${r}
rule: rule-${i}
name: Rule-${r}.${i}-Violated
description: This is a test ${r}/${i} violation.
description: |
This is a test ${r}/${i} violation.
This is a **description** of the issue in markdown*.
Here's how to fix the issue.
For example:
This is some bad code.
Should become:
This is some good code.
category: warning
effort: 10
labels:
- RULE-${i}
- RULESET-${r}
- ${sources[$((${i}%${#sources[@]}))]}
- ${targets[$((${i}%${#targets[@]}))]}
links:
- title: Document A
url: http://ruleset/${r}/rule/${i}/documentA.html
- title: Document B
url: http://ruleset/${r}/rule/${i}/documentB.html
incidents:
" >> ${file}
for n in $(seq 1 ${nIncident})
Expand Down

0 comments on commit 6c00008

Please sign in to comment.