From 50a155ddb201eecae00d6d5ab13b7eb53174f78c Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Tue, 29 Jun 2021 00:05:11 +0200 Subject: [PATCH] Lint: Update linter list, disable gomnd for some lines Signed-off-by: Knut Ahlers --- .golangci.yml | 2 +- action_counter.go | 2 +- config.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f78879c..30378a0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -38,7 +38,6 @@ linters: - godox # Tool for detection of FIXME, TODO and other comment keywords [fast: true, auto-fix: false] - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true] - goimports # Goimports does everything that gofmt does. Additionally it checks unused imports [fast: true, auto-fix: true] - - golint # Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes [fast: true, auto-fix: false] - gomnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false] - gosec # Inspects source code for security problems [fast: true, auto-fix: false] - gosimple # Linter for Go source code that specializes in simplifying a code [fast: true, auto-fix: false] @@ -48,6 +47,7 @@ linters: - nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false] - noctx # noctx finds sending http request without context.Context [fast: true, auto-fix: false] - nolintlint # Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: false] + - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false] - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: true, auto-fix: false] - structcheck # Finds unused struct fields [fast: true, auto-fix: false] - stylecheck # Stylecheck is a replacement for golint [fast: true, auto-fix: false] diff --git a/action_counter.go b/action_counter.go index fd0ea5e..dd16887 100644 --- a/action_counter.go +++ b/action_counter.go @@ -33,7 +33,7 @@ func (a ActorCounter) Execute(c *irc.Client, m *irc.Message, r *Rule) error { return errors.Wrap(err, "execute counter value template") } - counterValue, err := strconv.ParseInt(parseValue, 10, 64) + counterValue, err := strconv.ParseInt(parseValue, 10, 64) //nolint:gomnd // Those numbers are static enough if err != nil { return errors.Wrap(err, "parse counter value") } diff --git a/config.go b/config.go index 2bed3bd..4b3d9a7 100644 --- a/config.go +++ b/config.go @@ -78,10 +78,10 @@ func loadConfig(filename string) error { if err = config.CloseRawMessageWriter(); err != nil { return errors.Wrap(err, "closing old raw log writer") } - if err = os.MkdirAll(path.Dir(tmpConfig.RawLog), 0o755); err != nil { + if err = os.MkdirAll(path.Dir(tmpConfig.RawLog), 0o755); err != nil { //nolint:gomnd // This is a common directory permission return errors.Wrap(err, "creating directories for raw log") } - if tmpConfig.rawLogWriter, err = os.OpenFile(tmpConfig.RawLog, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644); err != nil { + if tmpConfig.rawLogWriter, err = os.OpenFile(tmpConfig.RawLog, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644); err != nil { //nolint:gomnd // This is a common file permission return errors.Wrap(err, "opening raw log for appending") } }