(resp *v1pb.CheckReleaseResponse)
| 32 | } |
| 33 | |
| 34 | func WriteReleaseCheckToCodeQualityJSON(resp *v1pb.CheckReleaseResponse) error { |
| 35 | var data []Finding |
| 36 | var warningCount, errorCount int |
| 37 | for _, result := range resp.Results { |
| 38 | for _, advice := range result.Advices { |
| 39 | switch advice.Status { |
| 40 | case v1pb.Advice_WARNING: |
| 41 | warningCount++ |
| 42 | case v1pb.Advice_ERROR: |
| 43 | errorCount++ |
| 44 | default: |
| 45 | continue |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | var riskDetail string |
| 50 | switch resp.RiskLevel { |
| 51 | case v1pb.RiskLevel_LOW: |
| 52 | riskDetail = "🟢 Low" |
| 53 | case v1pb.RiskLevel_MODERATE: |
| 54 | riskDetail = "🟡 Moderate" |
| 55 | case v1pb.RiskLevel_HIGH: |
| 56 | riskDetail = "🔴 High" |
| 57 | default: |
| 58 | riskDetail = "⚪ None" |
| 59 | } |
| 60 | details := fmt.Sprintf(`Summary: • Total Affected Rows: %d |
| 61 | • Overall Risk Level: %s |
| 62 | • Advices Statistics: %d Error(s), %d Warning(s)`, resp.GetAffectedRows(), riskDetail, errorCount, warningCount) |
| 63 | data = append(data, Finding{ |
| 64 | Description: details, |
| 65 | CheckName: "Summary", |
| 66 | Fingerprint: "summary", |
| 67 | Severity: "info", |
| 68 | }) |
| 69 | for _, result := range resp.Results { |
| 70 | for _, advice := range result.Advices { |
| 71 | var severity string |
| 72 | // Valid values are info, minor, major, critical, or blocker. |
| 73 | switch advice.Status { |
| 74 | case v1pb.Advice_WARNING: |
| 75 | severity = "minor" |
| 76 | case v1pb.Advice_ERROR: |
| 77 | severity = "critical" |
| 78 | default: |
| 79 | continue |
| 80 | } |
| 81 | data = append(data, Finding{ |
| 82 | Description: advice.Content, |
| 83 | CheckName: advice.Title, |
| 84 | Fingerprint: fmt.Sprintf("%s#%d", result.File, advice.GetStartPosition().GetLine()), |
| 85 | Severity: severity, |
| 86 | Location: Location{ |
| 87 | Path: result.File, |
| 88 | Lines: Lines{ |
| 89 | Begin: common.ConvertLineToActionLine(int(advice.GetStartPosition().GetLine())), |
| 90 | }, |
| 91 | }, |
no test coverage detected