diff --git a/output/formatter.go b/output/formatter.go index e66015b..428661a 100644 --- a/output/formatter.go +++ b/output/formatter.go @@ -117,8 +117,8 @@ func reportSonarqube(rootPaths []string, w io.Writer, data *reportInfo) error { return err } -func convertToSonarIssues(rootPaths []string, data *reportInfo) (sonarIssues, error) { - var si sonarIssues +func convertToSonarIssues(rootPaths []string, data *reportInfo) (*sonarIssues, error) { + si := &sonarIssues{[]sonarIssue{}} for _, issue := range data.Issues { var sonarFilePath string for _, rootPath := range rootPaths { diff --git a/output/formatter_test.go b/output/formatter_test.go index 339d166..d196087 100644 --- a/output/formatter_test.go +++ b/output/formatter_test.go @@ -32,7 +32,7 @@ var _ = Describe("Formatter", func() { NumFound: 0, }, } - want := sonarIssues{ + want := &sonarIssues{ SonarIssues: []sonarIssue{ { EngineID: "gosec", @@ -56,7 +56,7 @@ var _ = Describe("Formatter", func() { issues, err := convertToSonarIssues([]string{rootPath}, data) Expect(err).ShouldNot(HaveOccurred()) - Expect(issues).To(Equal(want)) + Expect(*issues).To(Equal(*want)) }) It("it should parse the report info with files in subfolders", func() { @@ -80,7 +80,7 @@ var _ = Describe("Formatter", func() { NumFound: 0, }, } - want := sonarIssues{ + want := &sonarIssues{ SonarIssues: []sonarIssue{ { EngineID: "gosec", @@ -104,7 +104,7 @@ var _ = Describe("Formatter", func() { issues, err := convertToSonarIssues([]string{rootPath}, data) Expect(err).ShouldNot(HaveOccurred()) - Expect(issues).To(Equal(want)) + Expect(*issues).To(Equal(*want)) }) It("it should not parse the report info for files from other projects", func() { data := &reportInfo{ @@ -127,15 +127,15 @@ var _ = Describe("Formatter", func() { NumFound: 0, }, } - want := sonarIssues{ - SonarIssues: nil, + want := &sonarIssues{ + SonarIssues: []sonarIssue{}, } rootPath := "/home/src/project2" issues, err := convertToSonarIssues([]string{rootPath}, data) Expect(err).ShouldNot(HaveOccurred()) - Expect(issues).To(Equal(want)) + Expect(*issues).To(Equal(*want)) }) It("it should parse the report info for multiple projects projects", func() { @@ -168,7 +168,7 @@ var _ = Describe("Formatter", func() { NumFound: 0, }, } - want := sonarIssues{ + want := &sonarIssues{ SonarIssues: []sonarIssue{ { EngineID: "gosec", @@ -207,7 +207,7 @@ var _ = Describe("Formatter", func() { issues, err := convertToSonarIssues(rootPaths, data) Expect(err).ShouldNot(HaveOccurred()) - Expect(issues).To(Equal(want)) + Expect(*issues).To(Equal(*want)) }) }) })