Skip to content

feat!: needextend effects must be local - #689

Open
AlexanderLanin wants to merge 1 commit into
eclipse-score:mainfrom
etas-contrib:strict-needextend
Open

feat!: needextend effects must be local#689
AlexanderLanin wants to merge 1 commit into
eclipse-score:mainfrom
etas-contrib:strict-needextend

Conversation

@AlexanderLanin

@AlexanderLanin AlexanderLanin commented Aug 4, 2026

Copy link
Copy Markdown
Member

We wanted to ensure local needextend for a while, but it seems we forgot to actually activate the check. Besides activating, this PR also improves and fixes the check itself.


Downstream PRs:

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run --lockfile_mode=error //src:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.6.0) and connecting to it...
INFO: Invocation ID: 668ee706-fa30-4a81-82ee-cac54dcc888b
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
    currently loading: src
WARNING: Target pattern parsing failed.
ERROR: Skipping '//src:license-check': no such target '//src:license-check': target 'license-check' not declared in package 'src' defined by /home/runner/work/docs-as-code/docs-as-code/src/BUILD
ERROR: no such target '//src:license-check': target 'license-check' not declared in package 'src' defined by /home/runner/work/docs-as-code/docs-as-code/src/BUILD
INFO: Elapsed time: 6.048s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR activates and refactors the SCORE “needextend must be local to the current document” policy enforcement, updates documentation to reflect the now-active constraint, and adds/adjusts tests so warnings can be asserted for both needs and needextend directives.

Changes:

  • Refactors check_needs_extends into smaller helpers and enforces explicit c.this_doc() usage plus cross-document match detection.
  • Adds unit tests for cross-document needextend matches and updates the file-based RST test case to expect the new policy warning.
  • Extends the file-based warning expectation runner to read :expect:/:expect_not: annotations from needextend directives (via modifications).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/extensions/score_metamodel/tests/test_rules_file_based.py Adds helper to read expectations from needextend modifications and uses it in warning checks.
src/extensions/score_metamodel/tests/test_check_needs_extends.py New mocked unit tests verifying cross-document matching produces the expected warning.
src/extensions/score_metamodel/tests/rst/options/test_need_extends.rst Activates an RST-level expectation for missing c.this_doc() on a needextend filter.
src/extensions/score_metamodel/checks/check_needs_extends.py Refactors and strengthens the needextend policy checks (explicit c.this_doc() + cross-document match detection).
docs/how-to/write_docs.rst Updates documentation note to reflect the now-enforced local-only needextend rule.

Comment on lines +97 to +107
try:
return filter_needs_mutable(
all_needs,
needs_config,
need_filter,
location=location,
origin_docname=location[0],
)
except Exception as e:
_warn(f"Invalid filter {need_filter!r}: {e}", location)
return []
Comment on lines +76 to +84
need_id = needextend["filter"]
try:
return [all_needs[need_id]]
except KeyError:
_warn(
f"Provided id {need_id!r} for needextend does not exist.",
location,
)
return []
Comment on lines 246 to +249

line_nr = need.get("lineno")

for raw in cast("list[str]", need.get("expect") or []):
for raw in _get_expectations(need, "expect"):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants