periphery
periphery copied to clipboard
Periphery doesn't account for various uses of properties
Describe the bug
Periphery doesn't account for various uses of properties.
Reproduction
1: When a property is used as a key for a Dictionary:
import Foundation
struct Thing {
let path: String
}
let thing = Thing(path: "/dev/null")
var thingByPath = [String:Thing]()
thingByPath[thing.path] = thing
for path in thingByPath.keys {
do {
try FileManager.default.attributesOfItem(atPath: path)
print(1)
} catch {
print(2)
}
}
2: When a property is indirectly used like in an implicit use in String(describing:), either directly or via a call to print(_:separator:terminator:):
struct Thing {
let id: Int
let name: String
}
print(Thing(id: 1, name: "a"))
Environment
$ periphery version
3.2.0
$ swift -version
swift-driver version: 1.127.14.1 Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)
Target: arm64-apple-macosx26.0
$ xcodebuild -version
Xcode 26.1.1
Build version 17B100
- Is a known bug: https://github.com/peripheryapp/periphery/issues/412
- This works for me, it correctly reports that both
idandnameand assigned, but unused. Can you please provide a demo project that reproduces the issue you are seeing?
Thanks for the info.
In the second case, the properties will be used because print() causes String(describing:) to be called, which uses the values of the properties to generate a String that is printed.