Skip to content

feat: DOC-02 auto-fix - #204

Merged
davidnmbond merged 5 commits into
mainfrom
feat/doc-02-autofix-v2
Nov 13, 2026
Merged

davidnmbond merged 5 commits into
mainfrom
feat/doc-02-autofix-v2

Conversation

@davidnmbond

Copy link
Copy Markdown
Contributor

Adds the DOC-02 remediation: inserts the supported-versions sentence into README.md and rewrites stale plain .NET versions when exactly one is supported. Leaves Framework/Standard/Core, target-specific monikers and multi-version cases alone. Reads files strictly as UTF-8 with a byte-preserving Latin-1 fallback. 2420 offline tests pass.

…tes stale versions

Adds the sentence the rule requires to README.md after the title and badges. When exactly one modern .NET version is supported it also rewrites plain stale mentions (.NET 10, net10.0) in the files the rule names. Several supported versions, .NET Framework/Standard/Core mentions and target-specific monikers are left for a person or the AI.

Reads only the advisory data the rule already emits. Cannot merge until the DOC-02 rule itself is committed, because EveryRegisteredRuleId_IsARealRule requires a rule for every remediation.
@codacy-production

codacy-production Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 2 medium

Alerts:
⚠ 2 issues (≤ 0 issues of at least minor severity)

Results:
2 new issues

Category Results
Complexity 2 medium

View in Codacy

🟢 Metrics 96 complexity · 0 duplication

Metric Results
Complexity 96
Duplication 0

View in Codacy

🟢 Coverage 96.48% diff coverage · +0.25% coverage variation

Metric Results
Coverage variation ✅ +0.25% coverage variation (-1.00%)
Diff coverage ✅ 96.48% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (c97435f) 22793 14520 63.70%
Head commit (7b3d58b) 22938 (+145) 14670 (+150) 63.96% (+0.25%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#204) 142 137 96.48%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

⚠️ Resolve issues before merging

Three high-confidence issues should be addressed before merging: repository paths derived from advisory data are not validated for containment, project-file rewrites can affect structured MSBuild content, and version matching can rewrite historical or partial version references incorrectly. The implementation also lacks coverage for direct application without the required phrase, missing source files, and spacing after nonblank title/badge lines.

Test suggestions

  • Insert the sentence after the title and badge lines
  • Insert the sentence into a README without a title and avoid duplicate insertion
  • Preserve CRLF line endings and a UTF-8 BOM
  • Rewrite plain .NET versions in Markdown, instructions, and project descriptions
  • Leave Framework, Standard, Core, target-specific, and historical mentions unchanged
  • Avoid replacing versions when multiple supported versions exist
  • Avoid rewriting already-current documented versions
  • Preserve bytes using the Latin-1 fallback for non-UTF-8 files
  • Handle missing README.md without failure
  • Handle JSON-serialized advisory data from the row cache
  • Apply safely when the required phrase is absent, including direct Apply invocation
  • Handle a reported source file that does not exist
  • Insert after a nonblank title/badge line while preserving spacing
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Apply safely when the required phrase is absent, including direct Apply invocation
2. Handle a reported source file that does not exist
3. Insert after a nonblank title/badge line while preserving spacing

TIP How was this review? Give us feedback


foreach (var file in Strings(result, "unsupported_mentions").Select(SourceFile).Distinct(StringComparer.OrdinalIgnoreCase))
{
if (RewriteMentions(Path.Combine(localPath, file), current))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH RISK

Restrict project-file replacements to the reported documentation text, preserving MSBuild properties and conditions. Likewise, limit Markdown edits to prose and exclude links and code blocks.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.


private static (string Text, Encoding Encoding) Read(string path)
{
var bytes = File.ReadAllBytes(path);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH RISK

Validate every path derived from advisory mentions after normalization and reject rooted paths or paths that escape the repository root before reading or writing. Preserve legitimate repository subdirectories and apply the check consistently to both operations.

See Issue in Codacy
See Issue in Codacy

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

[GeneratedRegex(@"\s<[^>]+>$")]
private static partial Regex PropertySuffixRegex();

[GeneratedRegex(@"\.NET\s+(?:(?<kind>Framework|Standard|Core)\s+)?(?<version>\d+(?:\.\d+)?)(?!\.\d)")]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Require a complete version boundary so patch versions and qualified versions are not partially matched. Add regression tests for multi-digit patch versions and platform-qualified versions.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

Comment on lines +158 to +161
var updated = ProseRegex().Replace(text, match =>
match.Groups["kind"].Success || Normalise(match.Groups["version"].Value) == current
? match.Value
: ".NET " + current);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Do not automatically rewrite historical version statements; leave them for manual remediation and add a regression test covering that case.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

@davidnmbond
davidnmbond merged commit 4241718 into main Nov 13, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant