Skip to content

Commit da029a6

Browse files
fix linter
1 parent c3ae34e commit da029a6

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

engine/detect/baseline.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import (
99
"github.com/zricethezav/gitleaks/v8/report"
1010
)
1111

12-
func IsNew(finding report.Finding, redact uint, baseline []report.Finding) bool {
12+
//nolint:gocyclo // TODO: refactor this function to reduce cyclomatic complexity
13+
func IsNew(finding *report.Finding, redact uint, baseline []report.Finding) bool {
1314
// Explicitly testing each property as it gives significantly better performance in comparison to cmp.Equal(). Drawback is that
1415
// the code requires maintenance if/when the Finding struct changes
15-
for _, b := range baseline {
16+
for i := range baseline {
17+
b := &baseline[i]
1618
if finding.RuleID == b.RuleID &&
1719
finding.Description == b.Description &&
1820
finding.StartLine == b.StartLine &&
@@ -26,7 +28,7 @@ func IsNew(finding report.Finding, redact uint, baseline []report.Finding) bool
2628
finding.Email == b.Email &&
2729
finding.Date == b.Date &&
2830
finding.Message == b.Message &&
29-
// Omit checking finding.Fingerprint - if the format of the fingerprint changes, the users will see unexpected behaviour
31+
// Omit checking finding.Fingerprint - if the format of the fingerprint changes, the users will see unexpected behavior
3032
finding.Entropy == b.Entropy {
3133
return false
3234
}
@@ -49,7 +51,7 @@ func LoadBaseline(baselinePath string) ([]report.Finding, error) {
4951
return previousFindings, nil
5052
}
5153

52-
func (d *Detector) AddBaseline(baselinePath string, source string) error {
54+
func (d *Detector) AddBaseline(baselinePath, source string) error {
5355
if baselinePath != "" {
5456
absoluteSource, err := filepath.Abs(source)
5557
if err != nil {
@@ -73,7 +75,6 @@ func (d *Detector) AddBaseline(baselinePath string, source string) error {
7375

7476
d.baseline = baseline
7577
baselinePath = relativeBaseline
76-
7778
}
7879

7980
d.baselinePath = baselinePath

engine/detect/detect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ func (d *Detector) AddFinding(finding *report.Finding) {
731731
}
732732
}
733733

734-
if d.baseline != nil && !IsNew(*finding, d.Redact, d.baseline) {
734+
if d.baseline != nil && !IsNew(finding, d.Redact, d.baseline) {
735735
logger.Debug().
736736
Str("fingerprint", finding.Fingerprint).
737737
Msgf("skipping finding: baseline")

0 commit comments

Comments
 (0)