Check for unused assigns in liveview

I have a legacy code with many assigns in def mount() function and the template was modified many times but your assigns remains untouchable. Exists any tool or easy method to check which assigns are being used?

You could inspect(@socket.assigns) in the template and /assign in the view.

I don’t think there would be any automated tool.

I understand that this is an old thread, but these threads are cached by Google, so they still come up in search results.

Solution: the Periscope library that gives you a CLI tool for seeing assigns, among other things: API Reference — periscope v0.1.1

Include it in your mix.exs and run your server locally with iex -S mix phx.server. it will let you see assigns, sockets, all currently loaded liveviews/components, etc.

3 Likes

Sooning as possible I will read about periscope, and test to see if it do what I want, thank you!

1 Like

periscope is indeed a very handy and easy to use tool for this!

1 Like