golangci / golangci-lint

Fast linters runner for Go
https://golangci-lint.run
GNU General Public License v3.0
15.77k stars 1.39k forks source link

Allow option to disable typecheck #5111

Closed jeffsaremi closed 2 weeks ago

jeffsaremi commented 2 weeks ago

Welcome

Your feature request related to a problem? Please describe

typecheck cannot be disabled since it's not a linter. Yet we keep getting errors reported by that. Errors which don't come from the go build itself! We need a way to disable this annoying behavior. thanks

Describe the solution you'd like

Allow option to completely remove typecheck from analysis and error reporting

Describe alternatives you've considered

not using golintci

Additional context

No response

Supporter

boring-cyborg[bot] commented 2 weeks ago

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

jeffsaremi commented 2 weeks ago

Example of how the error is reported even though go build and vscode do not report any issues:

type WorkloadGraph struct {
    logger *zap.Logger
    *datastore.CommonSourceData
}
...
func (a *WorkloadGraph) loadAccounts() {
...
        a.Accounts[account.ID] = &datastore.Account{
            ID:     account.ID,
            Name:   account.Name,
            Region: account.Region,
        }
...

now Compare these:


❯ go build ./...

❯ make lint
...
Lint App
golangci-lint has version 1.55.2 built with go1.21.3 from e3c2265f on 2023-11-03T12:59:25Z
internal/graph/builder.go:160:5: a.Accounts undefined (type *WorkloadGraph has no field or method Accounts) (typecheck)
                a.Accounts[account.ID] = &datastore.Account{
                  ^
make: *** [lint] Error 1
ldez commented 2 weeks ago

Why do you have typecheck errors?

Why is it not possible to skip/ignore typecheck errors?

jeffsaremi commented 2 weeks ago

I don't know why this was closed? I understand that typecheck is not a linter, yet the tool is reporting errors which are actually not errors! I'm not sure you read my description and examples that I provided? go build reports absolutely no errors. SO there is no reason to get an error like that from this tool SOmeone needs to look into this!

ldez commented 2 weeks ago

Everything is explained inside the documentation: how to find the cause and how to fix it.

Your example is not a minimum reproducible example (ie: I cannot copy-paste your example)

I don't appreciate the tone you are using: I can understand frustration but I have some limits.

jeffsaremi commented 2 weeks ago

ok thank you! the other link you provided is more helpful Is there a way to easily determine the version of go compiler used for each release of golintci? e.g by looking here; https://github.com/golangci/golangci-lint/releases

ldez commented 2 weeks ago

The only thing I can do with your example is this:

```go package main import ( "go.uber.org/zap" ) type CommonSourceData struct{} type Account struct { ID string Name string Region string } type WorkloadGraph struct { logger *zap.Logger *CommonSourceData Accounts map[string]*Account } func (a *WorkloadGraph) loadAccounts() { a.logger.Info("Loading accounts") account := Account{} a.Accounts[account.ID] = &Account{ ID: account.ID, Name: account.Name, Region: account.Region, } } func main() { w := &WorkloadGraph{} w.loadAccounts() } ``` ```console $ golangci-lint run --show-stats 0 issues. ```

And everything works.

Is there a way to easily determine the version of go compiler used for each release of golintci?

It's golangci-lint.

$ golangci-lint version         
golangci-lint has version 1.61.0 built with go1.23.1 from a1d6c560 on 2024-09-09T17:44:42Z
jeffsaremi commented 2 weeks ago

ok thanks!