Best practise handling verified routes scattered all over?

Hey there,

First, this isn’t going to be a criticism of verified routes - they’re a great idea and I like them a lot. But, they come with a downside, which is that there’s a lot of “copies” of the route sprinkled throughout the codebase. In just one part of the project I’m working on now, there’s over 300 ~p routes sprinkled all over the place, in layouts, liveview ex and heex, many of them highly redundant/duplicates of each other. Changing a path somewhere quickly becomes quite the pain. It’s great that the framework checks all of them - but there’s still a lot of them!

How do you handle/abstract/bulk update/otherwise manage your verified routes?

sed but I am old school. Most IDEs editors have search & replace built into them too.

What I do is:
https://www.cyberciti.biz/faq/how-to-use-sed-to-find-and-replace-text-in-files-in-linux-unix-shell/

Yep, I’m been using sed and bulk find/replace as well. Was just wondering if there’s a trick which is a little more elixir and a little less brute force…

I’d argue that this is actually a benefit of verified routes (over the prev. route helpers). You just deal with the path itself. The value becomes the identity and what you’re searching for.

Sure you could wrap the value in a function – which is what we normally do with magic values – but then you’ll scatter a function call all over the place. This is what we had with route helpers and it for sure wasn’t better. Routes just have that many permutations that functions become just as complex as the values they wrap.

You can look into compiler tracers to find invocations of the verified routes sigil: Code — Elixir v1.17.0-dev