Skip to content

detect map param where a singular key is also a param? #53

@dnwe

Description

@dnwe

I'm not sure how tricky this would be to detect via ruleguard/semgrep, but one pattern I noticed whilst refactoring a large legacy codebase recently were instances of a large map being passed into func calls when only a single value was actually being used in the body of the func, and they key was available at call time

e.g.,

func process(id string, labels map[string]string) {
     label := labels[id]
     // ...
}

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