fsel

package module
v0.0.0-...-806c04f Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: MIT Imports: 8 Imported by: 0

README

fsel

Go Reference test

Linter: fsel flags field access with unverified nil errors.

func bad() error {
	s, err := doSomething()
	fmt.Println(s.X) // <- field address without checking nilness of err
	return err
}

func good() error {
	s, err := doSomething()
	if err != nil {
		return err
	}
	fmt.Println(s.X) // ok because err is definitely nil
	return nil
}

func doSomething() (*S, error) {
	return nil, errors.New("error")
}

type S struct {
	X int
}

You can try an example by running make run.example.

How to use

go install github.com/qawatake/fsel/cmd/fsel@latest
fsel ./...

False Positives

To ignore a false positive, add a comment //lint:ignore fsel reason to the line.

func f() error {
	s, err := doSomething()
	if isNotNil(err) {
		return err
	}
	fmt.Println(s.X) //lint:ignore fsel reason
	return nil
}

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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