Skip to content

Rule for redundant error declarations #1098

@alexandear

Description

@alexandear

Is your feature request related to a problem? Please describe.

The code

var err error
insts, err := call()

can be simplified to

insts, err := call()

Describe the solution you'd like

A new rule redundant-err-decl that would suggest removing redundant err declarations.

Describe alternatives you've considered

Use sed to search redundant for err declarations and remove them manually:

find . -name '*.go' -exec sed -n '/var err error/{N;/\n.*err :=/p;}' {} +

Additional context

See these PRs for examples:

Metadata

Metadata

Assignees

No one assigned

    Labels

    rule proposalIssue proposing a new rule

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions