retnonnilerr

package module
v0.0.0-...-11caebe Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: MIT Imports: 8 Imported by: 0

README

retnonnilerr

Go Reference Test

retnonnilerr is a static analysis tool to prevent below unhandling error.

func f() error {
    x, err := fn()
    if err != nil {
        return nil // !!!
    }
    fmt.Printf("x is %v\n", x)
    return nil
}

How to use

From CLI
go install github.com/MokkeMeguru/retnonnilerr/cmd/retnonnilerr
cd path/to/product
retnonnilerr ./...

From CI

See my custom linter settings

Test it using act (WARNING: reviewdog cannot do normaly)

act --job reviewdog

Ignore Lint?

If you want to ignore this linter at the line, you can comment lint:ignore retnonnilerr.

func f() error {
    x, err := fn()
    if err != nil {
        //lint:ignore retnonnilerr TODO fix
        return nil
    }
    fmt.Printf("x is %v\n", x)
    return nil
}

References

  • nilerr

    Very similar, except for the lack of test code checks and the part that inspects err without exceptions.

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
tools
utils

Jump to

Keyboard shortcuts

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