-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rule Request: Redundant ObjC attribute #2193
Comments
This probably should also catch uses of |
If you guys don't mind, i would pick up and implement this rule. I have ran a few tests, and it seems most of the @NSManaged
@IBAction
@IBOutlet
@IBInspectable
@GKInspectable Non redundant candidate: @NSCopying
@discardableResult
@available Just to visualize what @marcelofabri meant with his last comment and my findings, the following would trigger / non-trigger: // Trigger
@objc @IBInspectable private var foo: String? { ... }
@IBInspectable @objc private var foo: String? { ... }
@objc @IBAction private func foo(_ sender: Any) { ... }
@IBAction @objc private func foo(_ sender: Any) { ... }
@objc @GKInspectable private var foo: String! { ... }
@GKInspectable @objc private var foo: String! { ... }
@objc @NSManaged private var foo: String!
@NSManaged @objc private var foo: String!
@objcMembers
class Foo {
@objc var bar: Any
}
// Not trigger
@objc private var foo: String? { ... }
@IBInspectable private var foo: String? { ... }
@objc private func foo(_ sender: Any) { ... }
@IBAction private func foo(_ sender: Any) { ... }
@GKInspectable private var foo: String! { ... }
private @GKInspectable var foo: String! { ... }
@NSManaged var foo: String!
@objc @NSCopying var foo: String!
@objc @discardableResult
func foo() -> UIView? {
return nil
}
@objc @available(iOS 10.0, *, *)
func foo() -> UIView? {
return nil
}
@objcMembers
class Foo {
var bar: Any
} Also, would it be okay, if it would be Swift 4.1+ rule? |
@dirtydanee As far as I know, nobody is working on this yet, so feel free to grab. Preferably, we should support all Swift versions, but it's fine to support only 4.1+ if there're differences between SourceKit outputs that make the rule not possible on Swift < 4.1 or much harder to implement. |
Absolutely, I encourage you to pick this up! Although I think there are a number of attributes that you didn’t include in your list. |
I have updated my comment with If |
Thanks for the list @SDGGiesbrecht ! After reading through the documentation, i came to the conclusion, that maybe only the ones having explicitly mentioned to be Based on the documentation it will be: @NSManaged
@IBAction
@IBOutlet
@IBInspectable
@GKInspectable
@IBDesignable I think the rest of the In my tests the only difference i found, if i apply the |
Done in #2270. Thanks @dirtydanee |
New Issue Checklist
Rule Request
We should warn if you have
@objc
along with@IBInspectable
/@IBDesignable
/@IBOutlet
/@IBAction
, since they all imply@objc
. Let's confirm this is the case unilaterally before doing this.1. Why should this rule be added? Share links to existing discussion about what the community thinks about this.
No external discussions about this that I'm aware of.
2. Provide several examples of what would and wouldn't trigger violations.
3. Should the rule be configurable, if so what parameters should be configurable?
I can't think of any useful configurations at the moment, other than the standard severity configuration.
4. 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.
Enabled by default if we can confirm that these attribute pairs are redundant in all cases. Opt-in otherwise.
The text was updated successfully, but these errors were encountered: