Skip to content

Changed everything across the repo #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Changed everything across the repo #1

wants to merge 1 commit into from

Conversation

dakshgup
Copy link
Member

No description provided.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This pull request overhauls NilAway by systematically refactoring its error handling, annotation processing, inference, and test infrastructure. The changes aim to improve robustness, consistency, and clarity for both internal diagnostics and end-user reporting.

• accumulation/analyzer.go now uses errors.Join and a new diagnostic engine to combine results from sub-analyzers via analysishelper.Result.
• Annotation files (affiliation, consume_trigger, full_trigger, key, produce_trigger) have been refactored to consistently use pointers for deep copying and equality, with careful updates to trigger creation and comparison.
• The README and Makefile were updated with clearer instructions, enhanced module support, and stricter linting targets.
• Inference and assertion packages now use an ordered map and new primitivizer logic to deterministically propagate nilability, while several legacy files (e.g. nilcheck.go, trusted_func.go) were removed.
• Test suites have been consolidated, enhanced for panic recovery, cancellation handling, and goroutine leak detection.

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

56 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 11 to +13
[nilness analyzer](https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/nilness), however, it employs much more
sophisticated and powerful static analysis techniques to track nil flows within a package as well _across_ packages, and
report errors providing users with the nilness flows for easier debugging.
report errors providing users with the nilness flows for easier debugging.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Sentence on line 13 feels a bit awkward: consider rephrasing for clarity (e.g. 'and reports errors by displaying the nilness flow for easier debugging').

Comment on lines +74 to +77
NilAway, in its current form, can report false positives. This unfortunately hinders its immediate
merging in [golangci-lint][golangci-lint] and be offered as a linter (see [PR#4045][pr-4045]).
Therefore, you need to build NilAway as a plugin to golangci-lint to be executed as a private
linter. There are two plugin systems in golangci-lint, and it is much easier to use the
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The phrase 'merging in golangci-lint and be offered as a linter' may be grammatically improved. Consider rewording for clarity.

Comment on lines +111 to +113
res := <-resultChan
require.Equal(t, res.index, 0)
require.ErrorIs(t, res.err, context.Canceled)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider revising require.Equal parameter ordering to (expected, actual) for clearer error messages.

Comment on lines 258 to 273
path, producers := r.ParseExprAsProducer(consumer.Expr, false)
if path == nil { // expr is not trackable
if producers == nil {
return // expr is not trackable, but cannot be nil, so do nothing
// Here we can infer that the expression is non-nil by definition. Instead of ignoring creation of a trigger,
// particularly for always safe tracking, we create a trigger with ProduceTriggerNever.
if c, ok := consumer.Annotation.(*annotation.UseAsReturn); ok && c.IsTrackingAlwaysSafe {
r.AddNewTriggers(annotation.FullTrigger{
Producer: &annotation.ProduceTrigger{
Annotation: &annotation.ProduceTriggerNever{},
Expr: consumer.Expr,
},
Consumer: consumer,
})
}
return
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: In AddConsumption, when path is nil and producers is nil, a ProduceTriggerNever trigger is created for always safe tracking. Confirm that this branch correctly identifies non-trackable yet non-nil expressions.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: File completely removed. Verify that the new design covers the contract parsing responsibilities and that no dependent module is left without proper function contract extraction.

Comment on lines +73 to +78
p := pass.Fset.File(d.Pos).Name()
for _, e := range excludes {
if strings.HasPrefix(p, e) {
return
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: File name (pass.Fset.File(d.Pos).Name()) may be relative while the parsed prefixes are absolute; ensure paths are normalized before prefix matching.

Suggested change
p := pass.Fset.File(d.Pos).Name()
for _, e := range excludes {
if strings.HasPrefix(p, e) {
return
}
}
p := pass.Fset.File(d.Pos).Name()
absPath, err := filepath.Abs(p)
if err == nil {
p = absPath
}
for _, e := range excludes {
if strings.HasPrefix(p, e) {
return
}
}

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