Skip to content

vet: point out unused function arguments #7892

Closed
@gopherbot

Description

@gopherbot

by [email protected]:

When applying the "extract method pattern" I quite often forget to actually
use extracted arguments and keep the hardcoded values in the the extracted function
which leads to errors.

I think that for not exported functions at least vet should complain about unused
function arguments. My personal opinion is that I would treat unused arguments of not
exported functions the same as unused variables (and cause a compiler error).

For exported functions things are a bit different because of API stability reasons. A
similar workaround to handling unused variables ("_ = unusedArgument" at the
beginning of the function) would be possible though and also enable documenting (via
comment) why a specific arguments is not used.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions