Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
type/automationCreated or maintained by an agentic workflow.Created or maintained by an agentic workflow.type/tech-debtCode health, refactoring, simplification.Code health, refactoring, simplification.
Description
Assignee: @copilot
Summary
The private static helper IsReparsePoint(string path) is duplicated byte-for-byte across four IArtifactPostProcessor implementations. Each copy is ~11 lines with identical logic, catch clauses, and return values.
Duplication Details
Pattern: Reparse-point detection helper
- Severity: Medium
- Occurrences: 4 (introduced/touched most recently by commit a760075, "Consolidate reports across retry attempts (Consolidate reports across retry attempts #10542)")
- Locations:
src/Platform/Microsoft.Testing.Extensions.CtrfReport/CtrfArtifactPostProcessor.cs(lines 84-95)src/Platform/Microsoft.Testing.Extensions.HtmlReport/HtmlArtifactPostProcessor.cs(lines 128-139, approx.)src/Platform/Microsoft.Testing.Extensions.JUnitReport/JUnitArtifactPostProcessor.cs(lines 135-145)src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxArtifactPostProcessor.cs(lines 101-111, approx.)
- Code Sample:
private static bool IsReparsePoint(string path) { try { return (File.GetAttributes(path) & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint; } catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) { return true; } }
Note: TrxReportEngine.Merge.PathHelpers.cs has a related, but not identical, single-expression variant (IsReparsePoint without try/catch) used for a different ancestor-walking check — that one is a separate, lower-priority overlap and is out of scope for this issue.
Impact Analysis
- Maintainability: Any future change to reparse-point handling (e.g., additional exception types, logging, or Windows/Unix-specific tweaks) must be applied in 4 places; it's easy to update 3 and miss one.
- Bug Risk: Because the logic conservatively treats I/O errors as "is a reparse point" (fail-safe), a fix to that safety behavior in one copy could silently diverge from the others if not mirrored everywhere.
- Code Bloat: ~40 duplicated lines across the report-extension projects for a single-purpose utility.
Refactoring Recommendations
- Extract to a shared internal helper
- Since
Microsoft.Testing.Platform.Extensions.ArtifactPostProcessing(insrc/Platform/Microsoft.Testing.Platform) already defines the sharedIArtifactPostProcessor/ArtifactPostProcessingContextabstractions consumed by all four processors, add a shared internal static helper there (e.g.,ArtifactPostProcessingPathHelper.IsReparsePoint(string path)) and have each processor call it instead of maintaining its own private copy. - Estimated effort: ~1 hour (small, low-risk refactor + rebuild/test).
- Benefits: single source of truth for reparse-point detection semantics; removes ~30 duplicated lines; consistent behavior guaranteed by construction.
- Since
Implementation Checklist
- Review duplication findings
- Add shared internal helper in
Microsoft.Testing.Platform(or another already-shared internals-visible-to project) - Replace the 4 private
IsReparsePointcopies with calls to the shared helper - Update
InternalAPI.Unshipped.txtif the shared surface changes any public/internal API tracked there - Verify no functional behavior changes (existing unit/acceptance tests for the four post-processors should still pass unmodified)
Analysis Metadata
- Analyzed Files: JUnitArtifactPostProcessor.cs, CtrfArtifactPostProcessor.cs, HtmlArtifactPostProcessor.cs, TrxArtifactPostProcessor.cs, JUnitReportMerger.cs, CtrfReportMerger.RetryCollapsing.cs, TrxReportEngine.Merge.PathHelpers.cs
- Detection Method: Semantic code analysis of files touched by recent commits, cross-referenced against sibling extension projects
- Commit: c2592c9 (HEAD); duplication originates from a760075
🤖 Automated content by GitHub Copilot. Generated by the Duplicate Code Detector workflow. · auto · 45.5 AIC · ⌖ 2.2 AIC · ⊞ 12.9K · [◷]( · ◷)
Add this agentic workflow to your repo
To install this agentic workflow, run
gh aw add githubnext/agentics/workflows/duplicate-code-detector.md@main
- expires on Aug 15, 2026, 4:47 AM UTC
Metadata
Metadata
Assignees
Labels
type/automationCreated or maintained by an agentic workflow.Created or maintained by an agentic workflow.type/tech-debtCode health, refactoring, simplification.Code health, refactoring, simplification.
Activity
github-actions commentedon Aug 15, 2026
This issue was automatically closed because it expired on 2026-08-15T04:47:16.122Z.