-
Notifications
You must be signed in to change notification settings - Fork 47
Description
Describe the bug
I started to play with issue #174 and I ran into an issue.
If data is defined before the first data section, that part counts as Comments section (lines are considered as COMMENT tokens).
Currently, the mentioned 0509 Section is empty rule will fail for Comments section unless there is only one line which starts with robocop: string due to the check_if_empty function.
for child in node.body:
if isinstance(child, Comment):
if 'robocop:' in child.tokens[0].value and len(node.body) == 1:
break
elif not isinstance(child, EmptyLine):
break
else:
self.report("empty-section", node=node)To Reproduce
You can reproduce the issue with this test code:
Data before the first section is ignored in Robot Framework.
Second line in Comment section.
*** Settings ***
Documentation Dummy documentation.
*** Test Cases ***
Dummy Test Case
[Documentation] Dummy documentation.
No OperationThis one will pass.
robocop:Data before the first section is ignored in Robot Framework.
*** Settings ***
Documentation Dummy documentation.
*** Test Cases ***
Dummy Test Case
[Documentation] Dummy documentation.
No OperationExpected behavior
I suppose we should handle Comments section like the others.
Additional context
Is there any particular reason why the check_if_empty function was implemented this way?
If this is a bug, it should be an easy fix by removing the if 'robocop: ... part, I can do a pull request for it.