Repository navigation
v1.5.0
What's Changed
This release completes Phase 11 — Project-level Tooling, expanding ComplexityAnalysis.Analyzers beyond compiler-time diagnostics with a dedicated project-level analysis surface.
The new ComplexityAnalysis.Tool CLI can analyze complete C# projects and solutions, produce deterministic aggregate reports, apply explicit CI quality gates, and detect normalized duplicate code across files — all while keeping project-wide work completely outside Roslyn analyzer hot paths.
This release also updates the project's test and analysis infrastructure dependencies.
Phase 11 — Project-level Tooling
Project-level complexity CLI
The repository now includes a dedicated ComplexityAnalysis.Tool project for whole-project analysis.
The CLI supports:
.csprojprojects;.slnsolutions;.slnxsolutions;- deterministic console reporting;
- machine-readable JSON reporting;
- opt-in quality gates;
- cooperative cancellation;
- generated-code exclusion;
- build-output exclusion;
- normalized duplicate-code detection.
The CLI is intentionally architecturally separated from the packaged Roslyn analyzer.
No filesystem scanning, project traversal, duplicate detection, or other whole-project operations have been introduced into DiagnosticAnalyzer.Initialize or analyzer callbacks.
Consumer applications using ComplexityAnalysis.Analyzers therefore remain independent from the CLI and its project-level responsibilities.
Aggregate complexity reports
Project-level reports aggregate complexity information across projects, files, and executable members.
Reports can include:
- Big-O Complexity;
- Cyclomatic Complexity;
- Maximum Control-Flow Nesting Depth;
- NLOC;
- Statement Count;
- Token Count;
- Parameter Count;
- Cognitive Complexity;
- Halstead Metrics;
- source identity and location;
- duplicate-code summaries and clone groups;
- quality-gate results.
Metrics that cannot be determined safely remain explicitly represented as unavailable or Unknown rather than being coerced into artificial values.
This preserves the conservative analysis philosophy established by previous releases.
Deterministic console and JSON output
Two report formats are available.
Console
The console report provides a human-readable representation suitable for local development and CI logs.
Projects, files, members, and duplicate groups are ordered deterministically so equivalent inputs produce stable output.
JSON
The JSON report exposes machine-readable project, file, member, location, metric, quality-gate, and duplicate information.
It is designed to support CI pipelines and future integrations without coupling consumers to analyzer internals.
The reporting architecture also introduces a format-independent writer boundary that can support additional exporters, such as SARIF, in future releases.
SARIF itself is intentionally not implemented in this release.
CI quality gates
Project-level quality gates are now supported.
All gates are explicitly opt-in.
The CLI does not introduce arbitrary default thresholds that could unexpectedly break existing builds.
Documented exit codes are:
0— analysis completed successfully;1— execution or configuration error;2— an explicitly configured quality gate was exceeded;130— operation cancelled.
Quality gates can evaluate project-level metric thresholds and duplicate-code limits while keeping policy separate from metric calculation.
Generated code and build-output exclusions
Whole-project analysis excludes generated and build-generated content by default.
Common exclusions include directories such as:
bin;obj;artifacts;TestResults;packages;- other known tooling/build output locations.
Generated-code and build-output behavior can be overridden explicitly when required.
This prevents project reports from being polluted by files that are not part of the authored source being evaluated.
Cross-file duplicate-code detection
Phase 11 also introduces normalized C# duplicate-code detection.
Duplicate detection runs exclusively in the project-level tooling layer and supports:
- duplicates within the same file;
- duplicates across different files;
- configurable minimum clone size;
- token-based thresholds;
- logical-line thresholds;
- deterministic clone grouping;
- precise source ranges;
- duplicate token counts;
- occurrence counts;
- project/file duplication information;
- optional duplicate-code quality gates.
Small fragments below the configured thresholds are ignored to reduce noise.
C#-aware normalization
Duplicate detection uses Roslyn tokenization and C#-specific normalization rather than plain textual comparison.
The normalization model understands constructs including:
- parameters;
- local variables;
- member, type, and namespace identifiers by role;
- numeric literals;
- string literals;
- character literals;
- interpolated strings;
- pattern variables;
- generic type arguments;
- member access;
- modern C# syntax supported by the configured parser.
Harmless renaming or literal substitutions can therefore be recognized as structurally equivalent where appropriate.
At the same time, material differences remain preserved.
Unary and binary operators, control-flow structure, and other behaviorally meaningful syntax are not collapsed into generic tokens merely to increase clone matches.
This reduces false positives between implementations that may look superficially similar but express different behavior.
Bounded duplicate-detection algorithm
Duplicate detection deliberately avoids naive all-pairs substring comparison.
The implementation uses token-window indexing with rolling/fingerprint-style hashing to identify candidate regions efficiently.
Candidate hashes are only used to narrow the search space.
A matching hash is never considered proof of duplication.
Every candidate is verified using the actual normalized token sequence before a clone is reported, preventing hash collisions from directly producing false-positive findings.
The expected behavior is approximately linear with the number of normalized token windows, plus verification of candidate buckets, with memory proportional to the indexed windows.
This keeps project-level duplicate detection suitable for real repositories while avoiding pathological unbounded comparison strategies.
Deterministic overlap suppression
Duplicate-code analysis also performs deterministic de-noising.
Overlapping or fully contained clone ranges are suppressed using stable rules that prioritize longer matches and deterministic source ordering.
This avoids overwhelming reports with multiple representations of effectively the same duplicate region.
Equivalent source inputs therefore produce equivalent clone groups regardless of filesystem enumeration order.
Architecture
The new project-level functionality preserves the separation between compiler analysis and repository analysis.
The dependency direction remains explicit:
ComplexityAnalysis.Tool → shared analyzer/metric infrastructure
The Roslyn analyzer does not depend on the CLI.
The project-level loader uses Roslyn syntax and compilation APIs directly without introducing Microsoft.CodeAnalysis.Workspaces.
No network calls, telemetry, databases, external clone-detection services, or runtime services are required.
This architecture allows project-wide analysis to evolve without compromising the bounded execution requirements of IDE and compiler analyzer hosts.
Documentation
Project-level tooling is documented in both English and Brazilian Portuguese.
The documentation now covers:
- CLI usage;
.csproj,.sln, and.slnxinputs;- console reports;
- JSON reports;
- aggregate metric semantics;
- quality gates;
- exit codes;
- generated/build-output exclusions;
- duplicate detection;
- C# normalization rules;
- clone thresholds;
- architecture and dependency boundaries;
- performance characteristics.
The Phase 11 behavior is also formally described in a dedicated specification, following the project's Specification-Driven Development approach.
Validation
The Phase 11 implementation was validated against the existing engineering baseline.
Validation included:
- Release restore and build;
- 1,088 automated tests passing;
- project-tool integration tests;
- analyzer characterization tests;
- package contract tests;
- consumer contract tests;
- performance synthetic-corpus tests;
- analyzer performance-budget tests;
- Roslyn host-compatibility tests;
- deterministic console and JSON reporting;
- duplicate detection against representative multi-file fixtures;
- quality-gate behavior;
- cancellation;
- generated/build-output exclusions;
- local NuGet packaging;
- manual CLI execution with JSON, duplicate detection, and duplicate quality gates.
The Release build completed with no new build warnings or errors.
Existing analyzer diagnostic behavior, package contracts, performance characteristics, diagnostic IDs, severity defaults, and configuration semantics remain unchanged.
Dependency updates
This release also includes maintenance updates to the development infrastructure:
dotnet-sonarscannerupdated from11.2.1to11.3.0;Microsoft.NET.Test.Sdkupdated from18.9.0to18.10.0.
These updates affect the repository's analysis/test infrastructure and do not change the public analyzer behavior.
Why this release matters
Previous releases progressively established a set of deterministic and independently explainable C# complexity measurements.
With v1.5.0, those measurements are no longer limited to compiler-time diagnostics.
ComplexityAnalysis.Analyzers now has a distinct project-level analysis layer capable of aggregating metrics across an entire codebase, producing CI-consumable reports, enforcing explicitly configured quality policies, and identifying structurally duplicated C# code across files.
Just as importantly, these capabilities remain outside the Roslyn analyzer hot path.
The result is a cleaner architectural separation between two different responsibilities:
compiler-time feedback for fast, bounded diagnostics and project-level analysis for repository-wide reporting and quality governance.
This release completes Phase 11 — Project-level Tooling of the project's capability-expansion roadmap.
What's Changed
-
feat: implement Phase 11 project-level tooling — #65
-
deps: update
dotnet-sonarscannerfrom11.2.1to11.3.0— #63 -
deps: update
Microsoft.NET.Test.Sdkfrom18.9.0to18.10.0— #64
See the canonical execution roadmap in #36 — Execution order for analyzer hardening and capability expansion.
Full Changelog: v1.4.0...v1.5.0
Full Changelog: v1.4.0...v1.5.0