woshiccm / Pecker

CodePecker is a tool to detect unused Swift code.
MIT License
1.46k stars 63 forks source link

False Positive: Subclasses of subclasses of XCTestCase #35

Closed noahsark769 closed 4 years ago

noahsark769 commented 4 years ago

If you have a subclass of XCTestCase (e.g. a BaseTestCase where you put your generic testing utilities), Pecker currently reports tests that inherit from this subclass these as unused. For example:

import XCTest

class BaseTestCase: XCTestCase {

}

extension BaseTestCase {
    func a() {
        print("a")
    }
}

class TestCase: BaseTestCase { // currently reported as unused
    func test() { // currently reported as unused
        self.a()
    }
}

Working example in repo: https://github.com/noahsark769/NGPeckerExamples/blob/master/NGPeckerExamplesTests/XCTestSuperclassMethodUsedBySubclass.swift#L11

woshiccm commented 4 years ago

https://github.com/woshiccm/Pecker/issues/6 Others have opened a issue, I am still working on it, so this will be closed😂

noahsark769 commented 4 years ago

Ah oops, you're right! Sorry!