You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix generation of facts file when diagnostics are ignored (#4422)
**What type of PR is this?**
Bug fix
**What does this PR do? Why is it needed?**
After #4402, it is no longer possible to use a custom analyzer without
having to declare a new `Fact` type. The build of a Go library will fail
if the library contains any external dependencies.
That's the case for executing gazelle by example (if we don't use a
precompiled binary):
```
$ bazel run //:gazelle
ERROR: .../external/gazelle++go_deps+org_golang_x_sync/errgroup/BUILD.bazel:3:11: output 'external/gazelle++go_deps+org_golang_x_sync/errgroup/errgroup.facts' was not created
ERROR: .../external/gazelle++go_deps+org_golang_x_sync/errgroup/BUILD.bazel:3:11: Running nogo on @@gazelle++go_deps+org_golang_x_sync//errgroup:errgroup failed: not all outputs were created or valid
ERROR: .../external/gazelle++go_deps+com_github_bazelbuild_buildtools/labels/BUILD.bazel:3:11: output 'external/gazelle++go_deps+com_github_bazelbuild_buildtools/labels/labels.facts' was not created
ERROR: .../external/gazelle++go_deps+com_github_bazelbuild_buildtools/labels/BUILD.bazel:3:11: Running nogo on @@gazelle++go_deps+com_github_bazelbuild_buildtools//labels:labels failed: not all outputs were created or valid
ERROR: .../external/gazelle++go_deps+in_gopkg_yaml_v3/BUILD.bazel:5:11: output 'external/gazelle++go_deps+in_gopkg_yaml_v3/yaml_v3.facts' was not created
ERROR: .../external/gazelle++go_deps+in_gopkg_yaml_v3/BUILD.bazel:5:11: Running nogo on @@gazelle++go_deps+in_gopkg_yaml_v3//:yaml_v3 failed: not all outputs were created or valid
ERROR: .../external/gazelle++go_deps+org_golang_x_sys/execabs/BUILD.bazel:3:11: output 'external/gazelle++go_deps+org_golang_x_sys/execabs/execabs.facts' was not created
ERROR: .../external/gazelle++go_deps+org_golang_x_sys/execabs/BUILD.bazel:3:11: Running nogo on @@gazelle++go_deps+org_golang_x_sys//execabs:execabs failed: not all outputs were created or valid
...
```
**Other notes for review**
This review continue to skip analysers when ignoring diagnostics, but
return a valid `pkg` to create the missing `.facts` file required by the
validation action, and incidentally, fix a potential crash at line
https://github.com/bazel-contrib/rules_go/blob/1f993522f463c142c5516f94852c3d6597f717c6/go/tools/builders/nogo_main.go#L98.
0 commit comments