dominikh / go-tools

Staticcheck - The advanced Go linter
https://staticcheck.dev
MIT License
6.22k stars 377 forks source link

Split ST1003 in multiple checks / allow to partially disable ST1003 #1575

Open iTrooz opened 4 months ago

iTrooz commented 4 months ago

All identifiers, such as variables and package names, are grouped under ST1003.

I think it'd be good to have the possibility to only enable ST1003 for the given types of identifier, e.g, variables

My use case: I work on a project where renaming the packages into compliance is not an option, so I had to disable ST1003. But I still would like to check for incorrect variables names / other incorrect identifiers other than package names

iTrooz commented 4 months ago

Another case where this could be useful: github CLI: https://github.com/cli/cli/blob/1a102edb52153bd90a3d339af4686d8d1af84bbf/pkg/cmd/root/root.go#L123-L139

Their package names (e.g. versionCmd) do not satisfy ST1003, but they still seem like a good choice in this case

iTrooz commented 4 months ago

I found a workaround with golangci-lint by adding this to the configuration:

issues:
  exclude:
    - "should not use MixedCaps in package name"

I wonder if there is a way to do it using pure staticcheck

dominikh commented 4 months ago

I wonder if there is a way to do it using pure staticcheck

Not at the moment, no. I'll have to think about it.