Skip to content

Analyzer: nilerr checks returning nil when err is not nil

License

Notifications You must be signed in to change notification settings

qawatake/nilerr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nilerr

pkg.go.dev

This repository is a fork of the gostaticanalysis/nilerr repository with additional patches applied.


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
	}
}

How to use

$ go install github.com/qawatake/nilerr/cmd/nilerr@latest
$ nilerr ./...

About

Analyzer: nilerr checks returning nil when err is not nil

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%