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

Rule add-constant is not working #752

Closed
marek-valuch opened this issue Oct 5, 2022 · 4 comments
Closed

Rule add-constant is not working #752

marek-valuch opened this issue Oct 5, 2022 · 4 comments

Comments

@marek-valuch
Copy link

Describe the bug
Arguments in rule add-constant doesn't work

/home/...: avoid magic numbers like '0', create a named constant for it (revive)
/home/...: avoid magic numbers like '1', create a named constant for it (revive)
/home/...: avoid magic numbers like '2', create a named constant for it (revive)
/home/...: string literal "" appears, at least, 3 times, create a named constant for it (revive)
/home/...: string literal "" appears, at least, 3 times, create a named constant for it (revive)

To Reproduce
Use golang-ci version 1.5 with following config

Config:
  revive:
     ...
    rules: 
      - name: add-constant
        severity: warning
        arguments:
          - maxLitCount: "10"
            allowStrs: '""'
            allowInts: "0,1,2,3"
            allowFloats: "0.0,0.,1.0,1.,2.0,2."

Expected behavior
No warnings expected

Desktop (please complete the following information):

  • OS: [Ubuntu 22.04]
  • Go version: 1.19.1

Additional context
In golang-ci version 1.49 these warnings doesn't occur.

@chavacava
Copy link
Collaborator

Hi @marek-valuch thanks for reporting the issue.
Did you check if the problem occurs when running revive directly (i.e. without passing through golangci-lint ?

@marek-valuch
Copy link
Author

Hi @marek-valuch thanks for reporting the issue. Did you check if the problem occurs when running revive directly (i.e. without passing through golangci-lint ?

Yes, I tried to use same rules in toml config. But I can't reproduce warnings (avoid magic numbers like... or string literal "" appears...) using revive directly.

@chavacava
Copy link
Collaborator

@marek-valuch if the problem does not appear when running revive directly might indicate à problem at golangci-lint

@marek-valuch
Copy link
Author

@marek-valuch if the problem does not appear when running revive directly might indicate à problem at golangci-lint

Yes, it seems like parsing problem for golang-ci. Rule add-constant works propery when applied without arguments directly in revive.

It is probably already reported in here: golangci/golangci-lint#3280

Thank you!

@chavacava chavacava closed this as not planned Won't fix, can't repro, duplicate, stale Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants