Re:Greppability is an underrated code metric
by klodolph on Tuesday September 03, 2024 @01:26AM
(#41431564)
I guess I wasn’t thinking of “find usages”, but as the article points out, it’s hard to find usages if the usages are dynamic.
The solution—to write code which is less dynamic—helps code search and features like find usages.
Re:Greppability is an underrated code metric
by alexpovel on Tuesday September 03, 2024 @02:22AM
(#41431855)
Regarding your third point, I put together a tool capable of that to some degree.
It allows you to grep inside source code, but limit the search to e.g. “only docstrings inside class definitions”, among other things. That is, it allows nesting and is syntax aware. That example is for Python, but the tool speaks more languages (thanks to treesitter).
https://github.com/alexpovel/srgn/blob/main/README.md#multip...
A simple example would be any "find usages" too, which can vary widely in accuracy by language and IDE. When it works well, naming becomes a lot less important, because you don't need to grep for potential usages and because refactoring with a better name is low-stakes.