peripheryapp / periphery

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

Function `traitCollectionDidChange(_:)` is unused #820

Closed AllDmeat closed 1 month ago

AllDmeat commented 2 months ago

After upgrading to Xcode 16.0 I've started receiving warnings about traitCollectionDidChange(_:) being unused, despite it's being actually used. It became deprecated, but iOS still executes it both on iOS 17 and iOS 18. You can set a breakpoint and get a proof.

macOS: 15.0 Xcode: 16.0 Xcode project: created using Xcode 15.0 Periphery version: 2.21.0

periphery scan result:

* Inspecting project...
* Building PeripheryExample...
* Indexing...
* Analyzing...

/Users/alldmeat/Developer/PeripheryExample/PeripheryExample/ViewController.swift:12:19: warning: Function 'traitCollectionDidChange(_:)' is unused

* Seeing false positives?
 - Periphery only analyzes files that are members of the targets you specify.
   References to declarations identified as unused may reside in files that are members of other targets, e.g test targets.
 - Periphery is a very precise tool, false positives often turn out to be correct after further investigation.
 - If it really is a false positive, please report it - https://github.com/peripheryapp/periphery/issues.

PeripheryExample.zip

pm-dev commented 2 months ago

I'm also seeing this with other functions that override library types.

For example UITableViewController/UICollectionViewController functions:

warning: Function 'tableView(_:heightForRowAt:)' is unused
warning: Function 'tableView(_:estimatedHeightForRowAt:)' is unused
warning: Function 'numberOfSections(in:)' is unused
warning: Function 'tableView(_:numberOfRowsInSection:)' is unused
warning: Function 'tableView(_:willDisplay:forRowAt:)' is unused
warning: Function 'tableView(_:cellForRowAt:)' is unused
warning: Function 'tableView(_:didSelectRowAt:)' is unused

NSObject:

warning: Function 'isEqual(_:)' is unused
warning: Property 'hash' is unused

And other random overridden functions:

warning: Function 'layoutSublayers(of:)' is unused
warning: Property 'insertDictationResultPlaceholder' is unused
warning: Function 'removeDictationResultPlaceholder(_:willInsertResult:)' is unused
warning: Function 'attachmentBounds(for:proposedLineFragment:glyphPosition:characterIndex:)'
warning: Function 'caretRect(for:)' is unused
warning: Function 'paste(_:)' is unused
AllDmeat commented 2 months ago

Me too, on a real project a got 750+ errors after switching to Xcode 16 (zero errors on Xcode 15)

AllDmeat commented 1 month ago

The issue is closed, but no new release is available. When are you planning to make it?