Skip to content

Make redundant-existence-check care less about where a check happens #1805

@anderseknert

Description

@anderseknert

This is currently considered a redundant-existence-check:

f(obj) if {
    obj.type
    obj.type == "object"	
}

But this isn't:

f(obj) if {
    obj.type == "object"	
    obj.type
}

Whether the intent was an existence check or not, the latter should also be considered a violation of this rule.

I actually found a case of this in our own code here 😅

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestruleIssues related to new or existing linter rules

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions