MarketSquare / robotframework-robocop

Tool for static code analysis of Robot Framework language
Apache License 2.0
182 stars 39 forks source link

[Rule] No test variable, no suite variable, and no global variable #1117

Open Lakitna opened 3 days ago

Lakitna commented 3 days ago

I'm working with a pretty big robot project where they used to constantly use Set Test Variable (and similar) instead of returning values. This causes significant confusion and issues when refactoring. I've since shown them why using returned values is a better idea, but there is still legacy code lurking in the depths.

What do you think of adding the following rules?

no-test-variable Disallows setting Test/Task-level variables. Using Set Test Variable, Set Task Variable, VAR ... scope=TEST, and VAR ... scope=TASK is not allowed outside the variables section.

no-suite-variable Disallows setting Suite-level variables. Using Set Suite Variable, VAR ... scope=SUITE, and VAR ... scope=SUITES is not allowed outside the variables section.

no-global-variable Disallows setting Test/Task-level variables. Using Set Global Variable and VAR ... scope=GLOBAL is not allowed outside the variables section.

These rules would ignore variables in the variables section.

I'm willing to write the rules. Let me know if you're interested in adding them