Skip to content

Fix false positives in valid_ibinspectable rule when using Swift 5.2 - #3155

Merged
jpsim merged 2 commits into
masterfrom
fix-false-positives-in-valid_ibinspectable-rule-when-using-swift-5.2
Mar 27, 2020
Merged

jpsim merged 2 commits into
masterfrom
fix-false-positives-in-valid_ibinspectable-rule-when-using-swift-5.2

Conversation

@jpsim

@jpsim jpsim commented Mar 27, 2020

Copy link
Copy Markdown
Collaborator

when defining inspectable properties in class extensions with computed properties.

The following was triggering:

extension Foo {
  @IBInspectable var color: UIColor {
    set {
      self.bar.textColor = newValue
    }

    get {
      return self.bar.textColor
    }
  }
}

Fix by checking to see if an instance property has set keywords in its body when running with Swift 5.2 or later.

jpsim added 2 commits March 27, 2020 09:33
when defining inspectable properties in class extensions with computed
properties.

The following was triggering:

```swift
extension Foo {
  @IBInspectable var color: UIColor {
    set {
      self.bar.textColor = newValue
    }

    get {
      return self.bar.textColor
    }
  }
}
```

Fix by checking to see if an instance property has `set` keywords in its
body when running with Swift 5.2 or later.
@realm realm deleted a comment from SwiftLintBot Mar 27, 2020
@SwiftLintBot

Copy link
Copy Markdown
1 Warning
⚠️ This PR may need tests.
12 Messages
📖 Linting Aerial with this PR took 0.57s vs 0.54s on master (5% slower)
📖 Linting Alamofire with this PR took 0.8s vs 0.79s on master (1% slower)
📖 Linting Firefox with this PR took 3.54s vs 3.45s on master (2% slower)
📖 Linting Kickstarter with this PR took 5.23s vs 5.18s on master (0% slower)
📖 Linting Moya with this PR took 0.48s vs 0.48s on master (0% slower)
📖 Linting Nimble with this PR took 0.54s vs 0.57s on master (5% faster)
📖 Linting Quick with this PR took 0.33s vs 0.3s on master (10% slower)
📖 Linting Realm with this PR took 0.9s vs 0.92s on master (2% faster)
📖 Linting SourceKitten with this PR took 0.46s vs 0.45s on master (2% slower)
📖 Linting Sourcery with this PR took 2.33s vs 2.37s on master (1% faster)
📖 Linting Swift with this PR took 7.76s vs 7.8s on master (0% faster)
📖 Linting WordPress with this PR took 5.94s vs 6.0s on master (0% faster)

Generated by 🚫 Danger

@jpsim
jpsim merged commit da3e1a7 into master Mar 27, 2020
@jpsim
jpsim deleted the fix-false-positives-in-valid_ibinspectable-rule-when-using-swift-5.2 branch March 27, 2020 17:04
pull Bot pushed a commit to scope-demo/SwiftLint that referenced this pull request Mar 27, 2020
…ealm#3155)

* Fix false positives in valid_ibinspectable rule when using Swift 5.2

when defining inspectable properties in class extensions with computed
properties.

The following was triggering:

```swift
extension Foo {
  @IBInspectable var color: UIColor {
    set {
      self.bar.textColor = newValue
    }

    get {
      return self.bar.textColor
    }
  }
}
```

Fix by checking to see if an instance property has `set` keywords in its
body when running with Swift 5.2 or later.

* fixup! Fix false positives in valid_ibinspectable rule when using Swift 5.2
@ahmedsafadii

Copy link
Copy Markdown

same problem

@jpsim

jpsim commented Mar 29, 2020

Copy link
Copy Markdown
Collaborator Author

Did the fix work for you?

optionalendeavors added a commit to optionalendeavors/SwiftLint that referenced this pull request Jul 12, 2020
* master: (101 commits)
  JUnit reporter for GitLab artifact:report:junit (realm#3177)
  Add empty changelog section
  release 0.39.2
  Update CI to run jobs with Xcode 11.0 to 11.4 (realm#3168)
  Fix false positives in valid_ibinspectable rule when using Swift 5.2 (realm#3155)
  Fix attributes rule false positive with Swift 5.2 (realm#3154)
  Fix CHANGELOG link
  Fix false positives in redundant_objc_attribute with Swift 5.2 (realm#3152)
  Fix false positives on implicit_getter with Swift 5.2+ (realm#3151)
  Simplify regex (realm#3145)
  fix links about configuration rules (realm#3142)
  Add unused_import config options to require imports for each module used (realm#3123)
  Add empty changelog section
  release 0.39.1
  Temporarily remove all SwiftSyntax rules and support (realm#3107)
  Fix unused_import rule reported locations and corrections (realm#3106)
  release 0.39.0
  Fix false positive in `empty_string` rule with multiline literals (realm#3101)
  Fix PrivateActionRule in Swift 5.2 (realm#3092)
  Fix false positive in implicit_getter with Swift 5.2 (realm#3099)
  ...

# Conflicts:
#	Source/SwiftLintFramework/Extensions/SwiftLintFile+Regex.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants