Skip to content

Enable nilnil linter #36152

@silverwind

Description

@silverwind

It's bad practive to write functions in go that return no result but also no error, e.g. return value nil, nil because it leaves the reader confused as developers are used to the fact that if there is no error, then the return value is valid.

The nilnil linter can detect such scenarios and we should enable it.

The challenge with this is that there are many violations in the current code base. When I run with the strictest config, there are currently 287 violations.

nilnil:
  only-two: false
  detect-opposite: true

Maybe we could add the linter and // nolint:nilnil all places so that these can be gradually refactored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic/code-lintingtype/proposalThe new feature has not been accepted yet but needs to be discussed first.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions