mgechev / revive

🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
https://revive.run
MIT License
4.73k stars 276 forks source link

How to configure `upperCaseConst` for the `var-naming` rule within `golangci-lint` for revive? #893

Closed takanuva15 closed 11 months ago

takanuva15 commented 11 months ago

Describe the bug I'm confused how to configure upperCaseConst for the var-naming rule within golangci-lint for revive. The linter-setting documentation in golangci-lint only shows 2 arguments for the var-naming rule. How would I specify the upperCaseConst option?

I tried this but it doesn't seem to work with the golangci-lint GitHub action. It still tells me to remove ALL_CAPS constants:

linters-settings:
  revive:
    rules:
      - name: var-naming
        arguments:
          - []
          - []
          - [{upperCaseConst=true}]

To Reproduce The Github action output is in a company repo so I can't link it here. I'm just wondering whether it's even possible to specify upperCaseConst through golangci-lint?

Expected behavior I should be able to specify the option

Logs

  Error: models/file.go:14:7: var-naming: don't use ALL_CAPS in Go names; use CamelCase (revive)
  const MY_SPECIAL = "Spec"
        ^

  Error: issues found

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

chavacava commented 11 months ago

Hi @takanuva15, this issue seems to better fit in the issue tracker of golangci-lint project.

takanuva15 commented 11 months ago

Thanks for the quick reply. I have made a new issue in golangci-lint with the details described here.

Based on the response from the maintainer, it looks like v1.54.2 of golangci-lint is using v1.3.2 of revive, so the upperCaseConst stuff isn't available yet in golangci-lint. However, v1.3.3 of revive is already present in the main branch of golangci-lint, so the next release will probably resolve that issue. I'll try to remember to update here if I get it solved.