Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

false positive: used in return value #9

@carldunham

Description

@carldunham

Not sure if this case is covered already:

func examples() []string {
	field := os.Getenv("FIELD")
	if field == "" {
		field = "foo"
	}
	return []string{field}
}

results in:

variable 'field' is only used in the if-statement (example.go:2:2); consider using short syntax (ifshort)
        field := t.Field
        ^

This is the shortest example I could boil down to, but found the issue using field as a map key, and in other ways in the return. Not sure if these are all the same issue, happy to provide more examples.

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