Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/robocop/linter/rules/duplications.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ def __init__(self) -> None:
def section_order_to_str(order: dict[str, int]) -> str:
by_index = sorted(order.items(), key=lambda x: x[1])
name_map = {
Token.COMMENT_HEADER: "Comments",
Token.SETTING_HEADER: "Settings",
Token.VARIABLE_HEADER: "Variables",
Token.TESTCASE_HEADER: "Test Cases / Tasks",
Expand Down
1 change: 1 addition & 0 deletions src/robocop/linter/rules/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def parse_test_case_order_param(value: str) -> list[str]:

def configure_sections_order(value: str) -> dict[str, int]:
section_map: dict[str, str] = {
"comments": Token.COMMENT_HEADER,
"settings": Token.SETTING_HEADER,
"variables": Token.VARIABLE_HEADER,
"testcase": Token.TESTCASE_HEADER,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test.robot:11:1 [W] ORD03 '*** Comments ***' section header is defined in wrong order: Settings > Comments > Variables > Test Cases / Tasks > Keywords
test.robot:20:1 [W] ORD03 '*** Settings ***' section header is defined in wrong order: Settings > Comments > Variables > Test Cases / Tasks > Keywords
test.robot:23:1 [W] ORD03 '*** Variables ***' section header is defined in wrong order: Settings > Comments > Variables > Test Cases / Tasks > Keywords

Found 3 issues.
5 changes: 5 additions & 0 deletions tests/linter/rules/order/section_out_of_order/golden.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*** Comments ***
*** Settings ***
*** Variables ***
*** Test Cases ***
*** Keywords ***
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
test


*** Settings ***
*** Variables ***
*** Test Cases ***
*** Keywords ***
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*** Comments ***
*** Settings ***
*** Test Cases ***
*** Keywords ***
14 changes: 14 additions & 0 deletions tests/linter/rules/order/section_out_of_order/test_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,17 @@ def test_custom_order(self, sections_order):

def test_extended(self):
self.check_rule(src_files=["test.robot"], expected_file="expected_extended.txt", output_format="extended")

def test_comments_section(self):
# bug #1724
self.check_rule(
src_files=["test.robot", "golden_without_comment_header.robot"],
expected_file="expected_output_comments.txt",
configure=["section-out-of-order.sections_order=settings,comments,variables,testcases,keywords"],
)

def test_good_order(self):
self.check_rule(
src_files=["golden.robot", "missing_sections.robot", "golden_without_comment_header.robot"],
expected_file=None,
)
Loading