Repository: MarketSquare/robotframework-robocop
Pull request #1338 (2025-03-23 10:16:04)

Adjust settings order between linter and formatter
From https://github.com/MarketSquare/robotframework-tidy/issues/719


Patch:
diff --git a/docs/releasenotes/6.0.0a3.rst b/docs/releasenotes/6.0.0a3.rst
index 82e319c..6095a68 100644
--- a/docs/releasenotes/6.0.0a3.rst
+++ b/docs/releasenotes/6.0.0a3.rst
@@ -686,6 +686,18 @@ features. It is now replaced with Python format syntax::
 
 It's important only for users who have custom rules using templates in messages.
 
+Dropped support for Robot Framework 3.2
+---------------------------------------
+
+Since Robocop supported Robot Framework >=3.2.2 and Robotidy >=4.0 we had to use 4.0 as baseline version.
+However Robocop can still be used to lint code written for RF 3 - but you need environment with at least RF 4 to run
+Robocop.
+
+Dropped support for Python 3.8
+------------------------------
+
+Python 3.8 is no longer supported by Python foundation - we are also dropping support for it.
+
 Normalized output path configuration in json and sarif reports
 --------------------------------------------------------------
 
@@ -844,6 +856,37 @@ Since target version is now shared option, it needs to be configured in common s
     [tool.robocop.format]
     # previously it could be only configured in format
 
+Adjusted order of settings in OrderSettings formatter to match Robocop rules
+----------------------------------------------------------------------------
+
+Robocop and Robotidy followed different recommended order of keyword and test case settings. Adjusted formatted
+to follow Robocop order, which is also recommended order by the Robot Framework Style Guide::
+
+    *** Test Cases ***
+    Test Case
+        [Documentation]
+        [Tags]
+        [Timeout]
+        [Setup]
+        [Template]
+        Static Variable Assignments
+        Keyword Calls
+        Verification Keyword Call
+        [Teardown]
+
+
+    *** Keywords ***
+    Keyword
+        [Documentation]
+        [Tags]
+        [Arguments]
+        [Timeout]
+        [Setup]
+        Static Variable Assignments
+        Keyword Calls
+        [Teardown]
+
+
 New rules and rule updates
 ===========================
 
diff --git a/docs/source/integrations.rst b/docs/source/integrations.rst
index 2bb629a..3fe09a1 100644
--- a/docs/source/integrations.rst
+++ b/docs/source/integrations.rst
@@ -19,7 +19,7 @@ To use Robocop as `pre-commit <https://pre-commit.com/>`_ hook, you need followi
 
     - repo: https://github.com/MarketSquare/robotframework-robocop
       # Robocop version.
-      rev: 6.0
+      rev: v6.0
       hooks:
         # Run the linter.
         - id: robocop
