-
Notifications
You must be signed in to change notification settings - Fork 287
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
How to disable rule.exported
for consts?
#1045
Comments
Hi @Potherca, I'm not sure to understand your request on linting comments on public constants. package main
// this is not ok
const AConstant = 10 When linting it with
and when linting with
Thus it seems to me that for the case of public constants comments, |
Hi @chavacava i think @Potherca wanted to switch off only some warnings (related with const), but there are no option for that. So I try to add this feature in PR #1047 think about it :) |
Hi @mfederowicz, as mentioned in the OP, two of the three warnings can be avoided by tweaking the configuration. The third one, "comment on exported const [..] should be of the form [..]" can not be disabled but my understanding is that in what concerns to that particular warning |
ok @chavacava I made my PR because I think that should be option to switch of selected warnings, but this is my opinion. On the other way fixing code for consts (in scaned project) shouldnt be complicated process :) |
@chavacava Thank you for taking the time to look at this. I've managed to create a minimal reproduable case for this. It looks like having a comment behind a const declaration causes the difference between golint and revive. To reproduce what I am seeing: package main
const (
// this is not ok
AConstant = 10
Bconstant = 11 // Some comment here
) Golint shows:
Revive shows:
So it looks like the issue is not with the const but with the comment. Should I close this issue and/or create a new issue for this difference caused by the trailing comment? |
@Potherca, thanks for the details. I'll further investigate these kind of cases. |
I can confirm that #1051 resolves all issues I have. Steps taken:
The results of both outputs are the same. |
TL;DR:
I am aware that the goal of this project is no longer to be a 100% drop-in replacement for golint (which I think is fair) but is there a way for me to disable the
exported
rule but only for consts?Full Details
At pipeline-components we have a component for go-lint. Although it is not one of our larger components[1], I'm thinking of prolonging support by replacing
golint
with revive.However, the current claim that the default behaviour is the same as
golint
does not appear to be 100% accurate.To be specific, I am seeing the following warnings from revive that are not there with golint:
The first two I can resolve by tweaking the default config,[2], which is fine for our purposes (as golint does not have a config, so we can just add one for revive).
But I have not yet been able to resolve the
comment on exported const [..] should be of the form [..]
. Please note, this is explicitly about exported "const", not other exported types.How could this be achieved?
[1] Currently it only has +/- 40K pulls on DockerHub
[2] Click to see config
The text was updated successfully, but these errors were encountered: