Open xylix opened 1 year ago
We have added a lot of new variable related rules to Robocop recently. They should be included in the next release. Some of them should be helpful for you.
We have old possible-variable-overwriting
rule, and now new unused-argument
, argument-overwritten-before-usage
, variable-overwritten-before-usage
, unused-variable
and inconsistent-variable-name
.
The last one, inconsistent-variable-name
seems closest to what you want - see my tests in open PR for comparison https://github.com/MarketSquare/robotframework-robocop/pull/843/files#diff-2f0d7272720db7099a933a449e434fc5918db1794deb7e76a0ab024970ecff4b .
Also Robotidy recently got new transformer - RenameVariables
- which is quite powerfull and can automatically rename all variables by their scope (removing any inconsistency): https://robotidy.readthedocs.io/en/stable/transformers/RenameVariables.html
It still under development but we're focusing a lot in this area recently. If there are some issues, missing features then feel free to open issues in our repositories :)
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
When there is some RF code like this:
Especially thanks to the fact that RobotFramework variables are case-insensitive and underscore-insensitive, it's pretty easy for a user to accidentally shadow a global variable with a local one.
Describe the solution you'd like I would like a warning in situations like this. I guess a workspace-level or comment toggle to disable the warning might also be useful?
Describe alternatives you've considered The other thing also demonstrated in the example, using "different" names that parse to same Robot Framework variable name, could also be an LSP check or a linting rule, but it might make more sense for that to be opt-in.