peripheryapp / periphery

A tool to identify unused code in Swift projects.
MIT License
5.02k stars 178 forks source link

warning: Extension ‘ExtensionName' is unused #734

Open mayoralito opened 1 month ago

mayoralito commented 1 month ago
periphery version
2.18.0

Given the code example:

class ViewControllerWebView: UIViewController {
    let webView = WKWebView()

    // …

   override func viewDidLoad() {
        super.viewDidLoad()
        webView.navigationDelegate = self
    }
}

extension ViewControllerWebView: WKNavigationDelegate {
  func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
        // 
    }

    func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
        // 
    }

    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
        // 
    }
}

The report came as

ViewControllerWebView.swift:66:11: warning: Extension 'ViewControllerWebView' is unused

Which I think it’s a false positive unless I’m missing something else.

ileitch commented 1 month ago

Thanks for reporting this @mayoralito. I'm unable to reproduce the warning with the example you provided. Could you please create a simple Xcode project that demonstrates the issue?