CodeMetrics.AI
1.0.1
dotnet tool install --global CodeMetrics.AI --version 1.0.1
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
dotnet tool install --local CodeMetrics.AI --version 1.0.1
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=CodeMetrics.AI&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package CodeMetrics.AI --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CodeMetrics.AI
A .NET 10 global tool that performs deterministic static analysis on .NET solutions using the Roslyn compiler API. Produces VS-compatible code metrics and scored scorecard evidence across 9 quality dimensions.
Install
dotnet tool install -g CodeMetrics.AI
Usage
# Auto-discover solution in current directory
code-metrics
# Specify solution explicitly
code-metrics --solution MyApp.slnx
# Skip dependency probe (avoids dotnet list package calls)
code-metrics --skip-dependency-probe
# Custom output paths
code-metrics --output ./results/metrics.csv --scorecard-output ./results/evidence.json
Output
| File | Description |
|---|---|
.scorecard/metrics.csv |
VS-compatible raw metrics (same format as Visual Studio's Code Metrics Results) |
.scorecard/evidence.json |
Scored evidence across 9 dimensions (schema v1) |
Dimensions
The tool scores your codebase across 9 quality dimensions (0-10 scale):
| Dimension | Method |
|---|---|
| Code Quality | Statistical — decomposition ratio and max member cyclomatic complexity |
| Maintainability | Statistical — maintainability index population/tail/extreme analysis |
| Error Handling | Rule-based — empty catches, throw ex, broad catches, sync blocking |
| Performance & Async | Rule-based — sync-over-async, Thread.Sleep, SaveChanges in loops |
| Security | Rule-based — hardcoded secrets, SQL interpolation, unsafe deserialization |
| Testing | Rule-based — test coverage, assertion density, placeholder detection |
| Documentation | Deduction-based — README, docs/, XML docs, public API coverage |
| Dependency Management | Rule-based — vulnerabilities, outdated, deprecated, version drift |
| Architecture & SOLID | Rule-based — project cycles, layering violations, metric hotspots |
Raw Metrics
Per-type and per-member metrics collected via Roslyn:
- Cyclomatic Complexity — decision point counting
- Lines of Code — source lines (excluding comments/blanks/braces) and executable statements
- Maintainability Index — composite of CC, LOC, and Halstead Volume
- Class Coupling — distinct external type dependencies
- Depth of Inheritance — base type chain length
MSBuild Integration
Copy Directory.Build.targets from the scorecard-tooling directory to your solution root:
dotnet build /t:Scorecard
dotnet build /t:Scorecard /p:ScorecardConfiguration=Release
Options
| Option | Default | Description |
|---|---|---|
--solution |
Auto-discover | Path to .sln or .slnx file |
--output |
.scorecard/metrics.csv |
CSV output path |
--scorecard-output |
.scorecard/evidence.json |
JSON evidence output path |
--configuration |
Debug |
Build configuration |
--skip-dependency-probe |
false |
Skip dependency management checks |
Project Filtering
The tool automatically skips non-production projects:
- Test projects (name contains "Tests")
- Aspire hosts (AppHost, ServiceDefaults, Hosting)
- Benchmarks, Samples, Demo, Playground projects
Requirements
- .NET 10 SDK
- Solution must be buildable (
dotnet buildsucceeds)
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.