Skip to content

Commit

Permalink
fix: code climate report need severity
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkcup committed Oct 15, 2022
1 parent 2823ec6 commit 15003f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/printers/codeclimate.go
Expand Up @@ -40,6 +40,7 @@ func (p CodeClimate) Print(ctx context.Context, issues []result.Issue) error {
codeClimateIssue.Location.Path = issue.Pos.Filename
codeClimateIssue.Location.Lines.Begin = issue.Pos.Line
codeClimateIssue.Fingerprint = issue.Fingerprint()
codeClimateIssue.Severity = "critical"

if issue.Severity != "" {
codeClimateIssue.Severity = issue.Severity
Expand Down
17 changes: 16 additions & 1 deletion pkg/printers/codeclimate_test.go
Expand Up @@ -42,6 +42,21 @@ func TestCodeClimate_Print(t *testing.T) {
Column: 9,
},
},
{
FromLinter: "linter-c",
Text: "issue c",
SourceLines: []string{
"func foo() {",
"\tfmt.Println(\"ccc\")",
"}",
},
Pos: token.Position{
Filename: "path/to/filec.go",
Offset: 6,
Line: 200,
Column: 2,
},
},
}

buf := new(bytes.Buffer)
Expand All @@ -51,7 +66,7 @@ func TestCodeClimate_Print(t *testing.T) {
require.NoError(t, err)

//nolint:lll
expected := `[{"description":"linter-a: some issue","severity":"warning","fingerprint":"BA73C5DF4A6FD8462FFF1D3140235777","location":{"path":"path/to/filea.go","lines":{"begin":10}}},{"description":"linter-b: another issue","severity":"error","fingerprint":"0777B4FE60242BD8B2E9B7E92C4B9521","location":{"path":"path/to/fileb.go","lines":{"begin":300}}}]`
expected := `[{"description":"linter-a: some issue","severity":"warning","fingerprint":"BA73C5DF4A6FD8462FFF1D3140235777","location":{"path":"path/to/filea.go","lines":{"begin":10}}},{"description":"linter-b: another issue","severity":"error","fingerprint":"0777B4FE60242BD8B2E9B7E92C4B9521","location":{"path":"path/to/fileb.go","lines":{"begin":300}}},{"description":"linter-c: issue c","severity":"critical","fingerprint":"BEE6E9FBB6BFA4B7DB9FB036697FB036","location":{"path":"path/to/filec.go","lines":{"begin":200}}}]`

assert.Equal(t, expected, buf.String())
}

0 comments on commit 15003f9

Please sign in to comment.