Skip to content

Commit ab1a78c

Browse files
refactor: use utils.SarifReport in semgrepRunner.go
- Updated semgrepRunner.go to utilize the SarifReport structure from the utils package, improving code organization and maintainability. - Removed the local definition of SarifReport to streamline the codebase.
1 parent 810a141 commit ab1a78c

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

tools/semgrepRunner.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,17 @@ package tools
22

33
import (
44
"codacy/cli-v2/config"
5+
"codacy/cli-v2/utils"
56
"encoding/json"
67
"fmt"
78
"os"
89
"os/exec"
910
"path/filepath"
1011
)
1112

12-
// SarifReport represents the structure of a SARIF report
13-
type SarifReport struct {
14-
Version string `json:"version"`
15-
Schema string `json:"$schema"`
16-
Runs []struct {
17-
Tool struct {
18-
Driver struct {
19-
Name string `json:"name"`
20-
Rules []any `json:"rules,omitempty"`
21-
} `json:"driver"`
22-
} `json:"tool"`
23-
Results []any `json:"results"`
24-
Invocations []any `json:"invocations,omitempty"`
25-
} `json:"runs"`
26-
}
27-
2813
// filterRuleDefinitions removes rule definitions from SARIF output
2914
func filterRuleDefinitions(sarifData []byte) ([]byte, error) {
30-
var report SarifReport
15+
var report utils.SarifReport
3116
if err := json.Unmarshal(sarifData, &report); err != nil {
3217
return nil, fmt.Errorf("failed to parse SARIF data: %w", err)
3318
}

0 commit comments

Comments
 (0)