-
Notifications
You must be signed in to change notification settings - Fork 66
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
Support cross-package nolint parsing #91
Comments
I think you're constrained to use the "//nolint:" notation, but just to clarify my understanding, am I correct in thinking what you mean it to express is "this cannot be nil by construction"? I just ran nilaway on a program that of mine, and added |
@davecb Not exactly :)
You're probably thinking about adding annotations to parameters & returns, similar to what Java has ( In NilAway we try to avoid adding annotation burden onto devs since it's not a builtin language feature unlike Java. But we do parse comments like
Where the return value would be assumed nonnil in NilAway's perspective. But those are mostly for testing purposes (do not rely on this feature in your code, though). In the future, we plan to add a tiny "annotation"-like library that NilAway understands, and most importantly will log and/or panic if the assumption is broken.
where |
We can report errors on
pkg A
when we are analyzingpkg B
due to our multi-pkg inference. However, nogo’s support for nolint comments is based on reading the AST from current package.That is, nogo does not know we have a nolint comment in pkg A when analyzing pkg B , but NilAway can report an error there, and hence cannot be suppressed.
The other linter implementations most likely follow the same logic.
We’ll need to implement own cross-pkg nolint support (i.e., reading the nolint and writing it to facts, then read it in downstream analysis to decide whether to report a certain error or not).
The text was updated successfully, but these errors were encountered: