diff options
author | DolceTriade <hmodi@aviatrix.com> | 2022-12-03 08:02:32 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-03 08:02:32 -0800 |
commit | fe4715a6d959159cb58397aadd7b9fed22fa19c4 (patch) | |
tree | 137dcae45f718ed937d4bc3ee3349a057d332492 /tests | |
parent | 60cd1e428a1cbbe386943fac1cfadd183f4d6898 (diff) | |
download | bazelbuild-rules_go-fe4715a6d959159cb58397aadd7b9fed22fa19c4.tar.gz |
nogo: Add a _base key to be a default config for all Analyzers. (#3351)
This is useful for situations where you want to exclude/include the same directories for all the analyzers. Specifying a config for a particular analyzer will cause the _base config, if it exists, to be underlayed for that analyzer (ie, if the analyzer doesn't set an option, it will use the options specified by the _base config).
You can use it like so:
{
"_base": {
"exclude_files": {
"external/": "third_party",
"proto/": "generated protobuf"
}
},
"override":
"description": "oops, I actually don't want to exclude any files here...",
"exclude_files": {}
}
}
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/nogo/custom/custom_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/core/nogo/custom/custom_test.go b/tests/core/nogo/custom/custom_test.go index 72f3a373..27624431 100644 --- a/tests/core/nogo/custom/custom_test.go +++ b/tests/core/nogo/custom/custom_test.go @@ -297,6 +297,24 @@ func run(pass *analysis.Pass) (interface{}, error) { } } +-- baseconfig.json -- +{ + "_base": { + "exclude_files": { + "has_.*\\.go": "Visibility analyzer not specified. Still inherits this special exception." + } + }, + "importfmt": { + "only_files": { + "has_errors\\.go": "" + } + }, + "foofuncname": { + "description": "no exemptions since we know this check is 100% accurate, so override base config", + "exclude_files": {} + } +} + -- has_errors.go -- package haserrors @@ -419,6 +437,18 @@ func Test(t *testing.T) { `importfmt`, }, }, { + desc: "custom_config_with_base_linedirective", + config: "baseconfig.json", + target: "//:has_errors_linedirective", + wantSuccess: false, + includes: []string{ + `linedirective_foofuncname.go:.*function must not be named Foo \(foofuncname\)`, + `linedirective_visibility.go:.*function D is not visible in this package \(visibility\)`, + }, + excludes: []string{ + `importfmt`, + }, + }, { desc: "uses_cgo_with_errors", config: "config.json", target: "//:uses_cgo_with_errors", |