periphery icon indicating copy to clipboard operation
periphery copied to clipboard

False positive with dictionary key

Open sdc-78 opened this issue 4 years ago • 2 comments

Hello,

With the following code:

class Foo {

    private let key = "the-key"

    func run() {
        var dictionary: [String: Any] = [:]
        dictionary[key] = 42 // <-- `key` is used there!
        print(dictionary.count)
    }
}

Foo().run()

Periphery 2.8.1 reports:

warning: Property 'key' is assigned, but never used

Note: If I add key in the print(...) statement, the warning disappears.

sdc-78 avatar Oct 14 '21 13:10 sdc-78

It looks like https://bugs.swift.org/browse/SR-14162 but here it's not a static property.

sdc-78 avatar Oct 15 '21 13:10 sdc-78

Yep, that's the same issue. I'm planning to try fix this issue myself, in time for Swift 5.6... but I've hardly any time recently for Periphery.

ileitch avatar Oct 16 '21 09:10 ileitch