Re:Ask HN: Looking for a tool
by BjoernKW on Friday August 18, 2017 @06:38AM
(#15045027)
It's called static analysis, which given JavaScript's dynamic nature obviously doesn't work as well as with statically-typed languages like Java. However, IntelliJ IDEA or WebStorm offer decent analysis tools for JavaScript as well. In IntelliJ IDEA "Find usages" is the name of the feature you're looking for.
[ Parent
| on HN ]
I don't have IntelliJ right now, but as far as I remember this function shows only line where selected method is called. I meant something more sophisticated, every piece fo code that could be affected by this.
Example:
int x = obj.something();
unrelated.doSomethingElse();
return x * x;
If I change something() method IntelliJ will show only the first line, even though the third one is affected by the change as well.I see. Like a trace of properties affected by a change. That's definitely possible using static analysis during a pre-commit hook.
You're right IntelliJ IDEA doesn't provide that feature out-of-the-box. SonarLint does something like this but only for specific patterns (or rather anti-patterns). I don't know about a general purpose tool that does this though.
It's theoretically possible in JavaScript I think - you can trace the usage of the function return through variable assignment statements, insertions into arrays, etc. Not easy but not impossible?