Skip to content
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

staticcheck: configuration for staticcheck, gosimple, stylecheck #2017

Merged
merged 1 commit into from May 27, 2021

Conversation

ldez
Copy link
Member

@ldez ldez commented May 26, 2021

Fixes #1275

Staticcheck is split into 4 linters in golangci-lint staticcheck, gosimple, stylecheck and unused.
(more information: #1989 (comment))

staticcheck stylecheck gosimple unused
go x x x x
checks (*) x x x -
dot-import-whitelist (ST1003) - x - -
initialisms (ST1001) - x - -
http-status-code-whitelist (ST1013) - x - -

(*): each checks section can only filter the rules related to this section:

  • checks on staticcheck only filter SAxxxx rules
  • checks on stylecheck only filter STxxxx rules
  • checks on gosimple only filter Sxxxx rules

example:

  stylecheck:
    go: "1.15"
    checks: [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022" ]
    dot-import-whitelist:
      - fmt
    initialisms: [ "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS" ]
    http-status-code-whitelist: [ "200", "400", "404", "500" ]

Staticcheck available options: https://staticcheck.io/docs/options

@ldez ldez added the enhancement New feature or improvement label May 26, 2021
Copy link
Member

@ernado ernado left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@ldez ldez merged commit b916c93 into golangci:master May 27, 2021
@ldez ldez deleted the feat/staticcheck-configuration branch May 27, 2021 18:11
msugakov added a commit to stackrox/kube-linter that referenced this pull request Sep 21, 2021
This one turned a bit more involved.

Apparently, per golangci/golangci-lint#2017
staticcheck is split into four (!) linters under golangci-lit. These
are: `staticcheck`, `gosimple`, `stylecheck` and `unused`. Using the
same name `staticcheck` for one of linters is not confusing at all.

Anyway, to get full staiccheck's power, one must enable all four
linters in `.golangci.yml`.

With that we can throw staticcheck target away from `Makefile`.

Verified by omitting `"-ST1000"` in `stylecheck.checks` list and
seeing how `make lint` fails with ST1000 findings.

Unfortunately, I found no way to see log of each linter when it is
executed in golangci-lint context to be able to confirm things more
precisely. :-( Looks like golangci-lint simply does not support that.
msugakov added a commit to stackrox/kube-linter that referenced this pull request Sep 21, 2021
This one turned a bit more involved.

Apparently, per golangci/golangci-lint#2017
staticcheck is split into four (!) linters under golangci-lit. These
are: `staticcheck`, `gosimple`, `stylecheck` and `unused`. Using the
same name `staticcheck` for one of linters is not confusing at all.

Anyway, to get full staiccheck's power, one must enable all four
linters in `.golangci.yml`.

With that we can throw staticcheck target away from `Makefile`.

Verified by omitting `"-ST1000"` in `stylecheck.checks` list and
seeing how `make lint` fails with ST1000 findings.

Unfortunately, I found no way to see log of each linter when it is
executed in golangci-lint context to be able to confirm things more
precisely. :-( Looks like golangci-lint simply does not support that.
msugakov added a commit to stackrox/kube-linter that referenced this pull request Sep 21, 2021
This one turned a bit more involved.

Apparently, per golangci/golangci-lint#2017
staticcheck is split into four (!) linters under golangci-lit. These
are: `staticcheck`, `gosimple`, `stylecheck` and `unused`. Using the
same name `staticcheck` for one of linters is not confusing at all.

Anyway, to get full staiccheck's power, one must enable all four
linters in `.golangci.yml`.

With that we can throw staticcheck target away from `Makefile`.

Verified by omitting `"-ST1000"` in `stylecheck.checks` list and
seeing how `make lint` fails with ST1000 findings.

Unfortunately, I found no way to see log of each linter when it is
executed in golangci-lint context to be able to confirm things more
precisely. :-( Looks like golangci-lint simply does not support that.
SeigeC pushed a commit to SeigeC/golangci-lint that referenced this pull request Apr 4, 2023
@ldez ldez added this to the v1.41 milestone Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support staticcheck configuration
2 participants