[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DYWM0QYV87S4BFXWVWK1B6":3,"skill-same:01M6DYWM0QYV87S4BFXWVWK1B6":81},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":45,"linkOnly":46,"markdownContent":47,"markdownBody":48,"frontMatter":49,"refName":51,"commitSha":52,"skillDirectory":53,"forksCount":54,"repositoryHtmlUrl":55,"repositoryHomepageUrl":56,"ownerHtmlUrl":57,"ownerBlogUrl":58,"ownerDescription":59,"updatedAt":60,"install":61,"resources":74},"01M6DYWM0QYV87S4BFXWVWK1B6","crap-score",null,"Calculates CRAP (Change Risk Anti-Patterns) for a named .NET method, class, or file. USE FOR: explicit CRAP calculation or coverage-and-complexity risk within that named target, including which tests to prioritize. DO NOT USE FOR: project-wide coverage\u002FCRAP, plateaus, or project-wide blockers\u002Fpriorities (coverage-analysis); behavioral\u002Fpseudo-mutation gaps (test-gap-analysis); writing tests; test runs without CRAP context.","managedcode\u002Fdotnet-skills","managedcode","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F78253589?v=4","01M6DYDJR3EG8KB5G4PC65XCTT","Managed Code","01M6DYDJX0ZT432N04NYJW89DN",515,"MIT","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FTesting\u002FOfficial-DotNet-Test\u002Fskills\u002Fcrap-score\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],"crap score","anti-patterns","for","which","calculation","gap","tests","mutation","project","priorities","patterns","do","complexity","behavioral","writing","use","coverage","context","prioritize","analysis","gap-analysis","risk","file","writing tests","change","test","2026-11-10 10:12:30",false,"---\nname: crap-score\ndescription: >\n  Calculates CRAP (Change Risk Anti-Patterns) for a named .NET method, class, or\n  file. USE FOR: explicit CRAP calculation or coverage-and-complexity risk\n  within that named target, including which tests to prioritize. DO NOT USE\n  FOR: project-wide coverage\u002FCRAP, plateaus, or project-wide blockers\u002Fpriorities\n  (coverage-analysis); behavioral\u002Fpseudo-mutation gaps (test-gap-analysis);\n  writing tests; test runs without CRAP context.\nlicense: MIT\n---\n\n# CRAP Score Analysis\n\nCalculate CRAP (Change Risk Anti-Patterns) scores for .NET methods to identify code that is both complex and undertested.\n\n## Background\n\nThe CRAP score combines **cyclomatic complexity** and **code coverage** into a single metric:\n\n$$\\text{CRAP}(m) = \\text{comp}(m)^2 \\times (1 - \\text{cov}(m))^3 + \\text{comp}(m)$$\n\nWhere:\n\n- $\\text{comp}(m)$ = cyclomatic complexity of method $m$\n- $\\text{cov}(m)$ = code coverage ratio (0.0 to 1.0) of method $m$\n\n| CRAP Score | Risk Level | Interpretation |\n|------------|------------|----------------|\n| \u003C 5        | Low        | Simple and well-tested |\n| 5 to \u003C 15  | Moderate   | Acceptable for most code |\n| 15 to 30   | High       | Needs more tests or simplification |\n| > 30       | Critical   | Refactor and add coverage urgently |\n\nA method with 100% coverage has CRAP = complexity (the minimum). A method with 0% coverage has CRAP = complexity^2 + complexity.\n\n## When to Use\n\n- User wants to assess which methods are risky due to low coverage and high complexity\n- User asks for CRAP score of specific methods, classes, or files\n- User wants to prioritize what to test next within a named method, class, or file based on coverage-and-complexity risk\n- User wants to evaluate test quality beyond simple coverage percentages\n\n## When Not to Use\n\n- User just wants to run tests (use `run-tests` skill)\n- User wants to write new tests (use `code-testing`)\n- User only wants a coverage percentage without complexity analysis\n- User wants project-wide coverage\u002FCRAP analysis or priorities (use `coverage-analysis`)\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Target scope | Yes | Method name, class name, or file path to analyze |\n| Test project path | No | Path to the test project. Defaults to discovering test projects in the solution. |\n| Source project path | No | Path to the source project under analysis |\n\n## Workflow\n\n### Step 1: Collect code coverage data\n\nIf the user supplies a valid Cobertura report that contains the requested\ntarget, use it directly and do not rerun tests. If the supplied report is\nmalformed, empty, internally contradictory, or missing the target, treat it as\nfailed input: regenerate it with a repository-compatible command when possible,\nor request a valid report when collection is unavailable. Otherwise invoke\n`run-tests` to classify the repository's test platform and confirm the\ncompatible command shape, then require a command that emits Cobertura:\n\n| Coverage provider | Cobertura command |\n|---|---|\n| `coverlet.collector` with VSTest | `dotnet test \u003Ctest.csproj> --collect:\"XPlat Code Coverage\" --results-directory \u003Cresults-dir>` |\n| `Microsoft.Testing.Extensions.CodeCoverage` with .NET 9 bridged MTP | `dotnet test \u003Ctest.csproj> -- --coverage --coverage-output-format cobertura --coverage-output \u003Coutput-path>` |\n| `Microsoft.Testing.Extensions.CodeCoverage` with .NET 10+ native MTP | `dotnet test --project \u003Ctest.csproj> --coverage --coverage-output-format cobertura --coverage-output \u003Coutput-path>` |\n\nUse an equivalent repository-owned command when the project defines one. Search\nthe results directory recursively when the collector creates a GUID subfolder.\nDo not substitute a generic binary `.coverage` command when no converter is\navailable.\n\nDo not stop at the first restore, compilation, test, or collector failure.\nClassify the failing layer, inspect every report the command emitted, and\nexhaust non-persistent retries before asking for input. Safe retries include\ncommand-line MSBuild properties that leave source and manifests unchanged and\nan already-installed or repository-provided alternative collector. A trivial\nsource error is a collection blocker, not the final analysis, when a reversible\ncommand-line setting can compile the same source. Never call an empty Cobertura\nfile a successful fallback.\n\nFor classic non-SDK projects (`ToolsVersion`, explicit compile items, or\n`packages.config`), use only a repository-provided coverage command that emits\nCobertura. If none exists, request Cobertura XML and stop; do not migrate the\nproject or inject an SDK-style provider. CRAP scores always require real\ncoverage data.\n\n#### Never estimate coverage\n\n**Guessed coverage produces wrong CRAP scores, which is worse than no answer.**\nFor a classic project with no repository coverage command or existing report,\nstop here and request Cobertura.\n\nDo not add coverage packages, change project manifests, or install global tools\nunless the user explicitly authorized dependency\u002Ftooling changes. If the\nrepository lacks a usable provider or converter, report that exact prerequisite\nand the compatible command shape identified through `run-tests`, then stop. If\nan existing binary `.coverage` report is present, convert it only with an\nalready-installed or repository-provided converter; otherwise request\nauthorization or a Cobertura export. If tests execute with failures but still\nemit valid coverage, continue with that data and note the failures. Report\ncomplexity on its own if useful, but never publish a CRAP number derived from\nassumed coverage.\n\nBefore using a report, verify that it parses, contains at least one class and\nmethod, and contains the requested target. An empty report or a report that\nomits the target is failed collection or filtering, not 0% coverage. Regenerate\ncoverage when possible; otherwise stop without publishing a CRAP score.\n\nIf the user supplies an existing report, state that it was not regenerated.\nDo not describe its data as current unless its provenance is established by\nrunning the repository's coverage command in this analysis.\n\n### Step 2: Compute cyclomatic complexity\n\nPrefer a machine-produced per-method complexity from a repository-provided code\nmetrics report or from the Cobertura method's `complexity` attribute when that\nreport maps to the current source. Microsoft.CodeAnalysis.Metrics can generate\nmethod-level `CyclomaticComplexity` data through `msbuild \u002Ft:Metrics`, but do\nnot add the package or modify the project without user approval.\n\nIf no machine-produced metric exists, analyze the current target source and\nlabel the result as a manual complexity count. Count the following decision\npoints (each adds 1 to the base complexity of 1):\n\n| Construct | Example |\n|-----------|---------|\n| `if` | `if (x > 0)` |\n| `else if` | `else if (y \u003C 0)` |\n| `case` (each) | `case 1:` |\n| `for` | `for (int i = 0; ...)` |\n| `foreach` | `foreach (var item in list)` |\n| `while` | `while (running)` |\n| `do...while` | `do { } while (cond)` |\n| `catch` (each) | `catch (Exception ex)` |\n| `&&` | `if (a && b)` |\n| `\\|\\|` (OR) | `if (a \\|\\| b)` |\n| `??` | `value ?? fallback` |\n| `?.` | `obj?.Method()` |\n| `? :` (ternary) | `x > 0 ? a : b` |\n| Pattern match arm | `x is > 0 and \u003C 10` |\n\nBase complexity is 1 for every method. Each decision point adds 1.\n\nWhen counting manually, read the source file, report the construct-by-construct\nbreakdown, and do not use a source comment as evidence. Count every occurrence,\nincluding operators nested inside arguments or return expressions; before\ndeclaring a conflict, rescan specifically for `&&`, `||`, `??`, `?.`, ternaries,\nand switch\u002Fpattern arms. If a supplied report maps to the current method and a\ncareful recount agrees, use its metric decisively. If a genuine disagreement\nremains, label both sources; when the user explicitly asked to use that report,\ncalculate the primary CRAP result from its machine-produced metric and present\nthe manual count as a caveat rather than withholding the requested result.\n\n### Step 3: Extract per-method coverage from Cobertura XML\n\nParse the Cobertura XML to find each method's `line-rate` attribute under the target `\u003Cclass>` element. If `line-rate` is not available at method level, compute it from the `\u003Clines>` elements:\n\n$$\\text{cov}(m) = \\frac{\\text{lines with hits} > 0}{\\text{total lines}}$$\n\nMethod names in Cobertura may differ from source (async methods, lambdas). Match by line ranges when names don't align.\n\nWhen both `line-rate` and `\u003Clines>` exist, recompute the hit ratio and compare\nthem. Allow only normal report rounding (one percentage point); if they differ\nmore, the report contradicts itself. Regenerate it or report the conflict and\nstop without calculating CRAP. Never silently choose whichever value produces\nthe expected score.\n\n### Step 4: Calculate CRAP scores\n\nFor each method in scope, apply the formula:\n\n$$\\text{CRAP}(m) = \\text{comp}(m)^2 \\times (1 - \\text{cov}(m))^3 + \\text{comp}(m)$$\n\nUse a calculator or script for the arithmetic and show the substituted\ncomplexity and coverage. Do not calculate the formula mentally. Answer a named\nmethod directly; analyze unrelated methods only when the requested scope is a\nclass or file. Once the requested result is established, do not append\nhypothetical refactor scores or coverage targets unless the user asked for\nthem. Any numeric example must also come from the calculator or script.\n\n### Step 5: Present results\n\nPresent a sorted table (highest CRAP first):\n\n```text\n| Method                          | Complexity | Coverage | CRAP Score | Risk     |\n|---------------------------------|------------|----------|------------|----------|\n| OrderService.ProcessOrder       | 10         | 45%      | 26.6       | High     |\n| OrderService.ValidateItems      | 8          | 90%      | 8.1        | Moderate |\n| OrderService.CalculateTotal     | 3          | 100%     | 3.0        | Low      |\n```\n\nInclude:\n\n- **Summary**: total methods analyzed, how many in each risk category\n- **Top offenders**: methods with CRAP > 30, with specific recommendations\n- **Quick wins**: methods with high complexity but where small coverage improvements would drop the score significantly\n\n### Step 6: Provide actionable recommendations\n\nFor high-CRAP methods, suggest one or both:\n\n1. **Add tests** -- identify uncovered branches and suggest specific test cases\n2. **Reduce complexity** -- suggest extract-method refactoring for deeply nested logic\n\nCalculate the **coverage needed** to bring a method below a CRAP threshold of 15:\n\n$$\\text{cov}_{\\text{needed}} = 1 - \\left(\\frac{15 - \\text{comp}}{\\text{comp}^2}\\right)^{1\u002F3}$$\n\nThis formula only applies when comp \u003C 15. When comp >= 15, the minimum possible CRAP score (at 100% coverage) is comp itself, which already meets or exceeds the threshold. In that case, **coverage alone cannot bring the CRAP score below the threshold** -- the method must be refactored to reduce its cyclomatic complexity first.\n\nReport this as: \"To bring `ProcessOrder` (complexity 10) below CRAP 15, increase coverage from 45% to more than 63.2% (at least 64% when reporting whole percentages).\" For methods where complexity alone exceeds the threshold, report: \"`ComplexMethod` (complexity 18) cannot reach CRAP \u003C 15 through testing alone -- reduce complexity by extracting sub-methods.\"\n\n## Validation\n\n- Verify that coverage data was collected successfully (Cobertura XML exists and contains data)\n- Confirm the target method is present; absence is not evidence of 0% coverage\n- Confirm every coverage figure came from that XML — no estimated, assumed, or source-comment-derived values\n- Cross-check method `line-rate` against its line-hit ratio when both exist\n- Cross-check that method names in coverage data match the source code\n- Confirm CRAP scores with calculator or script output\n- Ensure a 100%-covered method's CRAP equals its complexity exactly\n\n## Common Pitfalls\n\n- **Estimating coverage when collection fails**: never do it — the resulting CRAP scores are wrong in the direction that matters. Use the repository-compatible Cobertura path confirmed through `run-tests`, then report the blocker instead.\n- **Treating an empty report or missing method as 0% coverage**: this is failed collection, filtering, or method mapping; do not manufacture a score.\n- **Trusting contradictory Cobertura fields**: compare `line-rate` with the line-hit ratio and stop if they disagree beyond rounding.\n- **Trusting a stale complexity comment in the source**: compute cyclomatic complexity from the current code; a `\u002F\u002F complexity: 7` comment left by a previous author is not evidence.\n- **Mental CRAP arithmetic**: use a calculator or script and show the substituted inputs.\n- **Changing tooling to bypass a collector error**: report the failed repository-compatible command and missing prerequisite; do not install a global collector or edit manifests without explicit authorization.\n- **Stale coverage data**: regenerate when the user asks for current results or the source\u002Fbinaries changed; otherwise disclose that a supplied report was not regenerated.\n- **Method name mismatches**: Cobertura XML may use mangled\u002Fcompiler-generated names for async methods, lambdas, or local functions. Match by line ranges when names don't align.\n- **Generated code**: Exclude auto-generated files (e.g., `*.Designer.cs`, `*.g.cs`) from analysis unless explicitly requested.\n","# CRAP Score Analysis\n\nCalculate CRAP (Change Risk Anti-Patterns) scores for .NET methods to identify code that is both complex and undertested.\n\n## Background\n\nThe CRAP score combines **cyclomatic complexity** and **code coverage** into a single metric:\n\n$$\\text{CRAP}(m) = \\text{comp}(m)^2 \\times (1 - \\text{cov}(m))^3 + \\text{comp}(m)$$\n\nWhere:\n\n- $\\text{comp}(m)$ = cyclomatic complexity of method $m$\n- $\\text{cov}(m)$ = code coverage ratio (0.0 to 1.0) of method $m$\n\n| CRAP Score | Risk Level | Interpretation |\n|------------|------------|----------------|\n| \u003C 5        | Low        | Simple and well-tested |\n| 5 to \u003C 15  | Moderate   | Acceptable for most code |\n| 15 to 30   | High       | Needs more tests or simplification |\n| > 30       | Critical   | Refactor and add coverage urgently |\n\nA method with 100% coverage has CRAP = complexity (the minimum). A method with 0% coverage has CRAP = complexity^2 + complexity.\n\n## When to Use\n\n- User wants to assess which methods are risky due to low coverage and high complexity\n- User asks for CRAP score of specific methods, classes, or files\n- User wants to prioritize what to test next within a named method, class, or file based on coverage-and-complexity risk\n- User wants to evaluate test quality beyond simple coverage percentages\n\n## When Not to Use\n\n- User just wants to run tests (use `run-tests` skill)\n- User wants to write new tests (use `code-testing`)\n- User only wants a coverage percentage without complexity analysis\n- User wants project-wide coverage\u002FCRAP analysis or priorities (use `coverage-analysis`)\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Target scope | Yes | Method name, class name, or file path to analyze |\n| Test project path | No | Path to the test project. Defaults to discovering test projects in the solution. |\n| Source project path | No | Path to the source project under analysis |\n\n## Workflow\n\n### Step 1: Collect code coverage data\n\nIf the user supplies a valid Cobertura report that contains the requested\ntarget, use it directly and do not rerun tests. If the supplied report is\nmalformed, empty, internally contradictory, or missing the target, treat it as\nfailed input: regenerate it with a repository-compatible command when possible,\nor request a valid report when collection is unavailable. Otherwise invoke\n`run-tests` to classify the repository's test platform and confirm the\ncompatible command shape, then require a command that emits Cobertura:\n\n| Coverage provider | Cobertura command |\n|---|---|\n| `coverlet.collector` with VSTest | `dotnet test \u003Ctest.csproj> --collect:\"XPlat Code Coverage\" --results-directory \u003Cresults-dir>` |\n| `Microsoft.Testing.Extensions.CodeCoverage` with .NET 9 bridged MTP | `dotnet test \u003Ctest.csproj> -- --coverage --coverage-output-format cobertura --coverage-output \u003Coutput-path>` |\n| `Microsoft.Testing.Extensions.CodeCoverage` with .NET 10+ native MTP | `dotnet test --project \u003Ctest.csproj> --coverage --coverage-output-format cobertura --coverage-output \u003Coutput-path>` |\n\nUse an equivalent repository-owned command when the project defines one. Search\nthe results directory recursively when the collector creates a GUID subfolder.\nDo not substitute a generic binary `.coverage` command when no converter is\navailable.\n\nDo not stop at the first restore, compilation, test, or collector failure.\nClassify the failing layer, inspect every report the command emitted, and\nexhaust non-persistent retries before asking for input. Safe retries include\ncommand-line MSBuild properties that leave source and manifests unchanged and\nan already-installed or repository-provided alternative collector. A trivial\nsource error is a collection blocker, not the final analysis, when a reversible\ncommand-line setting can compile the same source. Never call an empty Cobertura\nfile a successful fallback.\n\nFor classic non-SDK projects (`ToolsVersion`, explicit compile items, or\n`packages.config`), use only a repository-provided coverage command that emits\nCobertura. If none exists, request Cobertura XML and stop; do not migrate the\nproject or inject an SDK-style provider. CRAP scores always require real\ncoverage data.\n\n#### Never estimate coverage\n\n**Guessed coverage produces wrong CRAP scores, which is worse than no answer.**\nFor a classic project with no repository coverage command or existing report,\nstop here and request Cobertura.\n\nDo not add coverage packages, change project manifests, or install global tools\nunless the user explicitly authorized dependency\u002Ftooling changes. If the\nrepository lacks a usable provider or converter, report that exact prerequisite\nand the compatible command shape identified through `run-tests`, then stop. If\nan existing binary `.coverage` report is present, convert it only with an\nalready-installed or repository-provided converter; otherwise request\nauthorization or a Cobertura export. If tests execute with failures but still\nemit valid coverage, continue with that data and note the failures. Report\ncomplexity on its own if useful, but never publish a CRAP number derived from\nassumed coverage.\n\nBefore using a report, verify that it parses, contains at least one class and\nmethod, and contains the requested target. An empty report or a report that\nomits the target is failed collection or filtering, not 0% coverage. Regenerate\ncoverage when possible; otherwise stop without publishing a CRAP score.\n\nIf the user supplies an existing report, state that it was not regenerated.\nDo not describe its data as current unless its provenance is established by\nrunning the repository's coverage command in this analysis.\n\n### Step 2: Compute cyclomatic complexity\n\nPrefer a machine-produced per-method complexity from a repository-provided code\nmetrics report or from the Cobertura method's `complexity` attribute when that\nreport maps to the current source. Microsoft.CodeAnalysis.Metrics can generate\nmethod-level `CyclomaticComplexity` data through `msbuild \u002Ft:Metrics`, but do\nnot add the package or modify the project without user approval.\n\nIf no machine-produced metric exists, analyze the current target source and\nlabel the result as a manual complexity count. Count the following decision\npoints (each adds 1 to the base complexity of 1):\n\n| Construct | Example |\n|-----------|---------|\n| `if` | `if (x > 0)` |\n| `else if` | `else if (y \u003C 0)` |\n| `case` (each) | `case 1:` |\n| `for` | `for (int i = 0; ...)` |\n| `foreach` | `foreach (var item in list)` |\n| `while` | `while (running)` |\n| `do...while` | `do { } while (cond)` |\n| `catch` (each) | `catch (Exception ex)` |\n| `&&` | `if (a && b)` |\n| `\\|\\|` (OR) | `if (a \\|\\| b)` |\n| `??` | `value ?? fallback` |\n| `?.` | `obj?.Method()` |\n| `? :` (ternary) | `x > 0 ? a : b` |\n| Pattern match arm | `x is > 0 and \u003C 10` |\n\nBase complexity is 1 for every method. Each decision point adds 1.\n\nWhen counting manually, read the source file, report the construct-by-construct\nbreakdown, and do not use a source comment as evidence. Count every occurrence,\nincluding operators nested inside arguments or return expressions; before\ndeclaring a conflict, rescan specifically for `&&`, `||`, `??`, `?.`, ternaries,\nand switch\u002Fpattern arms. If a supplied report maps to the current method and a\ncareful recount agrees, use its metric decisively. If a genuine disagreement\nremains, label both sources; when the user explicitly asked to use that report,\ncalculate the primary CRAP result from its machine-produced metric and present\nthe manual count as a caveat rather than withholding the requested result.\n\n### Step 3: Extract per-method coverage from Cobertura XML\n\nParse the Cobertura XML to find each method's `line-rate` attribute under the target `\u003Cclass>` element. If `line-rate` is not available at method level, compute it from the `\u003Clines>` elements:\n\n$$\\text{cov}(m) = \\frac{\\text{lines with hits} > 0}{\\text{total lines}}$$\n\nMethod names in Cobertura may differ from source (async methods, lambdas). Match by line ranges when names don't align.\n\nWhen both `line-rate` and `\u003Clines>` exist, recompute the hit ratio and compare\nthem. Allow only normal report rounding (one percentage point); if they differ\nmore, the report contradicts itself. Regenerate it or report the conflict and\nstop without calculating CRAP. Never silently choose whichever value produces\nthe expected score.\n\n### Step 4: Calculate CRAP scores\n\nFor each method in scope, apply the formula:\n\n$$\\text{CRAP}(m) = \\text{comp}(m)^2 \\times (1 - \\text{cov}(m))^3 + \\text{comp}(m)$$\n\nUse a calculator or script for the arithmetic and show the substituted\ncomplexity and coverage. Do not calculate the formula mentally. Answer a named\nmethod directly; analyze unrelated methods only when the requested scope is a\nclass or file. Once the requested result is established, do not append\nhypothetical refactor scores or coverage targets unless the user asked for\nthem. Any numeric example must also come from the calculator or script.\n\n### Step 5: Present results\n\nPresent a sorted table (highest CRAP first):\n\n```text\n| Method                          | Complexity | Coverage | CRAP Score | Risk     |\n|---------------------------------|------------|----------|------------|----------|\n| OrderService.ProcessOrder       | 10         | 45%      | 26.6       | High     |\n| OrderService.ValidateItems      | 8          | 90%      | 8.1        | Moderate |\n| OrderService.CalculateTotal     | 3          | 100%     | 3.0        | Low      |\n```\n\nInclude:\n\n- **Summary**: total methods analyzed, how many in each risk category\n- **Top offenders**: methods with CRAP > 30, with specific recommendations\n- **Quick wins**: methods with high complexity but where small coverage improvements would drop the score significantly\n\n### Step 6: Provide actionable recommendations\n\nFor high-CRAP methods, suggest one or both:\n\n1. **Add tests** -- identify uncovered branches and suggest specific test cases\n2. **Reduce complexity** -- suggest extract-method refactoring for deeply nested logic\n\nCalculate the **coverage needed** to bring a method below a CRAP threshold of 15:\n\n$$\\text{cov}_{\\text{needed}} = 1 - \\left(\\frac{15 - \\text{comp}}{\\text{comp}^2}\\right)^{1\u002F3}$$\n\nThis formula only applies when comp \u003C 15. When comp >= 15, the minimum possible CRAP score (at 100% coverage) is comp itself, which already meets or exceeds the threshold. In that case, **coverage alone cannot bring the CRAP score below the threshold** -- the method must be refactored to reduce its cyclomatic complexity first.\n\nReport this as: \"To bring `ProcessOrder` (complexity 10) below CRAP 15, increase coverage from 45% to more than 63.2% (at least 64% when reporting whole percentages).\" For methods where complexity alone exceeds the threshold, report: \"`ComplexMethod` (complexity 18) cannot reach CRAP \u003C 15 through testing alone -- reduce complexity by extracting sub-methods.\"\n\n## Validation\n\n- Verify that coverage data was collected successfully (Cobertura XML exists and contains data)\n- Confirm the target method is present; absence is not evidence of 0% coverage\n- Confirm every coverage figure came from that XML — no estimated, assumed, or source-comment-derived values\n- Cross-check method `line-rate` against its line-hit ratio when both exist\n- Cross-check that method names in coverage data match the source code\n- Confirm CRAP scores with calculator or script output\n- Ensure a 100%-covered method's CRAP equals its complexity exactly\n\n## Common Pitfalls\n\n- **Estimating coverage when collection fails**: never do it — the resulting CRAP scores are wrong in the direction that matters. Use the repository-compatible Cobertura path confirmed through `run-tests`, then report the blocker instead.\n- **Treating an empty report or missing method as 0% coverage**: this is failed collection, filtering, or method mapping; do not manufacture a score.\n- **Trusting contradictory Cobertura fields**: compare `line-rate` with the line-hit ratio and stop if they disagree beyond rounding.\n- **Trusting a stale complexity comment in the source**: compute cyclomatic complexity from the current code; a `\u002F\u002F complexity: 7` comment left by a previous author is not evidence.\n- **Mental CRAP arithmetic**: use a calculator or script and show the substituted inputs.\n- **Changing tooling to bypass a collector error**: report the failed repository-compatible command and missing prerequisite; do not install a global collector or edit manifests without explicit authorization.\n- **Stale coverage data**: regenerate when the user asks for current results or the source\u002Fbinaries changed; otherwise disclose that a supplied report was not regenerated.\n- **Method name mismatches**: Cobertura XML may use mangled\u002Fcompiler-generated names for async methods, lambdas, or local functions. Match by line ranges when names don't align.\n- **Generated code**: Exclude auto-generated files (e.g., `*.Designer.cs`, `*.g.cs`) from analysis unless explicitly requested.\n",{"name":5,"license":15,"description":50},"Calculates CRAP (Change Risk Anti-Patterns) for a named .NET method, class, or file. USE FOR: explicit CRAP calculation or coverage-and-complexity risk within that named target, including which tests to prioritize. DO NOT USE FOR: project-wide coverage\u002FCRAP, plateaus, or project-wide blockers\u002Fpriorities (coverage-analysis); behavioral\u002Fpseudo-mutation gaps (test-gap-analysis); writing tests; test runs without CRAP context.\n","main","497cc9aba79a931ac6fb8d36a48cc22fe3d6d74b","catalog\u002FTesting\u002FOfficial-DotNet-Test\u002Fskills\u002Fcrap-score",41,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills","https:\u002F\u002Fskills.managed-code.com","https:\u002F\u002Fgithub.com\u002Fmanagedcode","https:\u002F\u002Fwww.managed-code.com","Open Source Community for .NET Developers: Reliable, Actively Maintained, and Community-Driven. Made in Ukraine 🇺🇦 with ❤️","2026-11-14 19:05:44",{"source":8,"skillName":5,"commands":62,"prompt":72,"zipAvailable":73},[63,66,69],{"tool":64,"command":65},"npx","npx skills add managedcode\u002Fdotnet-skills --skill crap-score",{"tool":67,"command":68},"bunx","bunx skills add managedcode\u002Fdotnet-skills --skill crap-score",{"tool":70,"command":71},"pnpm","pnpm dlx skills add managedcode\u002Fdotnet-skills --skill crap-score","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FTesting\u002FOfficial-DotNet-Test\u002Fskills\u002Fcrap-score\u002FSKILL.md",true,[75],{"path":76,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":79,"sourceHtmlUrl":80},"manifest.json","REFERENCE","参考文档",114,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FTesting\u002FOfficial-DotNet-Test\u002Fskills\u002Fcrap-score\u002Fmanifest.json",[82,119,140,170,180,207],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":98,"publishedAt":45},"01M6DYQE1Y9FHAQHEDTVFQ3447","xtwitter-scraper","Use XTwitterScraper when a .NET application needs typed access to Xquik's X automation REST API for tweet search, user lookup, posting workflows, extraction jobs, monitors, webhooks, or giveaway draws. USE FOR: integrating the XTwitterScraper NuGet package; reviewing Xquik API client usage; modeling API-key configuration, pagination, binary exports, raw responses, retries, and webhook\u002Fevent flows in .NET. DO NOT USE FOR: unrelated stacks; direct browser automation; generic social-media strategy; or code that does not call Xquik. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FXTwitterScraper\u002Fskills\u002Fxtwitter-scraper\u002FSKILL.md",[88,93],{"categoryNo":89,"categoryName":90,"taxonomyType":91,"taxonomyTypeDesc":92},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":94,"categoryName":95,"taxonomyType":96,"taxonomyTypeDesc":97},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118],"xtwitter scraper","browser automation","workflows","run","code","browser","search","repository","api","Media","api client","access","edit","unrelated","webhooks","files","social","commands","modeling","webhook",{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":131,"publishedAt":45},"01M6DYQ9S4PE1H6G8MCH9T21HR","sep","Use Sep for high-performance separated-value parsing and writing in .NET, including delimiter inference, explicit parser\u002Fwriter options, and low-allocation row\u002Fcolumn workflows. USE FOR: delimited data needs are performance-sensitive and allocation-aware; project needs explicit control over separator inference, escaping, trimming, and header behavior;. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FSep\u002Fskills\u002Fsep\u002FSKILL.md",[125,128],{"categoryNo":126,"categoryName":127,"taxonomyType":91,"taxonomyTypeDesc":92},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":129,"categoryName":130,"taxonomyType":96,"taxonomyTypeDesc":97},"01JBSEEDCAT000000000000036","内容创作者",[121,33,132,101,133,102,106,134,135,136,111,36,112,114,30,137,138,27,116,139],"performance","tasks","data","parsing","parser","writer","options","high-performance",{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":45},"01M6DZS2DNEPXCGGF6SSCW6G5V","webgpu-threejs-tsl","Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fwebgpu-claude-skill\u002Fskills\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[147,148,149,150,151,152,153,154,155,156,157,158,34,159,160,161,162,163,164,165,21,166,167,168,169],"webgpu","threejs","webgpu threejs tsl","setup","shaders","gpu","integration","applications","js","node","syntax","guide","language","three","compute","post","processing","with","renderer","materials","wgsl","effects","when",{"skillNo":171,"name":172,"nameZh":6,"description":173,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":174,"categories":175,"keywords":176,"publishedAt":45},"01M6DZS0BQXW2B56A289XF1X76","roslynk","Use Roslynk for semantic inspection and edits of *.cs, *.razor and *.cshtml solution files.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Froslynk\u002Fskills\u002Froslynk\u002FSKILL.md",[],[172,34,114,177,178,21,179],"semantic","razor","inspection",{"skillNo":181,"name":182,"nameZh":6,"description":183,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":184,"categories":185,"keywords":186,"publishedAt":45},"01M6DZRW6MEJCVW80K3S4XV60K","system-text-json-net11","Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in `JsonNamingPolicy.PascalCase` naming policy, and the strongly-typed generic `JsonSerializerOptions.GetTypeInfo` and `JsonSerializerOptions.TryGetTypeInfo` metadata accessors (generic overloads that return a typed `JsonTypeInfo`). USE ONLY when the user is targeting net11.0 or later and needs PascalCase JSON property or dictionary-key names without writing a custom naming policy, a strongly-typed generic `JsonTypeInfo` instead of the non-generic `JsonTypeInfo`, or a no-throw way to probe whether a type's serialization metadata is resolved. DO NOT USE when the target is earlier than net11.0, the requested behavior uses an established pre-net11 naming policy, or the user explicitly selected another JSON library.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fdotnet-skills\u002Fplugins\u002Fdotnet11\u002Fskills\u002Fsystem-text-json-net11\u002FSKILL.md",[],[187,188,189,190,33,191,192,193,194,195,196,34,197,198,199,200,30,201,202,203,204,21,205,206,169],"system","json","text","system text json net11","policy","metadata","library","serialization","behavior","user","only","probe","guidance","later","type","dictionary","naming","targeting","custom","generic",{"skillNo":208,"name":209,"nameZh":6,"description":210,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":211,"categories":212,"keywords":215,"publishedAt":45},"01M6DZRRJP3S662NFSG1RSPQQ7","process-api-net11","Provides guidance on the new System.Diagnostics.Process APIs introduced in .NET 11: Process.Run, Process.RunAndCaptureText, Process.StartAndForget, Process.ReadAllText\u002FBytes\u002FLines, KillOnParentExit, InheritedHandles, and StartDetached. USE FOR: starting, orchestrating, or capturing output from external processes in applications targeting net11.0 or later. DO NOT USE FOR: applications targeting .NET 10 or earlier, or basic pre-.NET 11 Process.Start usage without new APIs.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fdotnet-skills\u002Fplugins\u002Fdotnet11\u002Fskills\u002Fprocess-api-net11\u002FSKILL.md",[213,214],{"categoryNo":89,"categoryName":90,"taxonomyType":91,"taxonomyTypeDesc":92},{"categoryNo":94,"categoryName":95,"taxonomyType":96,"taxonomyTypeDesc":97},[107,216,217,218,102,219,154,187,34,199,200,30,220,221,222,223,204,21,224],"process","process api net11","diagnostics","start","basic","processes","output","usage","new"]