Chore: Bump golangci-lint v1.57.1 (#84998)

* bump golangci-lint v1.57.1

* update setting

* remove goconst

* fix linting issues

* prettier

* fix G601

* go mod tidy
go work sync
This commit is contained in:
ismail simsek
2024-03-25 15:28:24 +01:00
committed by GitHub
parent e6fa367d02
commit 6137c4e0a6
16 changed files with 186 additions and 20 deletions

View File

@@ -217,6 +217,7 @@ func (r ruleWithFolder) Fingerprint() fingerprint {
writeBytes(nil)
return
}
// #nosec G103
// avoid allocation when converting string to byte slice
writeBytes(unsafe.Slice(unsafe.StringData(s), len(s)))
}

View File

@@ -198,7 +198,10 @@ func (st DBstore) UpdateAlertRules(ctx context.Context, rules []ngmodels.UpdateR
}
ruleVersions := make([]ngmodels.AlertRuleVersion, 0, len(rules))
for _, r := range rules {
for i := range rules {
// We do indexed access way to avoid "G601: Implicit memory aliasing in for loop."
// Doing this will be unnecessary with go 1.22 https://stackoverflow.com/a/68247837/767660
r := rules[i]
var parentVersion int64
r.New.ID = r.Existing.ID
r.New.Version = r.Existing.Version // xorm will take care of increasing it (see https://xorm.io/docs/chapter-06/1.lock/)