robotframework-robocop icon indicating copy to clipboard operation
robotframework-robocop copied to clipboard

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

Open Lakitna opened this issue 4 months ago • 4 comments

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

Lakitna avatar Sep 30 '24 12:09 Lakitna