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
2 changes: 1 addition & 1 deletion docs/it/about/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Sviluppato da [PythonWoods](https://github.com/PythonWoods), è progettato per e
---

Storico completo delle release e policy della linea attiva.
La linea 0.4.x e stata abbandonata; la stabilizzazione attiva e 0.5.x.
La linea 0.4.x è stata abbandonata; la stabilizzazione attiva è la 0.5.x.

[:lucide-arrow-right: Leggi](https://github.com/PythonWoods/zenzic/blob/main/CHANGELOG.md)

Expand Down
8 changes: 7 additions & 1 deletion src/zenzic/core/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,13 @@ def load_selected_rules(self, plugin_ids: Sequence[str]) -> list[BaseRule]:
"""
from zenzic.core.exceptions import PluginContractError # deferred: avoid circular import

requested = [pid.strip() for pid in plugin_ids if pid.strip()]
requested: list[str] = []
seen: set[str] = set()
for pid in plugin_ids:
cleaned = pid.strip()
if cleaned and cleaned not in seen:
seen.add(cleaned)
requested.append(cleaned)
if not requested:
return []

Expand Down
29 changes: 29 additions & 0 deletions tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
AdaptiveRuleEngine,
BaseRule,
CustomRule,
PluginRegistry,
RuleFinding,
Violation,
VSMBrokenLinkRule,
Expand Down Expand Up @@ -264,6 +265,34 @@ def test_scan_docs_with_unknown_plugin_raises_contract_error(tmp_path: Path) ->
scan_docs_references(tmp_path, config)


def test_plugin_registry_deduplicates_requested_plugin_ids(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""Duplicate plugin IDs are loaded once while preserving declaration order."""

class _EP:
def __init__(self, name: str) -> None:
self.name = name

registry = PluginRegistry()
monkeypatch.setattr(
registry,
"_entry_points",
lambda: [_EP("acme"), _EP("beta")],
)

loaded_names: list[str] = []

def _fake_load(ep: _EP) -> BaseRule:
loaded_names.append(ep.name)
return _PluginTodoRule()

monkeypatch.setattr(registry, "_load_entry_point", _fake_load)

_rules = registry.load_selected_rules(["acme", "acme", "beta", "acme"]) # noqa: F841
assert loaded_names == ["acme", "beta"]


# ─── Cross-adapter custom rules (Dev 4 mandate) ───────────────────────────────


Expand Down
Loading