nilnesserr

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 6 Imported by: 2

README

nilnesserr

nilnesserr = nilness + nilerr

nilnesserr is a linter for report return nil error in Go. It combines the features of nilness and nilerr, providing a concise way to detect return an unrelated/nil-values error.

Case

case 1

err := do()
if err != nil {
    return err
}
err2 := do2()
if err2 != nil {
    return err // which should return err2 after check `err2 != nil`, but return a nil value error
}

Some Real Bugs

We use https://github.com/alingse/go-linter-runner to run linter on GitHub Actions for public Go repos

Install

go install github.com/alingse/nilnesserr/cmd/nilnesserr@latest

TODO

case 2

err := do()
if err != nil {
    return err
}
_, ok := do2()
if !ok {
    return err
}

case 3

err := do()
if err != nil {
    return err
}
_, ok := do2()
if !ok {
    return errors.Wrap(err)
}

maybe this is also a bug, should return a non-nil value error after the if

License

This project is licensed under the MIT License. See the LICENSE file for details.

This project incorporates source code from two different libraries:

  1. nilness licensed under the BSD license.
  2. nilerr licensed under the MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAnalyzer

func NewAnalyzer(setting LinterSetting) (*analysis.Analyzer, error)

Types

type LinterSetting

type LinterSetting struct{}

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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