Skip to content

Typecheck errors are reported for ignored directories #4914

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
bewuethr opened this issue Aug 15, 2024 · 2 comments
Closed
6 of 7 tasks

Typecheck errors are reported for ignored directories #4914

bewuethr opened this issue Aug 15, 2024 · 2 comments
Labels
question Further information is requested

Comments

@bewuethr
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

Release v1.60.1 includes #4870, "fix: typecheck issues should never be ignored".

This seems to result in also overriding issues.exclude-dirs in the configuration, i.e., reporting typecheck errors in excluded directories.

$ go run github.com/golangci/golangci-lint/cmd/[email protected] run ./...
$ go run github.com/golangci/golangci-lint/cmd/[email protected] run ./...
somepackage/main.go:1: : # golangcitest/somepackage
somepackage/main.go:6:14: invalid operation: 1 + "2" (mismatched types untyped int and untyped string) (typecheck)
package main
exit status 1

I'd expect issues.exclude-dirs to ignore all errors in the listed directories.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.60.1 built with go1.23.0 from 3298c104 on 2024-08-14T01:15:05Z

Configuration

issues:
  exclude-dirs:
    - somepackage

Go environment

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/benjamin/.cache/go-build'
GOENV='/home/benjamin/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/benjamin/.local/share/asdf/installs/golang/1.22.6/packages/pkg/mod'
GONOPROXY='github.com/someorg'
GONOSUMDB='github.com/someorg'
GOOS='linux'
GOPATH='/home/benjamin/.local/share/asdf/installs/golang/1.22.6/packages'
GOPRIVATE='github.com/someorg'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/benjamin/.local/share/asdf/installs/golang/1.22.6/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/benjamin/.local/share/asdf/installs/golang/1.22.6/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.6'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/tmp/golangcitest/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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2808541535=/tmp/go-build -gno-record-gcc-switches'

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
NFO golangci-lint has version 1.60.1 built with go1.23.0 from 3298c104 on 2024-08-14T01:15:05Z 
INFO [config_reader] Config search paths: [./ /tmp/golangcitest /tmp / /home/benjamin] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused] 
INFO [loader] Go packages loading at mode 575 (files|imports|name|types_sizes|deps|exports_file|compiled_files) took 232.18468ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 128.62µs 
INFO [linters_context/goanalysis] analyzers took 3.33477ms with top 10 stages: buildir: 281.911µs, fact_deprecated: 270.396µs, inspect: 65.749µs, S1003: 61.535µs, SA4022: 47.95µs, buildtag: 47.499µs, S1007: 46.727µs, S1010: 44.012µs, SA4024: 41.868µs, directives: 39.574µs 
INFO [runner] Issues before processing: 175, after processing: 1 
INFO [runner] Processors filtering stat (in/out): path_prettifier: 175/175, identifier_marker: 175/175, nolint: 175/175, uniq_by_line: 175/1, max_per_file_from_linter: 1/1, max_same_issues: 1/1, filename_unadjuster: 175/175, exclude: 175/175, source_code: 1/1, path_shortener: 1/1, skip_files: 175/175, invalid_issue: 175/175, autogenerated_exclude: 175/175, exclude-rules: 175/175, max_from_linter: 1/1, cgo: 175/175, diff: 1/1, severity-rules: 1/1, fixer: 1/1, path_prefixer: 1/1, sort_results: 1/1, skip_dirs: 175/175 
INFO [runner] processing took 3.124089ms with stages: identifier_marker: 2.941811ms, path_prettifier: 67.486µs, source_code: 22.552µs, exclude-rules: 20.809µs, nolint: 15.289µs, cgo: 13.095µs, autogenerated_exclude: 12.484µs, skip_dirs: 11.652µs, filename_unadjuster: 5.339µs, invalid_issue: 4.769µs, uniq_by_line: 4.668µs, max_same_issues: 1.142µs, path_shortener: 661ns, max_from_linter: 540ns, skip_files: 391ns, max_per_file_from_linter: 340ns, sort_results: 241ns, exclude: 240ns, fixer: 240ns, diff: 200ns, path_prefixer: 80ns, severity-rules: 60ns 
INFO [runner] linters took 39.229374ms with stages: goanalysis_metalinter: 36.049809ms 
somepackage/main.go:1: : # golangcitest/somepackage
somepackage/main.go:6:14: invalid operation: 1 + "2" (mismatched types untyped int and untyped string) (typecheck)
package main
INFO File cache stats: 1 entries of total size 66B 
INFO Memory: 5 samples, avg is 30.2MB, max is 40.6MB 
INFO Execution took 364.615067ms       

A minimal reproducible example or link to a public repository

$ tree
.
├── somepackage
│   └── main.go
├── go.mod
└── go.sum

1 directory, 3 files
$ head **/*
==> go.mod <==
module golangcitest

go 1.22.6

==> go.sum <==

==> somepackage/main.go <==
package main

import "fmt"

func main() {
        fmt.Println(1 + "2")
}

Validation

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

Supporter

@bewuethr bewuethr added the bug Something isn't working label Aug 15, 2024
Copy link

boring-cyborg bot commented Aug 15, 2024

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez ldez added question Further information is requested and removed bug Something isn't working labels Aug 15, 2024
@ldez
Copy link
Member

ldez commented Aug 15, 2024

Hello,

  1. typecheck errors are never ignored, because it's not possible, this is explained inside the doc.
  2. exclude-dirs is not a way to skip the analysis of a directory: https://golangci-lint.run/usage/configuration/#issues-configuration

The PR that you quote is to avoid side effects: linters are not able to perform the analysis when there are typecheck errors. This is not related to golangci-lint itself but to how the analysis system works inside Go tooling.
This is explained in the issue attached to the PR.

typecheck errors are reported in the same style as reports/issues but they are completely different because they are related to compilation problems.

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

No branches or pull requests

2 participants