diff --git a/src/robocop/__init__.py b/src/robocop/__init__.py
index ccba933..ecc2fc7 100644
--- a/src/robocop/__init__.py
+++ b/src/robocop/__init__.py
@@ -1,1 +1,1 @@
-__version__ = "6.0.0b1"
+__version__ = "6.0.0b2"
diff --git a/src/robocop/formatter/formatters/OrderSettings.py b/src/robocop/formatter/formatters/OrderSettings.py
index 4919377..d7865c6 100644
--- a/src/robocop/formatter/formatters/OrderSettings.py
+++ b/src/robocop/formatter/formatters/OrderSettings.py
@@ -61,13 +61,13 @@ class OrderSettings(Formatter):
         [Return]  ${value}
     ```
 
-    Test case settings ``[Documentation]``, ``[Tags]``, ``[Template]``, ``[Timeout]``, ``[Setup]`` are put before
+    Test case settings ``[Documentation]``, ``[Tags]``, ``[Timeout]``, ``[Setup]``, ``[Template]`` are put before
     test case body and ``[Teardown]`` is moved to the end of test case.
 
     Default order can be changed using following parameters:
-      - ``keyword_before = documentation,tags,timeout,arguments``
+      - ``keyword_before = documentation,tags,arguments,timeout,setup``
       - ``keyword_after = teardown,return``
-      - ``test_before = documentation,tags,template,timeout,setup``
+      - ``test_before = documentation,tags,timeout,setup,template``
       - ``test_after = teardown``
 
     Not all settings names need to be passed to given parameter. Missing setting names are not ordered. Example::
@@ -99,7 +99,7 @@ class OrderSettings(Formatter):
         self,
         keyword_before: str = "documentation,tags,arguments,timeout,setup",
         keyword_after: str = "teardown,return",
-        test_before: str = "documentation,tags,template,timeout,setup",
+        test_before: str = "documentation,tags,timeout,setup,template",
         test_after: str = "teardown",
     ):
         super().__init__()
diff --git a/uv.lock b/uv.lock
index 5e0bd1f..1eb08d5 100644
--- a/uv.lock
+++ b/uv.lock
@@ -536,7 +536,7 @@ wheels = [
 
 [[package]]
 name = "robotframework-robocop"
-version = "6.0.0a1"
+version = "6.0.0b2"
 source = { editable = "." }
 dependencies = [
     { name = "jinja2" },


Test patch:
diff --git a/tests/formatter/formatters/OrderSettings/expected/custom_order_all_end.robot b/tests/formatter/formatters/OrderSettings/expected/custom_order_all_end.robot
index d483af1..9c8eb23 100644
--- a/tests/formatter/formatters/OrderSettings/expected/custom_order_all_end.robot
+++ b/tests/formatter/formatters/OrderSettings/expected/custom_order_all_end.robot
@@ -41,6 +41,12 @@ Test case 5  # comment1
    [Documentation]  this is
    [Teardown]  teardown
 
+Setup And Template
+    Keyword
+    [Template]
+    [Setup]
+
+
 *** Keywords ***
 Keyword
     Keyword
diff --git a/tests/formatter/formatters/OrderSettings/expected/custom_order_all_end_pre_rf7.robot b/tests/formatter/formatters/OrderSettings/expected/custom_order_all_end_pre_rf7.robot
index 2de849f..b6f2dbd 100644
--- a/tests/formatter/formatters/OrderSettings/expected/custom_order_all_end_pre_rf7.robot
+++ b/tests/formatter/formatters/OrderSettings/expected/custom_order_all_end_pre_rf7.robot
@@ -41,6 +41,12 @@ Test case 5  # comment1
    [Documentation]  this is
    [Teardown]  teardown
 
+Setup And Template
+    Keyword
+    [Template]
+    [Setup]
+
+
 *** Keywords ***
 Keyword
     Keyword
diff --git a/tests/formatter/formatters/OrderSettings/expected/custom_order_default.robot b/tests/formatter/formatters/OrderSettings/expected/custom_order_default.robot
index 372440b..c4274f1 100644
--- a/tests/formatter/formatters/OrderSettings/expected/custom_order_default.robot
+++ b/tests/formatter/formatters/OrderSettings/expected/custom_order_default.robot
@@ -10,8 +10,8 @@ Test case 1
     [Teardown]  Teardown
 
 Test case 2
-    [Template]  Template
     [Timeout]  timeout
+    [Template]  Template
     Keyword
     [Timeout]  timeout2  # this is error because it is duplicate
 
@@ -41,6 +41,12 @@ Test case 5  # comment1
    Keyword3
    [Teardown]  teardown
 
+Setup And Template
+    [Setup]
+    [Template]
+    Keyword
+
+
 *** Keywords ***
 Keyword
     [Documentation]  this is
diff --git a/tests/formatter/formatters/OrderSettings/expected/custom_order_default_pre_rf7.robot b/tests/formatter/formatters/OrderSettings/expected/custom_order_default_pre_rf7.robot
index ad7bc02..0af0ed1 100644
--- a/tests/formatter/formatters/OrderSettings/expected/custom_order_default_pre_rf7.robot
+++ b/tests/formatter/formatters/OrderSettings/expected/custom_order_default_pre_rf7.robot
@@ -10,8 +10,8 @@ Test case 1
     [Teardown]  Teardown
 
 Test case 2
-    [Template]  Template
     [Timeout]  timeout
+    [Template]  Template
     Keyword
     [Timeout]  timeout2  # this is error because it is duplicate
 
@@ -41,6 +41,12 @@ Test case 5  # comment1
    Keyword3
    [Teardown]  teardown
 
+Setup And Template
+    [Setup]
+    [Template]
+    Keyword
+
+
 *** Keywords ***
 Keyword
     [Documentation]  this is
diff --git a/tests/formatter/formatters/OrderSettings/expected/custom_order_without_test_teardown.robot b/tests/formatter/formatters/OrderSettings/expected/custom_order_without_test_teardown.robot
index 63a50a9..94ffaa1 100644
--- a/tests/formatter/formatters/OrderSettings/expected/custom_order_without_test_teardown.robot
+++ b/tests/formatter/formatters/OrderSettings/expected/custom_order_without_test_teardown.robot
@@ -10,8 +10,8 @@ Test case 1
     Keyword
 
 Test case 2
-    [Template]  Template
     [Timeout]  timeout
+    [Template]  Template
     Keyword
     [Timeout]  timeout2  # this is error because it is duplicate
 
@@ -41,6 +41,12 @@ Test case 5  # comment1
    # comment3
    Keyword3
 
+Setup And Template
+    [Setup]
+    [Template]
+    Keyword
+
+
 *** Keywords ***
 Keyword
     [Documentation]  this is
diff --git a/tests/formatter/formatters/OrderSettings/expected/custom_order_without_test_teardown_pre_rf7.robot b/tests/formatter/formatters/OrderSettings/expected/custom_order_without_test_teardown_pre_rf7.robot
index da557db..9c3d6f5 100644
--- a/tests/formatter/formatters/OrderSettings/expected/custom_order_without_test_teardown_pre_rf7.robot
+++ b/tests/formatter/formatters/OrderSettings/expected/custom_order_without_test_teardown_pre_rf7.robot
@@ -10,8 +10,8 @@ Test case 1
     Keyword
 
 Test case 2
-    [Template]  Template
     [Timeout]  timeout
+    [Template]  Template
     Keyword
     [Timeout]  timeout2  # this is error because it is duplicate
 
@@ -41,6 +41,12 @@ Test case 5  # comment1
    # comment3
    Keyword3
 
+Setup And Template
+    [Setup]
+    [Template]
+    Keyword
+
+
 *** Keywords ***
 Keyword
     [Documentation]  this is
diff --git a/tests/formatter/formatters/OrderSettings/expected/test.robot b/tests/formatter/formatters/OrderSettings/expected/test.robot
index 372440b..c4274f1 100644
--- a/tests/formatter/formatters/OrderSettings/expected/test.robot
+++ b/tests/formatter/formatters/OrderSettings/expected/test.robot
@@ -10,8 +10,8 @@ Test case 1
     [Teardown]  Teardown
 
 Test case 2
-    [Template]  Template
     [Timeout]  timeout
+    [Template]  Template
     Keyword
     [Timeout]  timeout2  # this is error because it is duplicate
 
@@ -41,6 +41,12 @@ Test case 5  # comment1
    Keyword3
    [Teardown]  teardown
 
+Setup And Template
+    [Setup]
+    [Template]
+    Keyword
+
+
 *** Keywords ***
 Keyword
     [Documentation]  this is
diff --git a/tests/formatter/formatters/OrderSettings/expected/test_pre_rf7.robot b/tests/formatter/formatters/OrderSettings/expected/test_pre_rf7.robot
index ad7bc02..0af0ed1 100644
--- a/tests/formatter/formatters/OrderSettings/expected/test_pre_rf7.robot
+++ b/tests/formatter/formatters/OrderSettings/expected/test_pre_rf7.robot
@@ -10,8 +10,8 @@ Test case 1
     [Teardown]  Teardown
 
 Test case 2
-    [Template]  Template
     [Timeout]  timeout
+    [Template]  Template
     Keyword
     [Timeout]  timeout2  # this is error because it is duplicate
 
@@ -41,6 +41,12 @@ Test case 5  # comment1
    Keyword3
    [Teardown]  teardown
 
+Setup And Template
+    [Setup]
+    [Template]
+    Keyword
+
+
 *** Keywords ***
 Keyword
     [Documentation]  this is
diff --git a/tests/formatter/formatters/OrderSettings/source/test.robot b/tests/formatter/formatters/OrderSettings/source/test.robot
index 268b370..4a46a51 100644
--- a/tests/formatter/formatters/OrderSettings/source/test.robot
+++ b/tests/formatter/formatters/OrderSettings/source/test.robot
@@ -41,6 +41,12 @@ Test case 5  # comment1
    # comment3
    Keyword3
 
+Setup And Template
+    Keyword
+    [Template]
+    [Setup]
+
+
 *** Keywords ***
 Keyword
     [Teardown]  Keyword
diff --git a/tests/formatter/formatters/OrderSettings/test_formatter.py b/tests/formatter/formatters/OrderSettings/test_formatter.py
index 1a20954..6755999 100644
--- a/tests/formatter/formatters/OrderSettings/test_formatter.py
+++ b/tests/formatter/formatters/OrderSettings/test_formatter.py
@@ -19,7 +19,7 @@ class TestOrderSettings(FormatterAcceptanceTest):
             (
                 "documentation,tags,arguments,timeout,setup",
                 "teardown,return",
-                "documentation,tags,template,timeout,setup",
+                "documentation,tags,timeout,setup,template",
                 "teardown",
                 "custom_order_default",
             ),