Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type StaticCheckEntry struct {
}

type GitlabCIEntry struct {
CheckName string `json:"check_name"`
Description string `json:"description"`
Fingerprint string `json:"fingerprint"`
Severity string `json:"severity"`
Expand All @@ -45,9 +46,10 @@ func main() {
}

var gitlabEntry GitlabCIEntry
gitlabEntry.CheckName = entry.Code
gitlabEntry.Description = entry.Message
gitlabEntry.Fingerprint = fmt.Sprintf("%s%s%d%d", entry.Code, entry.Location.File, entry.Location.Line, entry.Location.Column)
gitlabEntry.Severity = entry.Severity
gitlabEntry.Severity = staticcheckSevToGitlabSev(entry.Severity)

gitlabEntry.Location.Path = getRelativePath(entry.Location.File)
gitlabEntry.Location.Lines.Begin = entry.Location.Line
Expand All @@ -71,3 +73,18 @@ func getRelativePath(absolutePath string) string {
}
return strings.ReplaceAll(absolutePath, path+"/", "")
}

func staticcheckSevToGitlabSev(scSev string) string {
// Staticcheck severities pulled from here: https://github.com/dominikh/go-tools/blob/915b568982be0ad65a98e822471748b328240ed0/lintcmd/lint.go#L373
// Gitlab severities pulled from here: https://docs.gitlab.com/ee/ci/testing/code_quality.html#implement-a-custom-tool
switch scSev {
case "ignored":
return "info"
case "warning":
return "minor"
case "error":
return "major"
default:
return scSev
}
}