Closed
Description
New Issue Checklist
- Updated SwiftLint to the latest versionI searched for existing GitHub issues
Rule Request
- Why should this rule be added? Share links to existing discussion about what
the community thinks about this.
In Swift, you need a var
or let
keyword to do an assignment inside a condition (if
, guard
, etc).
Thus, you only get the disadvantages of Yoda conditions, but no benefits.
- Provide several examples of what would and wouldn't trigger violations.
// should trigger
if 42 == foo {}
guard "str" == bar else { return }
while 10 == baz { }
// shouldn't trigger
if foo == 42 {}
guard bar == "str" else { return }
while baz == 10 { }
if foo == bar {}
- Should the rule be configurable, if so what parameters should be configurable?
Just the severity.
- Should the rule be opt-in or enabled by default? Why?
See README.md for guidelines on when to mark a
rule as opt-in.
I think this might cause some false positives, so I'd say opt-in. But it could be enabled by default if we can avoid those false positives.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
jpsim commentedon Oct 24, 2017
Good rule, but definitely opt-in.
Introduction of Yoda condition checking.
Introduction of Yoda condition checking.
Introduction of Yoda condition checking.
Introduction of Yoda condition checking.
Introduction of Yoda condition checking.
Introduction of Yoda condition checking.
Introduction of Yoda condition checking.
Introduction of Yoda condition checking.
Introduction of Yoda condition checking.
Introduction of Yoda condition checking.
Introduction of Yoda condition checking.
Introduction of Yoda condition checking.
2 remaining items