Skip to content

Commit

Permalink
🌱 make maintained values keys constants (ossf#3700)
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Korczynski <[email protected]>
Co-authored-by: Raghav Kaul <[email protected]>
  • Loading branch information
AdamKorcz and raghavkaul authored Nov 28, 2023
1 parent 04ea8be commit 6857320
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions checks/evaluation/maintained.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ func Maintained(name string,
if f.Outcome == finding.OutcomePositive {
switch f.Probe {
case issueActivityByProjectMember.Probe:
numberOfIssuesUpdatedWithinThreshold = f.Values["numberOfIssuesUpdatedWithinThreshold"]
numberOfIssuesUpdatedWithinThreshold = f.Values[issueActivityByProjectMember.NoOfIssuesValue]
case hasRecentCommits.Probe:
commitsWithinThreshold = f.Values["commitsWithinThreshold"]
commitsWithinThreshold = f.Values[hasRecentCommits.CommitsValue]
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions probes/hasRecentCommits/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ import (
var fs embed.FS

const (
lookBackDays = 90
lookBackDays = 90
CommitsValue = "commitsWithinThreshold"
LookBackValue = "lookBackDays"
)

const Probe = "hasRecentCommits"
Expand Down Expand Up @@ -60,8 +62,8 @@ func Run(raw *checker.RawResults) ([]finding.Finding, string, error) {
return nil, Probe, fmt.Errorf("create finding: %w", err)
}
f = f.WithValues(map[string]int{
"commitsWithinThreshold": commitsWithinThreshold,
"lookBackDays": 90,
CommitsValue: commitsWithinThreshold,
LookBackValue: lookBackDays,
})
findings = append(findings, *f)
} else {
Expand Down
5 changes: 3 additions & 2 deletions probes/issueActivityByProjectMember/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import (
var fs embed.FS

const (
lookBackDays = 90
lookBackDays = 90
NoOfIssuesValue = "numberOfIssuesUpdatedWithinThreshold"
)

const Probe = "issueActivityByProjectMember"
Expand Down Expand Up @@ -60,7 +61,7 @@ func Run(raw *checker.RawResults) ([]finding.Finding, string, error) {
return nil, Probe, fmt.Errorf("create finding: %w", err)
}
f = f.WithValues(map[string]int{
"numberOfIssuesUpdatedWithinThreshold": numberOfIssuesUpdatedWithinThreshold,
NoOfIssuesValue: numberOfIssuesUpdatedWithinThreshold,
})
findings = append(findings, *f)
} else {
Expand Down

0 comments on commit 6857320

Please sign in to comment.