nilaway
nilaway copied to clipboard
Static analysis tool to detect potential nil panics in Go code
This PR fixes the convergence issues causes by unbounded growing of assertion trees with assignments in a loop, such as in the simple example shown below. ``` func test() {...
This PR refines the logic of non-literal map access, particularly in the case of built-in call expressions, to not consider the index trackable if there exists a nested call to...
This PR simply refactors the contract analyzer to prepare for further updates. Specifically, it (1) Defines a separate type for `[]Contract` such that it can be made to be exported...
This PR implements the fact export for manually-written and inferred function contracts. Specifically it enhances the `functioncontracts` sub-analyzer, which imports contracts from upstream packages, parses/infers the contracts for the local...
This PR updates the golden test in CI to run under two modes: with and without grouping of similar errors.
NilAway reports a false positive error for the switch case as shown below. The switch case ``` func test() { var x interface{} switch v := x.(type) { case nil:...
[`strings.Split`](https://pkg.go.dev/strings#Split) is guaranteed to return a non-nil slice with at least one element, so alerting from calling that is a false positive. ``` /Users/adam/code/src/github.com/moov-io/base/telemetry/attributes.go:84:19: error: Potential nil panic detected. Observed...
After updating to the latest rules_go and version of nilaway I am now getting the following panic: ``` /create.go:1:1: error: INTERNAL PANIC: conflicting position information on upstream object go.mongodb.org/mongo-driver/mongo.Cursor.M7: existing:...
NilAway is encoded with the pattern that if the error return is non-nil, then inherently assume non-error returns to be nilable, and hence need guarding. However, this reports a false...
NilAway can support prevalently found short-circuiting in non-conditional logical expressions. Examples of supported expressions are shown below (refer to [nonconditional.go](https://github.com/uber-go/nilaway/blob/main/testdata/src/go.uber.org/nilcheck/nonconditionalflow.go) for detailed test cases). ``` return x != nil &&...