Golangci-lint does not lint for all files inside subdirectories #4880
-
Welcome
Description of the problemWhen I run Go version: 1.22.3 Version of golangci-lint$ golangci-lint --version
golangci-lint has version 1.59.0 built with go1.22.3 from 2059b18 on 2024-05-25T11:38:08Z ConfigurationGo environment$ go version && go env
go version go1.22.3 darwin/arm64
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/***/go-build'
GOENV='/***/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/***/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/***/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.22.3/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.3/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.3'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/path/to/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/1n/pp4nqn4d71sb1bqcb7pnsk9w0000gp/T/go-build3223765096=/tmp/go-build -gno-record-gcc-switches -fno-common' Verbose output of running$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/viral.doshi/Desktop/Repos/factorycommon /Users/viral.doshi/Desktop/Repos /Users/viral.doshi/Desktop /Users/viral.doshi /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 75 linters: [asasalint asciicheck bidichk bodyclose canonicalheader dogsled dupl dupword durationcheck errcheck errchkjson errname exhaustive exportloopref fatcontext funlen gci ginkgolinter gocheckcompilerdirectives gochecknoglobals gochecknoinits gochecksumtype gocognit goconst gocritic gocyclo godot gofmt goheader goimports gomoddirectives gomodguard goprintffuncname gosec gosimple gosmopolitan govet grouper importas inamedparam ineffassign interfacebloat lll loggercheck maintidx makezero mirror misspell nakedret nilerr nonamedreturns nosprintfhostport prealloc predeclared promlinter protogetter reassign revive rowserrcheck sloglint spancheck sqlclosecheck staticcheck stylecheck tagalign tenv testableexamples tparallel unconvert unparam unused usestdlibvars wastedassign whitespace zerologlint]
INFO [loader] Go packages loading at mode 575 (imports|compiled_files|files|name|types_sizes|deps|exports_file) took 1.120000542s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 6.804959ms
INFO [linters_context] importas settings found, but no aliases listed. List aliases under alias: key.
INFO [linters_context/goanalysis] analyzers took 1m54.952353336s with top 10 stages: gocritic: 1m14.335213206s, the_only_name: 10.311426082s, dupl: 1.774694247s, buildir: 1.598236252s, wastedassign: 1.241936665s, gofmt: 715.243963ms, unconvert: 700.358957ms, goimports: 639.471876ms, buildssa: 542.03679ms, bidichk: 541.755208ms
INFO [runner] Issues before processing: 19030, after processing: 0
INFO [runner] Processors filtering stat (out/in): skip_files: 13145/13145, cgo: 19030/19030, exclude: 13145/13145, invalid_issue: 13145/19030, skip_dirs: 13145/13145, autogenerated_exclude: 13145/13145, nolint: 0/13145, filename_unadjuster: 19030/19030, path_prettifier: 13145/13145, identifier_marker: 13145/13145, exclude-rules: 13145/13145
INFO [runner] processing took 311.86533ms with stages: exclude-rules: 207.909374ms, identifier_marker: 96.269458ms, path_prettifier: 3.174124ms, nolint: 2.051792ms, skip_dirs: 843.209µs, cgo: 623.499µs, autogenerated_exclude: 432.375µs, filename_unadjuster: 344.541µs, invalid_issue: 214.916µs, max_same_issues: 709ns, skip_files: 250ns, uniq_by_line: 167ns, sort_results: 167ns, fixer: 166ns, diff: 125ns, exclude: 125ns, max_from_linter: 84ns, path_shortener: 84ns, source_code: 42ns, path_prefixer: 41ns, severity-rules: 41ns, max_per_file_from_linter: 41ns
INFO [runner] linters took 9.50068575s with stages: goanalysis_metalinter: 9.188516875s
INFO File cache stats: 131 entries of total size 970.2KiB
INFO Memory: 108 samples, avg is 964.8MB, max is 1523.8MB
INFO Execution took 10.651645833s A minimal reproducible example or link to a public repositoryWorks when I run it on individual files golangci-lint run ./coommon.go -v -c ./.golangci.yml
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 75 linters: [asasalint asciicheck bidichk bodyclose canonicalheader dogsled dupl dupword durationcheck errcheck errchkjson errname exhaustive exportloopref fatcontext funlen gci ginkgolinter gocheckcompilerdirectives gochecknoglobals gochecknoinits gochecksumtype gocognit goconst gocritic gocyclo godot gofmt goheader goimports gomoddirectives gomodguard goprintffuncname gosec gosimple gosmopolitan govet grouper importas inamedparam ineffassign interfacebloat lll loggercheck maintidx makezero mirror misspell nakedret nilerr nonamedreturns nosprintfhostport prealloc predeclared promlinter protogetter reassign revive rowserrcheck sloglint spancheck sqlclosecheck staticcheck stylecheck tagalign tenv testableexamples tparallel unconvert unparam unused usestdlibvars wastedassign whitespace zerologlint]
INFO [loader] Go packages loading at mode 575 (imports|types_sizes|exports_file|files|name|compiled_files|deps) took 31.592084ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 5.958µs
INFO [linters_context] importas settings found, but no aliases listed. List aliases under alias: key.
ERRO [linters_context] typechecking error: stat /Users/viral.doshi/Desktop/Repos/factorycommon/coommon.go: directory not found
INFO [linters_context/goanalysis] analyzers took 7.535205ms with top 10 stages: buildir: 858.958µs, fact_deprecated: 571.792µs, buildssa: 414.834µs, findcall: 392.5µs, cgocall: 340.083µs, the_only_name: 291.167µs, inspect: 268.708µs, gocritic: 190.459µs, ST1012: 179.625µs, typecheck: 175.459µs
INFO [runner] processing took 1.916µs with stages: max_same_issues: 584ns, nolint: 416ns, sort_results: 250ns, skip_dirs: 167ns, max_from_linter: 167ns, filename_unadjuster: 42ns, cgo: 42ns, skip_files: 42ns, uniq_by_line: 42ns, invalid_issue: 41ns, identifier_marker: 41ns, exclude-rules: 41ns, fixer: 41ns, path_prefixer: 0s, path_prettifier: 0s, severity-rules: 0s, exclude: 0s, max_per_file_from_linter: 0s, path_shortener: 0s, source_code: 0s, autogenerated_exclude: 0s, diff: 0s
INFO [runner] linters took 349.094875ms with stages: goanalysis_metalinter: 349.069667ms
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 5 samples, avg is 53.5MB, max is 64.1MB
INFO Execution took 396.887292ms Validation
Supporter
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 18 replies
-
I see the errors correctly when I run it for a single file $ golangci-lint run ./coommon.go -v -c ./.golangci.yml
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 75 linters: [asasalint asciicheck bidichk bodyclose canonicalheader dogsled dupl dupword durationcheck errcheck errchkjson errname exhaustive exportloopref fatcontext funlen gci ginkgolinter gocheckcompilerdirectives gochecknoglobals gochecknoinits gochecksumtype gocognit goconst gocritic gocyclo godot gofmt goheader goimports gomoddirectives gomodguard goprintffuncname gosec gosimple gosmopolitan govet grouper importas inamedparam ineffassign interfacebloat lll loggercheck maintidx makezero mirror misspell nakedret nilerr nonamedreturns nosprintfhostport prealloc predeclared promlinter protogetter reassign revive rowserrcheck sloglint spancheck sqlclosecheck staticcheck stylecheck tagalign tenv testableexamples tparallel unconvert unparam unused usestdlibvars wastedassign whitespace zerologlint]
INFO [loader] Go packages loading at mode 575 (imports|types_sizes|exports_file|files|name|compiled_files|deps) took 31.592084ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 5.958µs
INFO [linters_context] importas settings found, but no aliases listed. List aliases under alias: key.
ERRO [linters_context] typechecking error: stat /Users/viral.doshi/Desktop/Repos/factorycommon/coommon.go: directory not found
INFO [linters_context/goanalysis] analyzers took 7.535205ms with top 10 stages: buildir: 858.958µs, fact_deprecated: 571.792µs, buildssa: 414.834µs, findcall: 392.5µs, cgocall: 340.083µs, the_only_name: 291.167µs, inspect: 268.708µs, gocritic: 190.459µs, ST1012: 179.625µs, typecheck: 175.459µs
INFO [runner] processing took 1.916µs with stages: max_same_issues: 584ns, nolint: 416ns, sort_results: 250ns, skip_dirs: 167ns, max_from_linter: 167ns, filename_unadjuster: 42ns, cgo: 42ns, skip_files: 42ns, uniq_by_line: 42ns, invalid_issue: 41ns, identifier_marker: 41ns, exclude-rules: 41ns, fixer: 41ns, path_prefixer: 0s, path_prettifier: 0s, severity-rules: 0s, exclude: 0s, max_per_file_from_linter: 0s, path_shortener: 0s, source_code: 0s, autogenerated_exclude: 0s, diff: 0s
INFO [runner] linters took 349.094875ms with stages: goanalysis_metalinter: 349.069667ms
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 5 samples, avg is 53.5MB, max is 64.1MB
INFO Execution took 396.887292ms $ golangci-lint run ./common.go -v -c ./.golangci.yml
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 75 linters: [asasalint asciicheck bidichk bodyclose canonicalheader dogsled dupl dupword durationcheck errcheck errchkjson errname exhaustive exportloopref fatcontext funlen gci ginkgolinter gocheckcompilerdirectives gochecknoglobals gochecknoinits gochecksumtype gocognit goconst gocritic gocyclo godot gofmt goheader goimports gomoddirectives gomodguard goprintffuncname gosec gosimple gosmopolitan govet grouper importas inamedparam ineffassign interfacebloat lll loggercheck maintidx makezero mirror misspell nakedret nilerr nonamedreturns nosprintfhostport prealloc predeclared promlinter protogetter reassign revive rowserrcheck sloglint spancheck sqlclosecheck staticcheck stylecheck tagalign tenv testableexamples tparallel unconvert unparam unused usestdlibvars wastedassign whitespace zerologlint]
INFO [loader] Go packages loading at mode 575 (compiled_files|deps|imports|types_sizes|exports_file|files|name) took 696.124167ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 488.541µs
INFO [linters_context] importas settings found, but no aliases listed. List aliases under alias: key.
INFO [linters_context/goanalysis] analyzers took 1.29639835s with top 10 stages: the_only_name: 727.953749ms, gocritic: 440.155791ms, modinfo: 17.5255ms, buildir: 15.307005ms, dupl: 9.829042ms, wastedassign: 9.147625ms, unparam: 4.710875ms, buildssa: 4.690042ms, goimports: 4.391667ms, gosec: 4.229209ms
INFO [runner] Processors filtering stat (out/in): cgo: 14/14, path_prettifier: 14/14, autogenerated_exclude: 14/14, exclude: 14/14, uniq_by_line: 14/14, source_code: 14/14, skip_dirs: 14/14, exclude-rules: 14/14, max_same_issues: 14/14, max_from_linter: 14/14, path_shortener: 14/14, severity-rules: 14/14, filename_unadjuster: 14/14, identifier_marker: 14/14, path_prefixer: 14/14, invalid_issue: 14/14, skip_files: 14/14, nolint: 14/14, diff: 14/14, max_per_file_from_linter: 14/14, fixer: 14/14, sort_results: 14/14
INFO [runner] processing took 628.168µs with stages: nolint: 271.541µs, exclude-rules: 123.707µs, identifier_marker: 108.041µs, autogenerated_exclude: 51.792µs, source_code: 35.084µs, path_prettifier: 18.584µs, skip_dirs: 6.125µs, uniq_by_line: 4.667µs, cgo: 2.875µs, filename_unadjuster: 1.416µs, invalid_issue: 1.333µs, path_shortener: 917ns, max_same_issues: 376ns, max_per_file_from_linter: 375ns, severity-rules: 375ns, sort_results: 209ns, skip_files: 167ns, fixer: 167ns, exclude: 167ns, diff: 125ns, max_from_linter: 84ns, path_prefixer: 41ns
INFO [runner] linters took 1.1718785s with stages: goanalysis_metalinter: 1.171200125s
common.go:147:2: preferWriteByte: consider writing single byte rune '\'' with sb.WriteByte('\'') (gocritic)
sb.WriteRune('\'')
^
common.go:153:2: preferWriteByte: consider writing single byte rune '\'' with sb.WriteByte('\'') (gocritic)
sb.WriteRune('\'')
^
common.go:24:68: Comment should end in a period (godot)
// If the program is being run with the "debug" flag, it will panic
^
common.go:156:82: Comment should end in a period (godot)
// Unused can be called to silence compiler warnings with minimal/no side effects
^
common.go:299:86: Comment should end in a period (godot)
// KillProcessByName will kill processes that match the pattern passed as an argument
^
common.go:326:80: Comment should end in a period (godot)
// ErrStdLibFailure indicates an error that occurred in the Go standard library
^
common.go:331:34: Comment should end in a period (godot)
// Error interface implementation
^
common.go:74:50: unnecessary leading newline (whitespace)
^
common.go:109:29: unnecessary leading newline (whitespace)
^
common.go:209:32: unnecessary leading newline (whitespace)
^
common.go:300:47: unnecessary leading newline (whitespace)
^
common.go:327:6: the type name `ErrStdLibFailure` should conform to the `XxxError` format (errname)
type ErrStdLibFailure struct {
^
common.go:103:5: _stackTracePool is a global variable (gochecknoglobals)
var _stackTracePool = sync.Pool{New: func() any {
^
common.go:320:3: error is not nil (line 318) but it returns nil (nilerr)
return nil
^
INFO File cache stats: 2 entries of total size 14.5KiB
INFO Memory: 20 samples, avg is 78.5MB, max is 150.9MB
INFO Execution took 1.883859292s |
Beta Was this translation helpful? Give feedback.
-
Can you provide a minimal reproducible example or link to a public repository? |
Beta Was this translation helpful? Give feedback.
-
From your logs:
This is the root of your problem. |
Beta Was this translation helpful? Give feedback.
From your logs:
This means you have a rule that excludes all the issues.
This means that the
nolint
processor excludes all the issues, so I guess you have anolint
directive at a package level.