Repository navigation
feat: DOC-02 auto-fix - #204
Conversation
…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.
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Complexity | 2 medium |
🟢 Metrics 96 complexity · 0 duplication
Metric Results Complexity 96 Duplication 0
🟢 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 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.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
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)) |
There was a problem hiding this comment.
🔴 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); |
There was a problem hiding this comment.
🔴 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)")] |
There was a problem hiding this comment.
🟡 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.
| var updated = ProseRegex().Replace(text, match => | ||
| match.Groups["kind"].Success || Normalise(match.Groups["version"].Value) == current | ||
| ? match.Value | ||
| : ".NET " + current); |
There was a problem hiding this comment.
🟡 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.
…se and non-historical lines
… version boundary, history in descriptions
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.