Skip to content

Commit

Permalink
lint: update linter settings to eliminate false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Dec 17, 2024
1 parent f25941d commit e5fdc0a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 17 deletions.
64 changes: 50 additions & 14 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
linters-settings:
govet:
check-shadowing: true
shadow: true
golint:
min-confidence: 0
min-confidence: 0.6
gocyclo:
min-complexity: 15
maligned:
Expand All @@ -24,44 +24,80 @@ linters-settings:
disabled-checks:
- wrapperFunc
- hugeParam
- rangeValCopy

linters:
disable-all: true
enable:
- megacheck
- revive
- govet
- unconvert
- megacheck
- gas
- gocyclo
- dupl
- misspell
- gosec
- unparam
- unused
- typecheck
- ineffassign
- stylecheck
- gochecknoinits
- exportloopref
- gocritic
- nakedret
- gosimple
- prealloc

fast: false
disable-all: true


run:
output:
format: tab
skip-dirs:
- vendor
concurrency: 4

issues:
exclude-dirs:
- vendor
exclude-rules:
- text: "should have a package comment, unless it's in another file for this package"
linters:
- golint
- text: "exitAfterDefer:"
linters:
- gocritic
- text: "whyNoLint: include an explanation for nolint directive"
linters:
- gocritic
- text: "go.mongodb.org/mongo-driver/bson/primitive.E"
linters:
- govet
- text: "weak cryptographic primitive"
linters:
- gosec
- text: "integer overflow conversion"
linters:
- gosec
- text: "should have a package comment"
linters:
- revive
- text: "at least one file in a package should have a package comment"
linters:
- stylecheck
- text: "commentedOutCode: may want to remove commented-out code"
linters:
- gocritic
- text: "unnamedResult: consider giving a name to these results"
linters:
- gocritic
- text: "var-naming: don't use an underscore in package name"
linters:
- revive
- text: "should not use underscores in package names"
linters:
- stylecheck
- text: "struct literal uses unkeyed fields"
linters:
- govet
- linters:
- unparam
- unused
- revive
path: _test\.go$
text: "unused-parameter"
exclude-use-default: false

4 changes: 2 additions & 2 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Func func(format string, args ...interface{})
func (f Func) Logf(format string, args ...interface{}) { f(format, args...) }

// NoOp logger
var NoOp = Func(func(format string, args ...interface{}) {})
var NoOp = Func(func(format string, args ...interface{}) {}) //nolint:revive

// Std logger sends to std default logger directly
var Std = Func(func(format string, args ...interface{}) { stdlog.Printf(format, args...) })
Expand All @@ -30,7 +30,7 @@ func Printf(format string, args ...interface{}) {

// Print simplifies replacement of std logger
func Print(line string) {
def.logf(line)
def.logf(line) //nolint:govet
}

// Fatalf simplifies replacement of std logger
Expand Down
2 changes: 1 addition & 1 deletion logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func TestLoggerWithPanic(t *testing.T) {
assert.Equal(t, 1, fatalCalls)
assert.Equal(t, "2018/01/07 13:02:34.000 PANIC (lgr.TestLoggerWithPanic) oh my, panic now! bad thing happened\n", rout.String())

t.Logf(rerr.String())
t.Logf(rerr.String()) //nolint:govet
assert.True(t, strings.HasPrefix(rerr.String(), "2018/01/07 13:02:34.000 PANIC"))
assert.Contains(t, rerr.String(), "github.com/go-pkgz/lgr.getDump")
assert.Contains(t, rerr.String(), "/lgr/logger.go:")
Expand Down

0 comments on commit e5fdc0a

Please sign in to comment.