deniz-dotnet-general.coverage-analysis
Analyzes .NET Cobertura line, branch, and condition evidence. Activation requires supplied .NET coverage evidence (a report, percentages, or line, branch, or condition metrics), an explicit request to collect .NET coverage for analysis, or an explicit CRAP request. Use for coverage plateaus, target arithmetic, project-wide CRAP/refactoring-risk hotspots, or a targeted CRAP calculation on one exact method, class, or source file. A supplied report is analyzed directly without rerunning tests, installing tools, or generating reports. Project-wide requests rank complex, under-covered members; targeted requests filter existing method rows and report only the requested scope. DO NOT USE FOR: requests with none of that evidence or intent, including hypothetical change-survival questions; behavioral/pseudo-mutation gaps, test-code audits, writing tests, or running tests without coverage context.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- deniz-dotnet-general.coverage-analysis
- description
- Analyzes .NET Cobertura line, branch, and condition evidence. Activation requires supplied .NET coverage evidence (a report, percentages, or line, branch, or condition metrics), an explicit request to collect .NET coverage for analysis, or an explicit CRAP request. Use for coverage plateaus, target arithmetic, project-wide CRAP/refactoring-risk hotspots, or a targeted CRAP calculation on one exact method, class, or source file. A supplied report is analyzed directly without rerunning tests, installing tools, or generating reports. Project-wide requests rank complex, under-covered members; targeted requests filter existing method rows and report only the requested scope. DO NOT USE FOR: requests with none of that evidence or intent, including hypothetical change-survival questions; behavioral/pseudo-mutation gaps, test-code audits, writing tests, or running tests without coverage context.
02 资源文件 7
- 参考文档references/guidelines.md3.5 KB
- 参考文档references/output-format.md4.1 KB
- 参考文档references/report-generation.md2.0 KB
- 参考文档references/setup-discovery.md15.0 KB
- 脚本scripts/Compute-CrapScores.ps14.3 KB
- 脚本scripts/CoverageData.ps114.4 KB
- 脚本scripts/Extract-MethodCoverage.ps13.6 KB
03 SKILL.md 正文
Coverage Analysis
Purpose
Explain what .NET coverage evidence proves, reconcile target arithmetic, and identify the code blocking progress. Add complexity/CRAP ranking only when the user explicitly asks for risk hotspots, CRAP, priorities by risk, or refactoring safety.
When to Use
Use this skill for interpreting supplied .NET line/branch/condition evidence, coverage gaps and plateaus, target arithmetic, or explicit project-wide coverage-backed risk analysis.
When Not to Use
- Behavioral or pseudo-mutation gaps in existing tests — use
test-gap-analysis - Writing or generating tests — this skill identifies where tests are needed, not write them
- General test execution unrelated to coverage or CRAP analysis
- Only collecting .NET coverage or printing a raw percentage with no diagnosis — use
run-tests; use native tooling for non-.NET coverage collection or analysis. Interpreting .NET line/branch gaps remains in scope here
Inputs
| Input | Required | Default | Description |
|---|---|---|---|
| Target scope | No | None | Exact method name, class name, or source-file path; selects the targeted CRAP path |
| Project/solution path | No | Current directory | Path to the .NET solution or project |
| Line coverage threshold | No | 80% | Minimum acceptable line coverage |
| Branch coverage threshold | No | 70% | Minimum acceptable branch coverage |
| Existing Cobertura path | No | Discover only if not supplied | Preferred input; never rerun tests when usable |
| CRAP threshold | No | 30 | Used only for explicit risk/CRAP requests |
| Hotspot count | No | 3 | Explicit risk requests only; cap at 10 unless the user asks for more |
Discover optional inputs from the workspace. Do not ask for a project path when the current directory or a supplied report is sufficient.
Choose the smallest matching path
| User intent | Required work | Do not do |
|---|---|---|
| Explain a supplied excerpt, condition, or summary | Answer directly from the supplied evidence | Tools, CRAP, discovery, report files |
| Interpret a supplied Cobertura path or diagnose a plateau | Read that report, reconcile totals, name all material gaps, answer directly | Rerun tests, install tools, compute CRAP, or generate files unless explicitly requested |
| Compute CRAP for one exact method, class, or file | Resolve the Cobertura rows for that target and compute CRAP only for those rows | Project-wide hotspot ranking or report generation |
| Rank risk hotspots, compute project-wide CRAP, or assess refactoring safety | Use the supplied/existing report, read references/guidelines.md, and compute CRAP before ranking |
Coverage-only ranking or a full report template unless requested |
| Analyze coverage when no report exists | Invoke deniz-dotnet-general.run-tests to collect Cobertura coverage with the repository-compatible runner, then analyze the generated report |
Choose or execute a test command independently; CRAP unless risk was requested |
| Produce a full markdown/HTML/CSV report | First deliver the direct answer; then read references/output-format.md or references/report-generation.md |
Report generation before the answer |
Words such as analyze coverage, what is blocking coverage, or why is coverage stuck do not by themselves request CRAP. Explicit signals include risk hotspot, CRAP, complexity-weighted priority, safe to refactor, or an equivalent request to combine complexity with coverage.
Targeted CRAP path
When the user names one exact method, class, or source file, use supplied or
existing Cobertura data when available; otherwise follow the normal collection
path once. Then run
pwsh -File scripts/Extract-MethodCoverage.ps1 -CoberturaPath <report> -Filter all -OutputFormat json-v1
and read its exit code beside the JSON:
- Exit 2: the input is invalid or contradictory, such as a non-Cobertura root, covered counts above valid counts, or duplicate method identities. That is failed collection, not 0% coverage: regenerate coverage when possible, otherwise stop without publishing a CRAP score.
- Exit 3: the evidence is partial. Continue, and score only the rows whose measurements are exact.
- Exit 0: every measurement is exact.
Filter data.methods for a method target by exact Class plus exact Method,
and by exact Signature too when the user gives one; for a class target by
exact Class; for a file target by normalized File path (the script writes
/ separators). When a method target still matches more than one row, such as
overloads, report the ambiguity and the matching rows rather than widening the
selection. A report with no method rows, or no row that matches, is failed
collection or filtering, not 0% coverage: report that the target is absent from
the Cobertura data and do not invent a score.
A matching row with ComplexityStatus: unknown has a null Complexity: its
Cobertura method had no complexity attribute, or the merged reports disagree.
Count that method's decision points in the current source only when that source
is the revision the report was collected from, such as a report you just
collected from the unchanged checkout, and label the result a manual count. The
scripts record no source revision, so for any other report mark its CRAP score
unavailable rather than mix current complexity with old coverage. A row with
LineCoverageStatus: unknown has no line evidence, so its CRAP score is
unavailable. For each matching row with an exact or counted complexity and exact
line coverage, calculate:
CRAP(m) = complexity^2 * (1 - lineCoverage)^3 + complexity
Here lineCoverage is the fraction CoveredLines / TotalLines from the row, as
the shipped scorer computes it; the rounded LineCoverage percentage can shift
the score.
Report only the selected rows, the formula inputs, the resulting score, and one concrete coverage or complexity recommendation. Do not emit the project-wide hotspot inventory or optional reports unless the user separately requests them.
Existing-data fast path
When the user supplies a coverage excerpt, summary, or valid Cobertura path:
- Treat it as authoritative input and start there.
- Do not discover the solution or test projects unless source mapping is necessary.
- Do not run
dotnet test, install ReportGenerator, add a coverage package, or readreferences/setup-discovery.mdorreferences/report-generation.md. - Do not write
coverage-analysis.mdor create a report directory unless the user requested a saved/full report. - For interpretation and plateau questions, parse only the evidence needed to
answer. For explicit project-wide risk requests, use the bundled scripts as
described in
references/guidelines.md.
A failed read/view operation is not proof that a named path does not exist. Classify the failure, then make one targeted existence probe and use a normalized path or alternate reader only for confirmed tool availability, transport, or path-normalization failures and only after verifying the canonical path remains inside the workspace. Stop on content-exclusion, permission/policy, workspace-boundary, or unknown failures. Report a missing path only when the independent probe also fails; do not broaden the search or substitute another artifact.
Collection path
Use this path only when no usable coverage evidence exists and the user asked for analysis that requires it.
- Read
references/setup-discovery.md. - Prefer existing Cobertura discovered under the requested root.
- If none exists, invoke
deniz-dotnet-general.run-testsfor repository overlay, platform, runner, and command selection, and have it collect Cobertura once per entry point. - Analyze the resulting Cobertura. Compute CRAP only if risk analysis was explicitly requested.
When the workspace contains the project/test manifests needed by this path,
perform discovery directly and delegate collection to deniz-dotnet-general.run-tests. Do not ask
the user to attach files or pre-run coverage that the current workspace lets
you inspect and generate.
Do not modify production code. Do not add coverage packages, change project
manifests, or install global tools unless the user explicitly authorized
dependency or tooling changes. If the repository lacks a usable coverage
provider, report that exact prerequisite and the compatible command shape that
deniz-dotnet-general.run-tests identified, then stop.
The automatic collection path is for SDK-style projects. For classic non-SDK or
packages.config projects, use only a repository-owned coverage command. If none
exists, stop and request Cobertura XML. Never migrate the project, inject an
SDK-style provider, create a wrapper project, or report substitute coverage from
another assembly.
Interpretation and arithmetic invariants
- A line hit proves execution, not both decision outcomes.
condition-coverage="50% (1/2)"proves one reported outcome ran, but not which one. Recommend forcing the opposite outcome. Without source, never invent likely predicates or claim whether true or false is missing. State that compound predicates need independently exercised operands and short-circuit combinations when applicable; do not infer the exact combinations without source or fuller XML.- Derive overall totals from Cobertura's covered/valid line counts. For target
T, required covered lines areceiling(valid lines × T). - Projected coverage is
(current covered lines + newly covered distinct lines) / valid lines. State assumptions such as fully covering a method. - When asked whether one member can reach a target, show its maximum projected total and at least one concrete sufficient combination of supplied members or line gains. If no supplied combination is sufficient, say so.
- For a multi-member target, name the exact combination and resulting covered / valid total; saying only "combine it with another member" is incomplete.
- Reconcile member gaps against project totals. Method line ranges can overlap or omit class-level lines, so do not sum method counts as project truth.
- Never call one member the sole, entire, or all remaining gap unless its distinct uncovered lines exactly reconcile with the project total and no other below-threshold member remains.
- Name every supplied or extracted below-threshold member, but keep detail proportional: lead with the blockers, summarize the remainder in one sentence or a compact table.
Response contract
Answer the user's question in the first 2–4 sentences.
- Excerpt or arithmetic question: one explanation plus the next test or member priority. No dashboard.
- Existing-report interpretation or plateau: overall line/branch coverage, blocking members, reconciled target impact, and 1–3 recommendations. Use at most one compact table.
- Explicit risk/CRAP request: top 3 actual hotspots by default, supporting complexity/coverage/CRAP values, remaining flagged count, and 1–3 priorities. Exclude fully covered low-risk methods from the hotspot table. Never exceed 10 rows unless the user requests a larger count. For refactoring safety, rank risky methods by CRAP rather than raw coverage alone, then name comparatively safe well-covered methods separately.
- Explicit full report request: read
references/output-format.md. Save the report only then.
Report only artifacts that exist. Do not announce inaccessible output paths or failed optional file writes when no file was requested.
Optional reports
HTML/CSV/markdown files are not part of normal analysis. Generate them only when the user explicitly requests report files or a CI artifact.
- Deliver the direct coverage/risk answer first.
- For a full markdown report, read
references/output-format.mdand save it. - For HTML/CSV, then read
references/report-generation.md. Do not install ReportGenerator before the direct answer, and do not retry a failed install.
Validation
- Confirm a supplied report was used without test execution or tool installation.
- Reconcile covered, valid, and uncovered line totals before projecting impact.
- Confirm every stated blocker comes from supplied or extracted evidence.
- If CRAP was requested, spot-check one score using
references/guidelines.md. - If files were requested, verify they exist before reporting their paths.
Common Pitfalls
- Existing report triggers setup work — stop. Analyze the named artifact first.
- Generic analysis triggers CRAP — stop. CRAP requires explicit risk intent.
- One method is called the entire gap — reconcile distinct uncovered lines and the full below-threshold set first.
- A small request gets a dashboard — scale down to a direct answer or one table.
- No Cobertura from collection — report the collection failure; do not invent substitute coverage.
- Compiler-generated method names — verify suspicious async, lambda, or local function names against source before presenting them as user-authored members.
- Test exit code 1 — coverage may still exist; proceed with a warning. Other nonzero build failures stop the collection path.
04 同仓库更多 Skills
writing-tunit-tests
Write tests in TUnit — the attributes, the async assertion model, data-driven cases, lifecycle hooks, and the parallelism rules. USE FOR writing or fixing a test in a TUnit project, translating a test idea into TUnit syntax, or reviewing TUnit test code for API mistakes. DO NOT USE FOR deciding what to test, judging whether a test is any good, or running tests.
dotnet-walls
Walls for a .NET change in a repository without its own quality gates — pinned, ephemeral analyzer, format, clone and scanner commands for the verify step, their identity ratchet, and the build traps. Use during a walls preflight, or when a worker's verify step needs .NET quality gates.
csharp-15
Write, review and modernize C# 15 (.NET 11) code correctly. Covers every C# 15 feature - collection expression arguments (`[with(...), ...]`), union types (`union`, `[Union]`, `IUnion`, custom unions), closed class hierarchies (`closed`), extension indexers, labeled `break`/`continue`, non-virtual static interface members on runtimes without default interface methods, and the preview memory-safety model (`unsafe(expr)`, `safe`, requires-unsafe members). Use when code targets net11.0 or LangVersion 15/preview, when the user mentions any of these features, when replacing marker interfaces, OneOf-style results, `goto`/flag loop exits or capacity/comparer boilerplate, or when the build reports CS8121, CS8509, CS8655, CS8510, CS0121/CS0411 on a `with(...)` element, CS9370, CS9380 or CS9363.
verified-waves
Run one task as verified multi-agent waves. Plans the fan-out, sends findings to fresh skeptics, keeps a ledger, and reports N of M done; small tasks stay solo.
harness
The bundled dispatch harness, which runs a task file on worker models through OpenCode or Codex, fences their writes, escalates their asks to the operator, settles each result from git and its verify commands, and records every step in a ledger. Its commands, task file, modes and write fence, configuration, runs and their recovery, ledger and exit codes.
delegating-to-worker-models
Use when you hand off implementation, a plan, research a decision will rely on, or a review, and you brief the worker and check what comes back. A subagent that searches, reads in parallel, or keeps your context small is ordinary tool use. Covers what stays with you, the mechanism, assigning work by strength, the walls preflight, prompts without contradictions, the worker contract and model profiles, evidence from your own run, review, and the fix-up loop.