Skip to content

Rule Request: Condition list instead of boolean && #6039

@SimplyDanny

Description

@SimplyDanny

Swift has the notion of condition lists that behave exactly as if the condition elements were combined with the && operator. Condition lists can be regarded as idiomatic Swift.

This new rule should trigger on boolean expressions used in places where condition lists would be allowed, too. It can even auto-transform these expressions. It is very important, though, that the order of evaluation is preserved to avoid changing the code's semantic with respect to side effects.

The rule should be opt-in. In fact, a reverse rule triggering on condition lists is also conceivable. At the moment, there is no specific configuration necessary.

Triggering examples

if a && b {}
while (a || b) && c {}

can be replaced with

if a, b {}
while a || b, c {}

Non-triggering examples

do {} while a || b && c
if a, { b && c }}() {}

Metadata

Metadata

Assignees

Labels

rule-requestRequests for a new rules.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions