peripheryapp / periphery

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

Specifying `baseline` and `verbose` seems incompatible #801

Closed benlaverriere closed 1 month ago

benlaverriere commented 1 month ago

I'm getting periphery set up for a project, and generally things are looking good! I noticed that when baseline and verbose are specified (either both on the command line, both in the YAML config file, or one in each) I get an error like:

➽ periphery scan --baseline periphery_baseline.json
[version] 2.21.0
[shell] /opt/homebrew/bin/zsh -lc env
[shell] /usr/bin/env swift -version
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
[shell] /usr/bin/env xcodebuild -version
Xcode 15.4
Build version 15F31d
error: (YamlError) Failed to represent periphery_baseline.json

I was hoping to use verbose to confirm I'm representing baseline correctly in our YAML file, but I can't get far enough in the output to see the generated config. The reason I wanted to confirm the syntax is that --baseline on the command line produces the expected * No unused code detected. but specifying it in YAML produces the full list of unused items. I assume I've gotten the YAML wrong for this particular option but can't confirm without verbose. 😅

ileitch commented 1 month ago

--verbose here I think isn't related. Instead, the problem is that the property kind of the baseline is FilePath, and 2.21.0 did not include the correct conversion for YAML decoding. This bug however is already fixed in master.

benlaverriere commented 1 month ago

Ah, gotcha — so that error is happening regardless but I'm only seeing it in verbose mode. Thanks for the explanation! I'll see about giving the latest beta a try.