Skip to content

Commit

Permalink
Fix correct .zero autocorrection (#3386)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulTaykalo authored Oct 19, 2020
1 parent 5d6e25a commit 662db7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
* Fix some false positives in rule `explicit_self`.
[Sven Münnich](https://github.com/svenmuennich)

* Fix incorrect autocorrection in `prefer_zero_over_explicit_init` rule.
[Paul Taykalo](https://github.com/PaulTaykalo)

## 0.40.3: Greased Up Drum Bearings

#### Breaking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public struct PreferZeroOverExplicitInitRule: OptInRule, ConfigurationProviderRu
AutomaticTestableRule {
public var configuration = SeverityConfiguration(.warning)
private var pattern: String {
let zero = "\\s*:\\s*0(.0*)?\\s*"
let zero = "\\s*:\\s*0(\\.0*)?\\s*"
let type = "(\(["CGPoint", "CGSize", "CGVector", "CGRect"].joined(separator: "|")))"
let firstArg = "(\(["x", "dx", "width"].joined(separator: "|")))"
let secondArg = "(\(["y", "dy", "height"].joined(separator: "|")))"
Expand Down Expand Up @@ -34,6 +34,7 @@ public struct PreferZeroOverExplicitInitRule: OptInRule, ConfigurationProviderRu
],
corrections: [
Example("↓CGPoint(x: 0, y: 0)"): Example("CGPoint.zero"),
Example("(↓CGPoint(x: 0, y: 0))"): Example("(CGPoint.zero)"),
Example("↓CGRect(x: 0, y: 0, width: 0, height: 0)"): Example("CGRect.zero"),
Example("↓CGSize(width: 0, height: 0.000)"): Example("CGSize.zero"),
Example("↓CGVector(dx: 0, dy: 0)"): Example("CGVector.zero")
Expand Down

0 comments on commit 662db7b

Please sign in to comment.