-
Notifications
You must be signed in to change notification settings - Fork 10
Reserve legacy aliases and advisory IDs against plugin rule collisions #485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ec2795a
7f070d2
c953bfa
97745c3
ae5f287
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -226,6 +226,32 @@ def _load_plugin_rules(self): | |
| ) | ||
| continue | ||
|
|
||
| # Legacy aliases still resolve to their builtin everywhere a | ||
| # rule is named (config keys, flags, suppressions), so a | ||
| # plugin claiming one could never be addressed under its own | ||
| # name. Advisory IDs are reserved for skillsaw's own notices | ||
| # — a rule reporting under one would never affect the exit | ||
| # code. | ||
| from .rules.builtin import RULE_ALIASES | ||
|
|
||
| if rid in RULE_ALIASES or rid in ADVISORY_RULE_IDS: | ||
|
not-stbenjam marked this conversation as resolved.
|
||
| reason = ( | ||
| f"'{rid}' is a legacy alias of builtin rule '{RULE_ALIASES[rid]}'" | ||
| if rid in RULE_ALIASES | ||
| else f"'{rid}' is reserved for skillsaw's own advisory notices" | ||
| ) | ||
| self._plugin_load_violations.append( | ||
| RuleViolation( | ||
| rule_id="plugin-load-error", | ||
| severity=Severity.WARNING, | ||
| message=( | ||
| f"Plugin '{plugin.name}' provides rule '{rid}', but " | ||
| f"{reason} — the plugin's rule was skipped." | ||
| ), | ||
| ) | ||
| ) | ||
| continue | ||
|
|
||
| self._known_rule_ids.add(rid) | ||
| if getattr(rule_instance, "deprecated", None) is not None: | ||
| self._deprecated_known[rid] = rule_instance | ||
|
|
@@ -398,6 +424,33 @@ def _load_custom_rule(self, rule_path: str): | |
| and not inspect.isabstract(obj) | ||
| ): | ||
| rule_instance = obj() | ||
|
|
||
| # Same reservation as plugin rules: a custom rule named | ||
| # after a legacy alias could never be addressed (config | ||
| # keys and flags resolve the alias to the builtin), and | ||
| # an advisory ID would exempt its findings from the exit | ||
| # code. | ||
| from .rules.builtin import RULE_ALIASES | ||
|
|
||
| rid = rule_instance.rule_id | ||
| if rid in RULE_ALIASES or rid in ADVISORY_RULE_IDS: | ||
|
not-stbenjam marked this conversation as resolved.
not-stbenjam marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a repository-local custom rule returns a canonical builtin ID such as AGENTS.md reference: AGENTS.md:L27-L29 Useful? React with 👍 / 👎. |
||
| reason = ( | ||
| f"'{rid}' is a legacy alias of builtin rule '{RULE_ALIASES[rid]}'" | ||
|
qodo-code-review[bot] marked this conversation as resolved.
|
||
| if rid in RULE_ALIASES | ||
| else f"'{rid}' is reserved for skillsaw's own advisory notices" | ||
| ) | ||
| self._plugin_load_violations.append( | ||
| RuleViolation( | ||
| rule_id="plugin-load-error", | ||
| severity=Severity.WARNING, | ||
| message=( | ||
| f"Custom rule file {path.name} provides rule '{rid}', " | ||
| f"but {reason} — the rule was skipped." | ||
| ), | ||
| ) | ||
| ) | ||
| continue | ||
|
|
||
| self._known_rule_ids.add(rule_instance.rule_id) | ||
| if getattr(rule_instance, "deprecated", None) is not None: | ||
| self._deprecated_known[rule_instance.rule_id] = rule_instance | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.