Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how Periphery treats references to storyboards/xibs #663

Closed
rogerluan opened this issue Oct 19, 2023 · 3 comments · Fixed by #687
Closed

Document how Periphery treats references to storyboards/xibs #663

rogerluan opened this issue Oct 19, 2023 · 3 comments · Fixed by #687

Comments

@rogerluan
Copy link
Contributor

Hi! 👋

I've been using Periphery for a while in multiple projects, and recently there has been concern about whether Periphery takes storyboards/xibs (Interface Builder files in general) into account when considering whether properties/functions/classes are being used or not.

I couldn't find this information clear anywhere in the README nor in Issues of this repo, so I decided to test on my own to confirm (even though I kinda know that it worked based on past experience), and indeed I confirmed that it treats IB files safely, as such:

  • If there's a class (e.g. MyViewController) that gets referenced in a storyboard or xib, its IBOutlets and IBActions won't be marked as unused, regardless of whether they're being used or not.
  • If the class is not being referenced in any xib/storyboard and is not referenced anywhere else, the entire class gets marked as unused (as opposed to only its functions/properties)

So I'd like to invite @ileitch (or any other major contributor who has enough knowledge about the inner workings of the tool) to officially document how Periphery handles those references and make it official for future readers, as this could be a deal breaker for adoption! And perhaps, while at it, clarify why Periphery chooses to take the "safe way" instead of the "clever way" when dealing with IB files? That is: if an IB references a class, and that class has a truly unused IBAction (for instance), why it doesn't mark that function as unused? It's not being referenced anywhere. Is this a technical limitation (i.e. we can't do anything about it), or a shortcut that was taken in the past?

Looking forward to hearing from core maintainers of this tool, as I'm curious to learn more about it! 😊

Thanks for this amazing tool! ❤️

@rogerluan
Copy link
Contributor Author

@ileitch any input here? 🙇

@ileitch
Copy link
Contributor

ileitch commented Dec 18, 2023

If there's a class (e.g. MyViewController) that gets referenced in a storyboard or xib, its IBOutlets and IBActions won't be marked as unused, regardless of whether they're being used or not.

You are correct, this is the current behavior.

clarify why Periphery chooses to take the "safe way" instead of the "clever way" when dealing with IB files?

It is a deliberate choice that Periphery should never produce false-positive results. Because we have not yet implemented full xib parsing, Periphery retains all members on the type to avoid false positives.

I'm closing this as a duplicate of #212, as my intention is for connections in xibs to only retain the members they reference.

@rogerluan
Copy link
Contributor Author

That's great to know, thank you for clarifying, @ileitch ! 🙇

I created #687 to document these behaviors 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants