-
Notifications
You must be signed in to change notification settings - Fork 280
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.exported: add feature to disable selected warnings for rule (const,method,function) #1047
rule.exported: add feature to disable selected warnings for rule (const,method,function) #1047
Conversation
It would be very nice to see this feature merged. I would especially need turning off warnings for types. |
…kind-warnings # Conflicts: # rule/exported.go
hi @denisvmedia I resolved conflicts from master, and if you have and sugestions (changes) let me know :) |
Hi @zak-pawel could you please elaborate on the reasons for turning off warnings for types? (I've quickly read the thread on telegraph repo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left some comments on the implementation details but, in general, IMO the semantics of the new configuration is not clear or, not rightly implemented.
For example, from the configuration documentation we understand that setting "type" will avoid generating any warning on types at all. Then, by reading the implementation we can see that some warning on types will be generated (those of the form "exported type %v should have comment or be unexported"
)
RULES_DESCRIPTIONS.md
Outdated
|
||
Example: | ||
|
||
```toml | ||
[rule.exported] | ||
arguments = ["checkPrivateReceivers", "disableStutteringCheck", "checkPublicInterface"] | ||
arguments = ["checkPrivateReceivers", "disableStutteringCheck", "checkPublicInterface", ["function","method","type","var"]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the configuration entry gives no clue about the "ignore" nature of the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i try struct with dedicated fields but in toml there is problem with notation like:
IgnoredWarnings{field:true,field2:true}
you can only use like this:
{field:true,field2:true} or list ["val","val2","val3"]
but there is no option to name/prefix that (or maybe I dont know the magic yet :()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what @chavacava is asking is to have a better naming of the setting, e.g. disableFunctionDocumentationCheck
instead of function
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what @chavacava is asking is to have a better naming of the setting, e.g.
disableFunctionDocumentationCheck
instead offunction
...
ok so each element of ["function","method","type","var"] as dedicated flag
arguments = ["disableFunctionCheck", "disableMethodCheck", "disableTypeCheck", "disableVarCheck"]
that was my first idea, but thinks using array/slice will be simpler (one place to modify) :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok maybe we can walk that way:
arguments = ["disableFunctionCheck", "disableMethodCheck", "disableTypeCheck", "disableVarCheck"]
and of course modify my commited code to use that flags insted of additional array in config what you think @chavacava ?
@chavacava let me elaborate a bit on
Telegraf has a "plugin-like" structure, where each "plugin" fulfills a set of interfaces and by now we exported the plugin struct as well as the interface functions by convention. We now want to use the checker to make sure each plugin only exports the plugin type and the interface functions! However, each of the plugin types has to implement certain functions like |
Hi @srebhan thank you for the details on your use case. |
@chavacava we are currently solely checking the plugins with this rule. Disabling the whole rule defeats the purpose as we actually want the exported rule to warn about exported structs and functions only whitelisting the known interface functions. This way the rule will warn about any unexpected exports which is exactly what we want. We only need to shut-up the comment warnings for the plugins... |
@zak-pawel @srebhan cc: @mfederowicz |
@chavacava I tested it on the Telegraf code, and it looks like the individual switches correctly disable the respective checks. Thanks! |
Thanks for the PR @mfederowicz |
@chavacava no problem, but forgot to add var testdata, created quick update: #1055 :P |
related with #1045
for rule.exported add feature to read array/list of types which we want to ignore in processing time
of course thouse are types discovered when rule.exported is enabled in config, if we set some other additional flags outside of that list it can results with panic/error