Skip to content

Nogo: analyzers flags are not passed to subanalyzers #4329

Closed
@grzegorzsn

Description

@grzegorzsn

Currently, nogo passes configuration only to top analyzers, skipping the required subanalyzers.

Why is it a a problem? Some analyzers split the configuration among a few subanalyzers. Good
example here is nilaway, which documentation explains how to pass some configuration options
to dedicated nilaway_config subanalyzer.

https://github.com/uber-go/nilaway/wiki/Configuration#bazelnogo

Example configuration looks like this:

{
  "nilaway_config": {
    "analyzer_flags": {
      "include-pkgs": "go.uber.org",
      "exclude-pkgs": "vendor/",
      "exclude-file-docstrings": "@generated,Code generated by,Autogenerated by"
    }
  },
  "nilaway": {
    "exclude_files": {
      "bazel-out": "this prevents nilaway from outputting diagnostics on intermediate test files"
    },
    "only_files": {
      "my/code/path": "This is the comment for why we want to enable NilAway on this code path"
    }
  },
}

However, as nilaway_config is just subanalyzer, the analyzer flags are never actually set by nogo.

Fix

This commit contains relevant fix. Please let me know if should file pull request in current form or
what adjustments are expected. I'd also love some guidance wrt. testing if needed.
d9fb014

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions