Skip to content

nakedret reports false positives from nested functions #11

@jhenstridge

Description

@jhenstridge

I noticed a bunch of new warnings from nakedret today that coincide with #10 being merged. While that PR does report some real cases that were previously ignored, it seems to also flag returns in nested functions.

Take the following example module:

package x

func Dummy() (err error) {
	defer func() {
		// perform cleanup
		return
	}()
	return nil
}

I get the following output from the tool:

$ $GOPATH/bin/nakedret -l 5 x.go
x.go:6 Dummy naked returns on 6 line function 

While there is a naked return statement in Dummy's AST, it belongs to a nested function with no return values, so should not be reported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions