Move the code and terraform audits into the reviews plugin
Copy the standalone code-review and terraform-review skills into
plugins/reviews as audit-code and audit-terraform. The rename separates the
automated, linter-driven audits from the guided review-pr walkthrough that
already lived here.
Resolve bundled script paths through ${SKILL_DIR}, exported in a new step 0.
CLAUDE_PLUGIN_ROOT is not set in the Bash tool environment, so the obvious
substitution would have expanded to nothing and broken every collection
script invocation.
Replace the PLAN and DESIGN docs with READMEs written from the current
SKILL.md and scripts. The old docs had drifted badly: they named semgrep
where the code calls opengrep, scoped five review agents where there are
now eight, and predated Lua, PowerShell, and GitHub Actions support.
Add CONSISTENCY_NORMS to the audit-terraform agent inputs. The collection
script writes consistency_norms.json and the agent prompt declares it, but
SKILL.md never listed it, leaving the variable unsubstituted.
Drop the --ingest-verdicts instruction from both skills. review_stats.py
parses no arguments, so the ref-mode verdict template it told users to feed
back could never be read.
Point audit-terraform's smoke test at README.md and resolve its fixture
paths relative to the test file rather than an absolute home directory.
Tests: 197 passing (audit-code), 106 passing (audit-terraform).
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
from scripts.slicing import slice_for_agent
|
||||
|
||||
|
||||
def _manifest():
|
||||
return {
|
||||
"mode": "local",
|
||||
"base_ref": "origin/main",
|
||||
"head_ref": "HEAD",
|
||||
"default_branch": "main",
|
||||
"language_breakdown": {"python": 1, "javascript": 0, "typescript": 0, "csharp": 0, "skipped_files": []},
|
||||
"changed_files": [{"path": "foo.py", "language": "python", "added_lines": [[10, 50]]}],
|
||||
"findings": [
|
||||
{"tool": "vulture", "rule_id": "vulture:90pct", "severity": "medium",
|
||||
"file": "foo.py", "line": 10, "end_line": 10, "message": "unused function"},
|
||||
{"tool": "radon", "rule_id": "radon:cc=12", "severity": "medium",
|
||||
"file": "foo.py", "line": 20, "end_line": 40, "message": "high CCN"},
|
||||
{"tool": "interrogate", "rule_id": "interrogate:missing-docstring", "severity": "low",
|
||||
"file": "foo.py", "line": 5, "end_line": 5, "message": "missing docstring"},
|
||||
{"tool": "lizard", "rule_id": "lizard:ccn=22", "severity": "high",
|
||||
"file": "foo.py", "line": 30, "end_line": 60, "message": "high CCN"},
|
||||
{"tool": "knip", "rule_id": "knip:dead-export", "severity": "medium",
|
||||
"file": "src/a.ts", "line": 12, "end_line": 12, "message": "unused export"},
|
||||
{"tool": "jscpd", "rule_id": "jscpd:clone-40lines", "severity": "medium",
|
||||
"file": "foo.py", "line": 100, "end_line": 140, "message": "duplicate"},
|
||||
{"tool": "bandit", "rule_id": "B608", "severity": "high",
|
||||
"file": "foo.py", "line": 5, "end_line": 5, "message": "SQL injection"},
|
||||
{"tool": "ruff-idiom", "rule_id": "C901", "severity": "medium",
|
||||
"file": "foo.py", "line": 50, "end_line": 50, "message": "too complex"},
|
||||
{"tool": "ruff-idiom", "rule_id": "PLR0915", "severity": "medium",
|
||||
"file": "foo.py", "line": 60, "end_line": 60, "message": "too many statements"},
|
||||
{"tool": "ruff-idiom", "rule_id": "SIM117", "severity": "low",
|
||||
"file": "foo.py", "line": 70, "end_line": 70, "message": "combine with"},
|
||||
{"tool": "ruff-idiom", "rule_id": "PLR0913", "severity": "medium",
|
||||
"file": "foo.py", "line": 80, "end_line": 80, "message": "too many args"},
|
||||
],
|
||||
"package_diffs": {"python": {"added": [], "removed": [], "upgraded": []}},
|
||||
"tool_stats": {},
|
||||
"tools_unavailable": [],
|
||||
"errors": [],
|
||||
}
|
||||
|
||||
|
||||
def test_maintainability_slice_includes_dedicated_tools():
|
||||
sliced = slice_for_agent(_manifest(), "maintainability")
|
||||
tools = {f["tool"] for f in sliced["findings"]}
|
||||
assert tools >= {"vulture", "radon", "interrogate", "lizard", "knip", "jscpd"}
|
||||
|
||||
|
||||
def test_maintainability_slice_includes_complexity_idioms():
|
||||
sliced = slice_for_agent(_manifest(), "maintainability")
|
||||
rules = {f["rule_id"] for f in sliced["findings"]}
|
||||
assert "C901" in rules
|
||||
assert "PLR0915" in rules
|
||||
|
||||
|
||||
def test_maintainability_slice_excludes_security_and_dependency():
|
||||
sliced = slice_for_agent(_manifest(), "maintainability")
|
||||
tools = {f["tool"] for f in sliced["findings"]}
|
||||
assert "bandit" not in tools
|
||||
|
||||
|
||||
def test_maintainability_slice_excludes_non_complexity_idioms():
|
||||
sliced = slice_for_agent(_manifest(), "maintainability")
|
||||
rules = {f["rule_id"] for f in sliced["findings"]}
|
||||
assert "SIM117" not in rules
|
||||
assert "PLR0913" not in rules
|
||||
|
||||
|
||||
def test_consistency_slice_excludes_complexity_idioms():
|
||||
sliced = slice_for_agent(_manifest(), "consistency")
|
||||
rules = {f["rule_id"] for f in sliced["findings"]}
|
||||
assert "C901" not in rules
|
||||
assert "PLR0915" not in rules
|
||||
assert "SIM117" in rules
|
||||
assert "PLR0913" in rules
|
||||
Reference in New Issue
Block a user