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
4 changes: 2 additions & 2 deletions docs/requirements/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ This section provides an overview of current process requirements and their clar
:parent_covered: YES

Docs-as-Code shall enforce that requirement descriptions do not contain the following weak words:
just, about, really, some, thing, absol-utely
ju-st, ab-out, rea-lly, so-me, th-ing, absol-utely

This rule applies to:

Expand Down Expand Up @@ -457,7 +457,7 @@ Mapping
================================ ===========================

.. note::
Some tool requirements do not have a matching process requirement.
Certain tool requirements do not have a matching process requirement.

.. tool_req:: Safety: enforce safe linking
:id: tool_req__docs_common_attr_safety_link_check
Expand Down
13 changes: 10 additions & 3 deletions src/extensions/score_draw_uml_funcs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@
from sphinx.application import Sphinx
from sphinx_needs.logging import get_logger

CollectResult = tuple[
str, # structure_text
str, # link_text
dict[str, str], # proc_impl_interfaces
dict[str, list[str]], # proc_used_interfaces
dict[str, str], # impl_comp
list[str], # proc_modules
]
Comment on lines +50 to +57
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is quiet random in this PR, has not much to do with the issue you're trying to solve.

Don't mix in random changes please (even if they are valid).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As requested from PR: #211, I did the required fixes for the remaining comments

It's the comment related to creating a type for the return value of the function, as it is complex

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ye, but that should not be in this PR. As it's not related with the fix / issue you are fixing here.


logger = get_logger(__file__)


Expand Down Expand Up @@ -399,9 +408,7 @@ def _collect_interfaces_and_modules(
proc_used_interfaces: dict[str, list[str]],
structure_text: str,
link_text: str,
) -> tuple[
str, str, dict[str, str], dict[str, list[str]], dict[str, str], list[str]
]:
) -> CollectResult:
"""Process interfaces and load modules for implementation."""
for iface in interfacelist:
if all_needs.get(iface):
Expand Down
15 changes: 8 additions & 7 deletions src/extensions/score_metamodel/checks/attributes_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

import string
Comment thread
MaximilianSoerenPollak marked this conversation as resolved.

from score_metamodel import CheckLogger, ProhibitedWordCheck, ScoreNeedType, local_check
from sphinx.application import Sphinx
from sphinx_needs.data import NeedsInfoType
Expand Down Expand Up @@ -70,11 +72,9 @@ def check_id_length(app: Sphinx, need: NeedsInfoType, log: CheckLogger):
if parts[1] == "example_feature":
max_lenght += 17 # _example_feature_
if len(need["id"]) > max_lenght:
length = 0
if "example_feature" not in need["id"]:
length = len(need["id"])
else:
length = len(need["id"]) - 17
length = len(need["id"])
if "example_feature" in need["id"]:
length -= 17
msg = (
f"exceeds the maximum allowed length of 45 characters "
"(current length: "
Expand All @@ -92,9 +92,10 @@ def _check_options_for_prohibited_words(
for option in options:
forbidden_words = prohibited_word_checks.option_check[option]
for word in need[option].split():
if word in forbidden_words:
normalized = word.strip(string.punctuation).lower()
if normalized in forbidden_words:
msg = (
f"contains a weak word: `{word}` in option: `{option}`. "
f"contains a weak word: `{normalized}` in option: `{option}`. "
"Please revise the wording."
)
log.warning_for_need(need, msg)
Expand Down
2 changes: 2 additions & 0 deletions src/extensions/score_metamodel/checks/check_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def remove_prefix(word: str, prefixes: list[str]) -> str:
need, f"is missing required {field_type}: `{field}`."
)
continue # Skip empty optional fields
# Try except used to add more context to Error without passing variables
# just for that to function
try:
values = _normalize_values(raw_value)
except ValueError as err:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@



.. Title of an architecture element contains a stop word
.. Title of an architecture element contains a stop word
#EXPECT: stkh_req__test_title_bad: contains a weak word: `must` in option: `title`. Please revise the wording.

.. stkh_req:: This must work
Expand All @@ -40,7 +40,7 @@

#EXPECT-NOT: stkh_req__test_title_good: contains a weak word: `must` in option: `title`. Please revise the wording.

.. stkh_req:: This is a teset
.. stkh_req:: This is a test
:id: stkh_req__test_title_good


Expand Down Expand Up @@ -73,3 +73,21 @@
:id: feat_arc_sta_desc_good

This should really work


#EXPECT: tool_req__docs_common_attr_desc_wording: contains a weak word: `just` in option: `content`. Please revise the wording.

.. tool_req:: Enforces description wording rules
:id: tool_req__docs_common_attr_desc_wording
:tags: Common Attributes
:implemented: YES
:satisfies:
PROCESS_gd_req__req_desc_weak,
:parent_covered: YES

Docs-as-Code shall enforce that requirement descriptions do not contain the following weak words:
just, about, really, some, thing, absolut-ely

This rule applies to:

* all requirement types defined in :need:`tool_req__docs_req_types`, except process requirements.
20 changes: 20 additions & 0 deletions src/extensions/score_metamodel/tests/test_check_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,23 @@ def test_unknown_option_present_in_neither_req_opt_neither_opt_opt(self):
"has these extra options: `other_option`.",
expect_location=False,
)

def test_invalid_option_value_type_raises_value_error(self):
# Given a need with an option of wrong type (list with non-str)
need_1 = need(
target_id="tool_req__002",
id="tool_req__002",
type="tool_req",
some_required_option=123,
docname=None,
lineno=None,
)

logger = fake_check_logger()
app = Mock(spec=Sphinx)
app.config = Mock()
app.config.needs_types = self.NEED_TYPE_INFO
app.config.allowed_external_prefixes = []

with pytest.raises(ValueError, match="Only Strings are allowed"):
check_options(app, need_1, logger)
4 changes: 2 additions & 2 deletions src/tests/test_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,8 @@ def run_test_commands():
def setup_test_environment(sphinx_base_dir, pytestconfig):
"""Set up the test environment and return necessary paths and metadata."""
git_root = find_git_root()
if git_root is None:
raise RuntimeError("Git root was not found")

assert git_root is None, "Git root was not found"
Comment thread
MaximilianSoerenPollak marked this conversation as resolved.

gh_url = get_github_base_url()
current_hash = get_current_git_commit(git_root)
Expand Down
Loading