peripheryapp / periphery

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

False Positives with `Hashable` #721

Closed iv-mexx closed 2 months ago

iv-mexx commented 3 months ago

Hi, I think I'm getting these false positives with a Strict thats Hashable in Periphery 2.18.0

  private struct LootToggleIdentifier: Hashable {
    let categoryName: String
    let typeName: String
    let usages: Set<Usage>
    let categories: Set<Category>
  }

Screenshot 2024-03-11 at 10 27 24

Its true, categoryName and typeName are never read explicitly, but they are factored into automatically synthesized hash function ( https://developer.apple.com/documentation/swift/hashable#Conforming-to-the-Hashable-Protocol )

ileitch commented 2 months ago

This isn't a false positive, Periphery correctly identifies that the property isn't read from anywhere else in your code. No tool can determine that these properties are used only for altering the hash value. You can either implement hash(into:) or use a comment command to retain these properties.