Skip to content
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

False Positive: Subclasses which implement optional protocol methods #27

Closed
noahsark769 opened this issue Dec 16, 2019 · 5 comments
Closed

Comments

@noahsark769
Copy link
Contributor

Consider the following code:

import Foundation

@objc protocol ProtocolWithOptionalMethods: AnyObject {
    func a()
    @objc optional func b()
}

class Superclass: NSObject, ProtocolWithOptionalMethods {
    func a() {
        print("a")
    }
}

class Subclass: Superclass {
    func b() {
        print("b")
    }
}

Currently, Pecker reports function b() was never used; consider removing it, but b is in fact used as an implementation of the optional method. I put together an example project to demonstrate this here: https://github.com/noahsark769/NGPeckerExamples/blob/master/NGPeckerExamples/OptionalFunctionFromSuperclass.swift#L23

@woshiccm
Copy link
Owner

Coool, will take a look at it

@woshiccm
Copy link
Owner

Have check it, this case is really hard to deal. This issue will be dealt with as a low priority, first deal with important issues, hope you understand

@noahsark769
Copy link
Contributor Author

Yes of course! I can imagine it's not easy. Just wanted to report it so that we could track it 👍

@woshiccm
Copy link
Owner

@noahsark769 #43
This issue had been fixed, only skip function with optional modifier, this means @objc optional func b() skipped, func b() not skip, temporarily unable to do it 😂. But I think it usually enough, because func b() needs to be used elsewhere.

@woshiccm
Copy link
Owner

And this issue will be closed.

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

No branches or pull requests

2 participants