peripheryapp / periphery

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

feat: Support filter by source branch #829

Open hoangatuan opened 1 month ago

hoangatuan commented 1 month ago

Description

Currently, we don't support filter results only on changed/added files. This PR adds logic to support that feature.

How it works?

  1. Using periphery scan to get the outputs.
  2. Use 'git diff $sourceBranch --path $filePath' to get all the changes in that file. (filePath comes from the output.declaration.location.path)
  3. Compare the output.declaration.location.line with the newLineStart and newLineSpan from the diff. If it matches, then it's a new/changed line.

Notes

This is a propose idea and solution. I haven't updated the tests. If you feel the feature and the solution is okay, I will update the tests. Please take a look and let me know if you have any suggestions. Thank you

hoangatuan commented 1 month ago

Hi @ileitch, I have a proposal here. It will be nice if you can take a look when you have time. Thank youu