Skip to content

contrasted_opening_brace false positives in trailing closures and else if statements #5752

@buresdv

Description

@buresdv

New Issue Checklist

Feature or Enhancement Proposal

I'm using the new contrasted_opening_brace rule. I ran across a potential false positive (at least in my opinion) when this rule is used on trailing closures that include parameters.

Examples include (lifted straight from my codebase):

return allDependencies.map
{ dependency in // <-- Violation here
    .init(name: dependency.fullName, version: dependency.version, directlyDeclared: dependency.declaredDirectly)
}
let originalServicesWithTheirUUIDs: [String: UUID] = services.reduce(into: [:])
{ result, originalService in // <-- Violation here
    result[originalService.name] = originalService.id
}
return AsyncStream
{ continuation in // <-- Violation here
}

I'd expect this rule to not consider these examples violations. Perhaps there could be a setting that would not flag these.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions