Skip to content

Commit

Permalink
Make results non null
Browse files Browse the repository at this point in the history
  • Loading branch information
owenrumney committed Apr 27, 2021
1 parent e0af797 commit 2c3c659
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions sarif/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Run struct { // https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01/sari
Tool Tool `json:"tool"`
Invocations []*Invocation `json:"invocations,omitempty"`
Artifacts []*Artifact `json:"artifacts,omitempty"`
Results []*Result `json:"results"`
Results []Result `json:"results"`
Properties Properties `json:"properties,omitempty"`
}

Expand Down Expand Up @@ -67,7 +67,7 @@ func (run *Run) AddRule(ruleID string) *Rule {
// AddResult returns an existing Result or creates a new one and returns a pointer to it
func (run *Run) AddResult(ruleID string) *Result {
result := newRuleResult(ruleID)
run.Results = append(run.Results, result)
run.Results = append(run.Results, *result)
return result
}

Expand All @@ -91,7 +91,7 @@ func (run *Run) GetRuleById(ruleId string) (*Rule, error) {
func (run *Run) GetResultByRuleId(ruleId string) (*Result, error) {
for _, result := range run.Results {
if *result.RuleID == ruleId {
return result, nil
return &result, nil
}
}
return nil, fmt.Errorf("couldn't find a result for rule %s", ruleId)
Expand Down
2 changes: 1 addition & 1 deletion test/run_stage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func newRunTest(t *testing.T) (*runTest, *runTest, *runTest) {
run: &sarif.Run{
Tool: sarif.Tool{},
Artifacts: []*sarif.Artifact{},
Results: []*sarif.Result{},
Results: []sarif.Result{},
},
}
return r, r, r
Expand Down

0 comments on commit 2c3c659

Please sign in to comment.