Skip to content

Commit

Permalink
Update nimble_operator to suggest the (in)equal operator instead of…
Browse files Browse the repository at this point in the history
… `beNil()` (#4025)
  • Loading branch information
CraigSiemens authored Jul 14, 2022
1 parent c95670e commit c5aa806
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
[SimplyDanny](https://github.com/SimplyDanny)
[#3985](https://github.com/realm/SwiftLint/issues/3985)

* Update `nimble_operator` to support the operators for `beNil()`.
[CraigSiemens](https://github.com/CraigSiemens)

## 0.47.1: Smarter Appliance

#### Breaking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public struct NimbleOperatorRule: ConfigurationProviderRule, OptInRule, Correcta
Example("expect(x) === x"),
Example("expect(10) == 10"),
Example("expect(success) == true"),
Example("expect(value) == nil"),
Example("expect(value) != nil"),
Example("expect(object.asyncFunction()).toEventually(equal(1))\n"),
Example("expect(actual).to(haveCount(expected))\n"),
Example("""
Expand All @@ -42,6 +44,8 @@ public struct NimbleOperatorRule: ConfigurationProviderRule, OptInRule, Correcta
Example("↓expect(x).to(beIdenticalTo(x))\n"),
Example("↓expect(success).to(beTrue())\n"),
Example("↓expect(success).to(beFalse())\n"),
Example("↓expect(value).to(beNil())\n"),
Example("↓expect(value).toNot(beNil())\n"),
Example("expect(10) > 2\n ↓expect(10).to(beGreaterThan(2))\n")
],
corrections: [
Expand All @@ -60,6 +64,8 @@ public struct NimbleOperatorRule: ConfigurationProviderRule, OptInRule, Correcta
Example("↓expect(success).to(beFalse())\n"): Example("expect(success) == false\n"),
Example("↓expect(success).toNot(beFalse())\n"): Example("expect(success) != false\n"),
Example("↓expect(success).toNot(beTrue())\n"): Example("expect(success) != true\n"),
Example("↓expect(value).to(beNil())\n"): Example("expect(value) == nil\n"),
Example("↓expect(value).toNot(beNil())\n"): Example("expect(value) != nil\n"),
Example("expect(10) > 2\n ↓expect(10).to(beGreaterThan(2))\n"): Example("expect(10) > 2\n expect(10) > 2\n")
]
)
Expand Down Expand Up @@ -88,7 +94,8 @@ public struct NimbleOperatorRule: ConfigurationProviderRule, OptInRule, Correcta
"beLessThan": (to: "<", toNot: nil, .withArguments),
"beLessThanOrEqualTo": (to: "<=", toNot: nil, .withArguments),
"beTrue": (to: "==", toNot: "!=", .nullary(analogueValue: "true")),
"beFalse": (to: "==", toNot: "!=", .nullary(analogueValue: "false"))
"beFalse": (to: "==", toNot: "!=", .nullary(analogueValue: "false")),
"beNil": (to: "==", toNot: "!=", .nullary(analogueValue: "nil"))
]

public func validate(file: SwiftLintFile) -> [StyleViolation] {
Expand Down

0 comments on commit c5aa806

Please sign in to comment.