From 99e8cc3d1756ecb927a2462a1dfa85c464e35525 Mon Sep 17 00:00:00 2001 From: Maximilian Pollak Date: Wed, 21 May 2025 10:19:48 +0200 Subject: [PATCH 1/2] Fixed wrong check activation Check found False positives due to 'process' being moved and loosing it's prefix. --- .../checks/attributes_format.py | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/extensions/score_metamodel/checks/attributes_format.py b/src/extensions/score_metamodel/checks/attributes_format.py index d5d75efe5..864a73802 100644 --- a/src/extensions/score_metamodel/checks/attributes_format.py +++ b/src/extensions/score_metamodel/checks/attributes_format.py @@ -25,12 +25,35 @@ def check_id_format(app: Sphinx, need: NeedsInfoType, log: CheckLogger): the requirement id or not. --- """ + # These folders are taken from 'https://github.com/eclipse-score/process_description/tree/main/process' + # This means, any needs within any of these folders (no matter where they are) will not be required to have 3 parts + process_folder_names = [ + "general_concepts", + "introduction", + "process_areas", + "roles", + "standards", + "workflows", + "workproducts", + "process", + ] # Split the string by underscores parts = need["id"].split("__") - - if need["id"].startswith( - ("gd_", "wf__", "wp__", "rl__", "stkh_req__", "tool_req__", "doc__") - ) or ("process/" in str(need.get("docname", ""))): + if need["type"] in [ + "std_wp", + "document", # This is used in 'platform_managment' in score. + "gd_guidl", + "workflow", + "gd_chklst", + "std_req", + "role", + "doc_concept", + "gd_temp", + "gd_method", + "gd_req", + "workproduct", + "doc_getstrt", + ] or any(prefix in str(need.get("docname", "")) for prefix in process_folder_names): if len(parts) != 2 and len(parts) != 3: msg = ( "expected to consisting of one of these 2 formats:" @@ -46,7 +69,6 @@ def check_id_format(app: Sphinx, need: NeedsInfoType, log: CheckLogger): ) log.warning_for_option(need, "id", msg) - @local_check def check_id_length(app: Sphinx, need: NeedsInfoType, log: CheckLogger): """ From b42f6e1fcd3055bfc25f13b9834c08663bfe860c Mon Sep 17 00:00:00 2001 From: Maximilian Pollak Date: Wed, 21 May 2025 10:42:30 +0200 Subject: [PATCH 2/2] Fixed test & rst files Test and rst files needed fixing to comply with new check rules --- docs/index.rst | 2 +- examples/simple/index.rst | 3 ++- .../score_metamodel/checks/attributes_format.py | 1 + .../rst/attributes/test_attributes_format_id_format.rst | 8 ++++---- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index b23acaa27..9193ffaa7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -17,7 +17,7 @@ Hello World This is a simple example of a documentation page using the `docs` tool. .. stkh_req:: TestTitle - :id: stkh_req__test_requirement + :id: stkh_req__docs__test_requirement :status: valid :safety: QM :rationale: A simple requirement we need to enable a documentation build diff --git a/examples/simple/index.rst b/examples/simple/index.rst index e3c472088..7856e574a 100644 --- a/examples/simple/index.rst +++ b/examples/simple/index.rst @@ -17,7 +17,7 @@ Hello World This is a simple example of a documentation page using the `docs` tool. .. stkh_req:: TestTitle - :id: stkh_req__test_requirement + :id: stkh_req__docs__test_requirement :status: valid :safety: QM :rationale: A simple requirement we need to enable a documentation build @@ -26,6 +26,7 @@ This is a simple example of a documentation page using the `docs` tool. Some content to make sure we also can render this + .. .. std_req:: External Link Test Req .. :id: std_req__iso26262__testing .. :status: valid diff --git a/src/extensions/score_metamodel/checks/attributes_format.py b/src/extensions/score_metamodel/checks/attributes_format.py index 864a73802..a0017406a 100644 --- a/src/extensions/score_metamodel/checks/attributes_format.py +++ b/src/extensions/score_metamodel/checks/attributes_format.py @@ -69,6 +69,7 @@ def check_id_format(app: Sphinx, need: NeedsInfoType, log: CheckLogger): ) log.warning_for_option(need, "id", msg) + @local_check def check_id_length(app: Sphinx, need: NeedsInfoType, log: CheckLogger): """ diff --git a/src/extensions/score_metamodel/tests/rst/attributes/test_attributes_format_id_format.rst b/src/extensions/score_metamodel/tests/rst/attributes/test_attributes_format_id_format.rst index 07648c852..3c8025c5a 100644 --- a/src/extensions/score_metamodel/tests/rst/attributes/test_attributes_format_id_format.rst +++ b/src/extensions/score_metamodel/tests/rst/attributes/test_attributes_format_id_format.rst @@ -14,16 +14,16 @@ #CHECK: check_id_format .. Id does not consists of 3 parts -#EXPECT: std_wp__test__test__abcd.id (std_wp__test__test__abcd): expected to consisting of this format: `____`. +#EXPECT: stk_req__test.id (stk_req__test): expected to consisting of this format: `____`. -.. std_wp:: This is a test - :id: std_wp__test__test__abcd +.. stkh_req:: This is a test + :id: stk_req__test .. Id follows pattern #EXPECT-NOT: expected to consisting of this format: `____`. .. std_wp:: This is a test - :id: std_wp__test__abce + :id: std_wp__test__test__abcd .. Id starts with wp and number of parth is neither 2 nor 3 #EXPECT: wp__test__test__abcd.id (wp__test__test__abcd): expected to consisting of one of these 2 formats:`__` or `____`.