You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lot of times, due to typo or some refactoring, I end up having variables in my code that do not exist. It is after I run the code I get to know about it. No static analyzer/linter can pick this up because of how Ruby is. It could be defined anywhere. It could also be a method etc.
Because Robe has access to the Ruby VM, I was wondering if it is possible to infer and warn when a variable or method used in the code does not exist. I believe it should be possible because apparently RubyMine does something like this. It probably will be compute heavy though.
The text was updated successfully, but these errors were encountered:
raghavio
changed the title
Infer if a variable or method is undeclared
Infer if a variable or method is undfined
Dec 25, 2024
raghavio
changed the title
Infer if a variable or method is undfined
Infer if a variable or method is undefined
Dec 25, 2024
This is a good suggestion. Alas, it's not a small change: the code doesn't have any kind of linter implementation at the moment, and it would need to be done in the server, I think, to have any chance at good performance.
It would probably be easier to approach the same problem from the other end, and highlight only the known local variables instead, using tree-sitter (here's an example of how this could be integrated: https://tree-sitter.github.io/tree-sitter/3-syntax-highlighting.html#local-variables, though this is not available in Emacs' treesit.el yet either). That's an approach for typos in variable names anyway.
As far as missing methods (or typos in method calls), runtime info could indeed help uniquely, though only for calls with the default receiver (meaning, methods on the same object). In many other cases, the object type is not always detectable, meaning the scan would have both false positives and false negatives.
A lot of times, due to typo or some refactoring, I end up having variables in my code that do not exist. It is after I run the code I get to know about it. No static analyzer/linter can pick this up because of how Ruby is. It could be defined anywhere. It could also be a method etc.
Because Robe has access to the Ruby VM, I was wondering if it is possible to infer and warn when a variable or method used in the code does not exist. I believe it should be possible because apparently RubyMine does something like this. It probably will be compute heavy though.
The text was updated successfully, but these errors were encountered: