Comments (9)
haha, I just tried setting up nilaway
today and then gave up after realizing that it flagged too many false positives.
I think your analysis is on point here. #3562 simply added a fancier report func that consumes a Diagnostic
struct from nogo run. So I think the appropriate fix here is to agree with nilaway
on how their Diagnostic could be programmatically parsed for ignore comments. https://github.com/search?q=repo%3Auber-go%2Fnilaway+%2Fanalysis.Diagnostic%7B%2F&type=code
I don't think propagating things across the build graph should be considered. It's expensive and will impact larger graphs negatively if things were to accumulate. If that is ever needed, we should simply rewrite nogo entirely.
from rules_go.
cc @patrickmscott who added nolint support, @sluongng who is maybe the nogo expert
from rules_go.
Here is the Diagnostic struct for future curious readers https://cs.opensource.google/go/x/tools/+/master:go/analysis/diagnostic.go;l=17;drc=dbd600188431770bd182cfa975efa023bea79af1
from rules_go.
cc: @linzhp
Im curious if Uber has something internally for this, or if this use case is not yet seen with nilaway
usage inside Uber.
from rules_go.
I haven't seen this in Uber, but we do use nilaway. @yuxincs may know more.
from rules_go.
NilAway is arguably the most sophisticated go (and nogo) analyzer, with support for inference across packages. What this means is that it could well be the case that NilAway finds a problem in an upstream package (and reported the error on the upstream package's Pos
, while analyzing the downstream package, as demonstrated in the issue here.
However, the nolint parsing support in nogo (and I think in other drivers as well), didn't take into account for such scenarios. The nolint comments are parsed only for the current package (and suppressed for current package):
rules_go/go/tools/builders/nogo_main.go
Lines 205 to 230 in b4b04b8
What we could do is to parse and store the nolint range information to artifact (fact file for example) and load it when analyzing downstream packages, such that we have complete nolint information to support cross-package linters like NilAway.
But I understand that nogo might not really want to do that given almost all other analyzers do not have this need and this may unnecessarily add pressures on caches, so we're thinking of adding such support and do suppressions directly in NilAway (via the Fact
mechanism). See uber-go/nilaway#91 and uber-go/nilaway#143 for more information :)
haha, I just tried setting up nilaway today and then gave up after realizing that it flagged too many false positives.
Please retry in the future, we are constantly trying to reduce false positives as much as possible 😉
from rules_go.
What we could do is to parse and store the nolint range information to artifact (fact file for example) and load it when analyzing downstream packages, such that we have complete nolint information to support cross-package linters like NilAway.
I am not against adding an additional artifact to help aid downstream nogo
runs.
In fact, I think @fmeum mentioned something about *.x
files might already contain some of the analysis data to help aid compilation?
As long as the data is fine grain and cached by Bazel, it should be ok to add.
from rules_go.
In fact, I think @fmeum mentioned something about
*.x
files might already contain some of the analysis data to help aid compilation?
I still haven't been able to delve into the contents of *.x
files unfortunately.
from rules_go.
.x
files have nogo facts:
rules_go/go/tools/builders/compilepkg.go
Lines 538 to 541 in b4b04b8
However, we may want to move nogo facts out of .x
after #3707
from rules_go.
Related Issues (20)
- Setting `--compilation_mode=opt` results in a binary with debug info + symbol table not being stripped HOT 1
- setting `extldflags` as flag does not parse properly HOT 1
- nogo not populating Go version in analysis pass
- Hello World for Golang is a bit difficult.
- gc_goopts seems buggy or has unexpected behavior
- Unable to get io_bazel_rules_go to work with a custom c++ toolchain HOT 1
- Rules_go 0.47.0 downgraded the gomock dependency from 1.7.0-rc1 to 1.6.0, which broke support for generics in mocks HOT 1
- How to test an analysis.Analyzer?
- Differentiate compile actions under go_test
- `GoLink` for Gazelle fails on Go 1.20 or greater HOT 1
- goleak broken by recent timeout changes
- How do I depend on the "bazel" package of rules_go when using MODULE.bazel HOT 3
- [BAZEL CI] rules_go cgo:opts_test is failing with Bazel@HEAD HOT 1
- go_tool_binary / GoToolchainBinaryBuild actions don't always run on the correct platform
- GoStdlib, GoCompilePkg, etc. don't respect exec_compatible_with of the underlying C/C++ toolchain HOT 1
- Calls to https://go.dev/dl/?mode=json are breaking airgapped builds - provide way to avoid these HOT 6
- rules_go + protobufs + experimental_sibling_repository_layout fails to build HOT 2
- How do you use protoc with 0.48.0? HOT 4
- Proposal: Fail protoc code gen on missing expected output files
- Embedding native buildinfo in Bazel binaries
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rules_go.