peripheryapp / periphery

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

False results for Codable after 2.18.0 update #709

Closed AllDmeat closed 1 month ago

AllDmeat commented 5 months ago

After updating Periphery to 2.18.0, properties in our Codable and Encodable structures started being marked as unused. This issue was not present in version 2.17.1.

Affected structures are used with JSONEncoder. There is a section Encodable in the README.md, and it states "This property retention behavior is automatic". That was indeed the case before version 2.18.0, but now it is not so.

It might be related to the fact that in version 2.18.0, the --external-encodable-protocols flag has been deprecated, and instead, we are now supposed to use --external-codable-protocols.

Is this a bug or an intentionally updated behavior? If it's the latter, then the README.md should also be updated accordingly.

tihimsm commented 4 months ago

I have a smiller problem. When using the external-codable-protocols option, the following error is output.

.periphery.yml: invalid key 'external-codable-protocols'
paynerc-socure commented 3 months ago

Run it with the --retain-codable-properties option.

 periphery scan --retain-codable-properties

I ran into the same issue and did some digging running through the debugger and found that. It does mention it in the CHANGELOG.md, but not in the README.md.

ileitch commented 1 month ago

Sorry for not updating the README and causing confusion. This was indeed an intentional change and --retain-codable-properties can be used to retain all Codable properties.

.periphery.yml: invalid key 'external-codable-protocols'

Configuration options use snake case in the yml, so external_codable_protocols.