Skip to content

Limit nilaway to the main module by default - #39

Merged
nnutter merged 3 commits into
analysis-brick-cortexfrom
analysis-semi-brick
Nov 5, 2026
Merged

nnutter merged 3 commits into
analysis-brick-cortexfrom
analysis-semi-brick

Conversation

@nnutter

@nnutter nnutter commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

No description provided.

A flag default can name a package, and only the loaded packages say
whether the default is right. nilaway's -include-pkgs wants the main
module of the run, which neither the working directory nor a flag parse
reveals: a workspace holds several main modules, and a pattern can point
at a module that is not the current one.

Add a hook that the command supplies and the driver calls after loading,
in the analysis path and in the fix path. No command supplies a hook
yet, so no flag changes. The test pins the order: the hook runs before
the analyzers, and it sees the loaded roots and their modules.

Change-Id: If8fdf9c1deeca15f4f8d6919e6060541a040dbfd
The analyzers asked whether a file is generated, but what they do with
the answer is skip its diagnostics. Rename the predicate in the
signature change, not in a behavior change. The next commit adds a flag
that turns the skip off, and a name that states the decision keeps the
call site honest about which question the flag answers.

Change-Id: Id1f81ecea1ae760033b52724574db7f9c2a0d44d
NilAway reads every package that it loads, so a run over one module also
builds the SSA form of the standard library and of every dependency.
That costs seconds and gigabytes, and it reports flows that the analyzed
repository cannot fix: a nil value inside the standard library belongs to
Go, not to the code under review.

Set -include-pkgs to the main modules of the loaded packages. The driver
hook supplies them, because a workspace has several main modules and a
pattern can name a module other than the current one. A reader who wants
the old scope sets -nilaway.include-all-pkgs, and an explicit
-nilaway_config.include-pkgs keeps the packages that it names.

Widening the scope exposes two code sites that the narrow run never
reaches, because it needs a fact about a standard library package. The
driver test now guards each flag lookup, and the fix pass builds its map
instead of cloning one that can be nil.

The hook no longer needs the flag on its command line, so the command
returns to the plain form.

Change-Id: I1ef0782ba71084540c610bc5064ba595167d6f62
@nnutter
nnutter added this pull request to stack #41 November 5, 2026 07:46
@nnutter nnutter changed the title analysis semi brick Limit nilaway to the main module by default Nov 5, 2026
@nnutter
nnutter merged commit 30a547d into master Nov 5, 2026
3 checks passed
@nnutter
nnutter deleted the analysis-semi-brick branch November 5, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant