Skip to content

exclude-dirs not working #5015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
6 of 7 tasks
nekohasekai opened this issue Sep 14, 2024 · 3 comments
Closed
6 of 7 tasks

exclude-dirs not working #5015

nekohasekai opened this issue Sep 14, 2024 · 3 comments
Labels
question Further information is requested

Comments

@nekohasekai
Copy link

Welcome

  • Yes, I'm using a binary release within 2 latest releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've read the typecheck section of the FAQ.
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.).
  • I agree to follow this project's Code of Conduct

Description of the problem

exclude-dirs seems to be ignored since v1.60.0, the same steps worked fine in v1.59.0 with go1.22.7.

Version of golangci-lint

$ golangci-lint --version
# golangci-lint has version v1.61.0 built with go1.23.1 from (unknown, modified: ?, mod sum: "h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8=") on (unknown)

Configuration

golangci-lint run --exclude-dirs bugpkg

Go environment

$ go version && go env
go version go1.23.1 darwin/arm64
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/sekai/Library/Caches/go-build'
GOENV='/Users/sekai/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/sekai/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/sekai/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.23.1/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.23.1/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/sekai/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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/62/0rdd_81n5jbf6j4w3pcmwycr0000gn/T/go-build3375113623=/tmp/go-build -gno-record-gcc-switches -fno-common'

Verbose output of running

$ golangci-lint cache clean
$  golangci-lint run --exclude-dirs bugpkg/ -v
INFO golangci-lint has version v1.61.0 built with go1.23.1 from (unknown, modified: ?, mod sum: "h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8=") on (unknown) 
INFO [config_reader] Config search paths: [./ /Users/sekai/Projects/lintbug /Users/sekai/Projects /Users/sekai /Users /] 
INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused] 
INFO [loader] Go packages loading at mode 575 (compiled_files|deps|exports_file|imports|files|name|types_sizes) took 80.058458ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 83.375µs 
INFO [linters_context/goanalysis] analyzers took 12.492663ms with top 10 stages: ctrlflow: 874.917µs, fact_deprecated: 609.834µs, printf: 565.625µs, SA4006: 494.626µs, buildir: 494.208µs, SA4000: 467.583µs, timeformat: 366.75µs, inspect: 340.75µs, SA9002: 327.583µs, S1008: 325.626µs 
INFO [runner] Issues before processing: 170, after processing: 1 
INFO [runner] Processors filtering stat (in/out): nolint: 170/170, max_same_issues: 1/1, path_prefixer: 1/1, sort_results: 1/1, autogenerated_exclude: 170/170, path_prettifier: 170/170, skip_files: 170/170, exclude: 170/170, exclude-rules: 170/170, severity-rules: 1/1, invalid_issue: 170/170, diff: 1/1, path_shortener: 1/1, fixer: 1/1, identifier_marker: 170/170, filename_unadjuster: 170/170, skip_dirs: 170/170, uniq_by_line: 170/1, max_per_file_from_linter: 1/1, max_from_linter: 1/1, source_code: 1/1, cgo: 170/170 
INFO [runner] processing took 2.395041ms with stages: identifier_marker: 2.2965ms, path_prettifier: 47.749µs, source_code: 12.375µs, nolint: 7.459µs, cgo: 5.249µs, invalid_issue: 4.459µs, filename_unadjuster: 4.416µs, uniq_by_line: 3.917µs, skip_dirs: 3.876µs, autogenerated_exclude: 3.251µs, exclude-rules: 2.541µs, path_shortener: 876ns, max_same_issues: 750ns, max_from_linter: 374ns, max_per_file_from_linter: 291ns, diff: 250ns, skip_files: 208ns, exclude: 167ns, sort_results: 167ns, fixer: 125ns, severity-rules: 41ns, path_prefixer: 0s 
INFO [runner] linters took 18.300208ms with stages: goanalysis_metalinter: 15.869416ms 
bugpkg/bug.go:3:10: could not import golang.org/x/sys/windows (-: build constraints exclude all Go files in /Users/sekai/go/pkg/mod/golang.org/x/[email protected]/windows) (typecheck)
import _ "golang.org/x/sys/windows"
         ^
INFO File cache stats: 1 entries of total size 52B 
INFO Memory: 3 samples, avg is 29.4MB, max is 30.9MB 
INFO Execution took 103.869042ms

A minimal reproducible example or link to a public repository

go.mod

module lintbug

go 1.23.1

require golang.org/x/sys v0.25.0

main.go

package main

func main() {
  println("Hello world")
}

bugpkg/bug.go

package bugpkg

import _ "golang.org/x/sys/windows" // some platform specified code without //go:build
$ golangci-lint run --exclude-dirs bugpkg

bugpkg/bug.go:3:10: could not import golang.org/x/sys/windows (-: build constraints exclude all Go files in /Users/sekai/go/pkg/mod/golang.org/x/[email protected]/windows) (typecheck)
import _ "golang.org/x/sys/windows"
         ^

Validation

  • Yes, I've included all information above (version, config, etc.).

Supporter

@nekohasekai nekohasekai added the bug Something isn't working label Sep 14, 2024
@ldez ldez added question Further information is requested and removed bug Something isn't working labels Sep 14, 2024
@ldez
Copy link
Member

ldez commented Sep 14, 2024

hello, typecheck errors cannot be ignored, this section of the FAQ explains why: https://golangci-lint.run/welcome/faq/#why-is-it-not-possible-to-skipignore-typecheck-errors

@ldez ldez closed this as completed Sep 14, 2024
@joaopapereira
Copy link

I'm not 100% sure I understand this restriction. Shouldn't golangci-lint respect the user's request to exclude directories?

@golangci golangci locked as resolved and limited conversation to collaborators Sep 19, 2024
@ldez
Copy link
Member

ldez commented Sep 19, 2024

If you try to compile, it's not possible to exclude a file (except with build tags), it's the same thing for golangci-lint.

Please read https://golangci-lint.run/welcome/faq/#why-is-it-not-possible-to-skipignore-typecheck-errors

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants