bazel-contrib / bazel-contrib/rules_go

nogo: configuration should be applied before executing an analyzer

Open
#2,472 7 comments 1 reaction 0 assignees View on GitHub
enhancement nogo
Dominant language
Go
Stars
1.5k
Forks
760
Avg merge
1d 11h
Merged PRs (30d)
12

Description

### What version of rules_go are you using?
0.2.5

### What version of gazelle are you using?
c08cffd46756c6dec217fecd5e65a529012dd0f8 (~master)

### What version of Bazel are you using?
3.0

### Does this issue reproduce with the latest releases of all the above?
Yes.

### What operating system and processor architecture are you using?
Mac OS X.

### Any other potentially useful information about your toolchain?

### What did you do?
I have a custom analyzer that raises an error if a file isn't formatted per `gofmt`. This requires reading the original go file, from `pass.Fset.Position(file.Pos()).Filename`. This sometimes fails because it seem like the input file is not available; my guess is that this is similar to #2396 . Unfortunately, I can't simply add an entry to `exclude_files` because that's evaluated after running the analyzer, which will just fail. I could change my analyzer to not return an error, and just emit a `Diagnostic`, but that seems a bit odd.

Further, it seems like it'd be more efficient to simply skip analyzers that we plan to ignore the results for.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the custom analyzer entry point around pass.Fset.Position(file.Pos()).Filename and the handling of exclude_files. Determine how configuration can be applied before analyzer execution so excluded analyzers are skipped; done means an excluded analyzer neither runs nor fails because its input file is unavailable.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.