From f7b429de2ecefcd51e6d419fc58817e5b5c25f34 Mon Sep 17 00:00:00 2001 From: Maciej Pijanowski Date: Sun, 14 Jul 2024 18:04:42 +0200 Subject: [PATCH] pre-commit: add robocop and robotidy Signed-off-by: Maciej Pijanowski --- .pre-commit-config.yaml | 10 ++++++++ .robocop | 1 + .robotidy | 52 +++++++++++++++++++++++++++++++++++++++++ robocop.toml | 42 +++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 .robocop create mode 100644 .robotidy create mode 100644 robocop.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 46611fa..ad9bde3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -59,3 +59,13 @@ repos: rev: 24.4.2 hooks: - id: black + + - repo: https://github.com/MarketSquare/robotframework-tidy + rev: 4.8.1 + hooks: + - id: robotidy + + - repo: https://github.com/MarketSquare/robotframework-robocop + rev: 5.0.1 + hooks: + - id: robocop diff --git a/.robocop b/.robocop new file mode 100644 index 0000000..17e5dea --- /dev/null +++ b/.robocop @@ -0,0 +1 @@ +--config robocop.toml diff --git a/.robotidy b/.robotidy new file mode 100644 index 0000000..b660836 --- /dev/null +++ b/.robotidy @@ -0,0 +1,52 @@ +spacecount = 4 +indent = 4 +continuation-indent = 4 +line-length = 120 +lineseparator = "unix" +separator = "space" + +transform = [ + "AddMissingEnd", + "AlignSettingsSection", + "AlignVariablesSection", + "DiscardEmptySections", + "InlineIf", + "MergeAndOrderSections", + "NormalizeAssignments", + "NormalizeComments", + "NormalizeNewLines", + "NormalizeSectionHeaderName", + "NormalizeSeparators", + "NormalizeSettingName", + "OrderSettings", + "OrderSettingsSection", + "RemoveEmptySettings", + "RenameKeywords", + "RenameTestCases", + "RenameVariables", + "ReplaceBreakContinue", + "ReplaceEmptyValues", + "ReplaceReturns", + "ReplaceRunKeywordIf", + "SplitTooLongLine", +] + +# Consider enabling: +# "SmartSortKeywords", + + +configure = [ + "NormalizeAssignments:equal_sign_type=equal_sign", + "NormalizeAssignments:equal_sign_type_variables=equal_sign", + "OrderSettingsSection:group_order=documentation,imports,settings,tags", + "OrderSettingsSection:documentation_order=documentation,metadata", + "OrderSettingsSection:imports_order=library,resource,variables", + "OrderSettingsSection:settings_order=suite_setup,suite_teardown,test_setup,test_teardown,test_timeout,test_template", + "RenameKeywords:ignore_library=False", + "RenameVariables:settings_section_case=upper", + "RenameVariables:variables_section_case=upper", + "RenameVariables:variables_section_case=upper", + "RenameVariables:variable_separator=underscore", + "SplitTooLongLine:split_single_value=True", + "SplitTooLongLine:align_new_line=True", +] diff --git a/robocop.toml b/robocop.toml new file mode 100644 index 0000000..81cfdac --- /dev/null +++ b/robocop.toml @@ -0,0 +1,42 @@ +[tool.robocop] +configure = [ + # TODO: add missing documentation for keywords and re-enable + "0201:enabled:False", + # TODO: add missing documentation for test cases and re-enable + "0202:enabled:False", + # TODO: add missing documentation for test suitdes and re-enable + "0203:enabled:False", + # TODO: consider re-enabling + "0301:enabled:False", + # TODO: consider fixing and re-enabling + "0316:enabled:False", + # TODO: fix and re-enable + "0319:enabled:False", + # TODO: fix and re-enable + "0327:enabled:False", + # TODO: fix and re-enable + "0328:enabled:False", + # TODO: consider reducing to default 40, or less + "0501:max_len:50", + # TODO: consider reducing to default 10, or less + "0503:max_calls:50", + # TODO: consider reducing to dfeault 20, or less + "0504:max_len:50", + # TODO: consider reducing to dfeault 10, or less + "0505:max_calls:50", + # TODO: reduce to default 400 or so + "0506:max_lines:5000", + # TODO: reduce to 120/80 + "0508:line_length:180", + "0701:enabled:False", + # TODO: fix and re-enable + "0908:enabled:False", + # TODO: re-enable after fixes + "0913:enabled:False", + # TODO: fix unused variables and re-enable + "0920:enabled:False", + # TODO: consider fixing and re-enabling + "0922:enabled:False", + # TODO: fix and re-enable + "0924:enabled:False" +]