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

[Rule] GROUP rules

Open bhirsz opened this issue 1 year ago • 8 comments

Robot Framework 7.2 introduce new syntax: GROUP. We need to add rules that will cover it.

Proposals:

  1. GROUP without name
GROUP
    Keyword Call
END
  1. Nested GROUPs
GROUP    Named
    GROUP  At some point we may recommend not using nested groups / use custom keywords instead
        Keyword Call
    END
END
  1. Too many parameters - already handled by parsing error
    GROUP    Too    many    values
        Fail    Not run
    END
  1. Empty group
GROUP    Empty group
END
  1. Invalid syntax (for some reason parsing error does not catch it):
GROUP    Group without end
```

bhirsz avatar Jan 02 '25 17:01 bhirsz

Also #1158

bhirsz avatar Jan 02 '25 17:01 bhirsz

How about GROUP with a single keyword in the body?

GROUP  foo
    Do only one thing
END

Lakitna avatar Jan 07 '25 11:01 Lakitna

And maybe a rule for too deeply nested stuff. You can do this without groups, but groups make it easier to create deep nesting:

GROUP  foo
  IF  something
    FOR  i  IN  range(10)
      GROUP  bar
        ...
      END
    END
  END
END

Lakitna avatar Jan 07 '25 11:01 Lakitna

How about GROUP with a single keyword in the body?

GROUP  foo
    Do only one thing
END

yes, typically we should avoid it - we can add len rule for it (configurable if needed). Also too big group rule

bhirsz avatar Jan 07 '25 11:01 bhirsz

any ideas to get this published?

jannek76 avatar Apr 07 '25 11:04 jannek76

It should be implemented first :) currently I'm handling ongoing issues after 6.0 release, but if not someone else, then I could take a look ina upcoming weeks. If you have ideas for different group rules then also please share.

bhirsz avatar Apr 07 '25 11:04 bhirsz

Hi! Any update on covering GROUP syntax ? I have used the formatter & all indentations got removed inside GROUP sections:

Before formatting:

GROUP    Name of Group
     Keyword Call
     Keyword Call
     Keyword Call
END

After formatting:

GROUP    Name of Group
Keyword Call
Keyword Call
Keyword Call
END

Is there a workaround to avoid this ?

MarvKler avatar Jul 31 '25 13:07 MarvKler

@MarvKler

It is not expected behaviour - I will check it out. At minimum Robocop should support GROUP syntax as it is. This thread was created for additional support (like extra linter rules). I'm not sure if you are related but at the same time other user reported #1424 . I will give updates to this issue in that thread

bhirsz avatar Jul 31 '25 20:07 bhirsz