nilerr

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2020 License: MIT Imports: 8 Imported by: 17

README

nilerr

pkg.go.dev

nilerr finds code which returns nil even though it checks that error is not nil.

func f() error {
	err := do()
	if err != nil {
		return nil // miss
	}
}

nilerr also finds code which returns error even though it checks that error is nil.

func f() error {
	err := do()
	if err == nil {
		return err // miss
	}
}

nilerr ignores code which has a miss with ignore comment.

func f() error {
	err := do()
	if err != nil {
		//lint:ignore nilerr reason
		return nil // ignore
	}
}

Documentation

Index

Constants

View Source
const Doc = "nilerr checks returning nil when err is not nil"

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "nilerr",
	Doc:  Doc,
	Run:  run,
	Requires: []*analysis.Analyzer{
		buildssa.Analyzer,
		commentmap.Analyzer,
	},
}

Functions

This section is empty.

Types

type ReferrersHolder added in v0.1.0

type ReferrersHolder interface {
	Referrers() *[]ssa.Instruction
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL