Refactor files under 400-line limit#54
Conversation
Code Review — PR #54: Refactor files under 400-line limitOverviewThis PR enforces a 400-line file-length ceiling across the codebase by splitting large classes into partial-class files organized by responsibility. It also extracts the PowerShell Core assembly resolver from an inline here-string in Bugs
But the actual hook lives at Fix: "command": "\"${CLAUDE_PROJECT_DIR:-.}\"/.codex/hooks/stop-file-length.sh"Potential Issues
public static void Register(string libPath)
{
if (_registered) return; // (A) two threads can both pass here
_libPath = libPath;
AssemblyLoadContext.Default.Resolving += OnResolving;
...
_registered = true; // (B) set too late for the racing thread
}Two concurrent calls (e.g. parallel PowerShell runspaces) can both read private static int _registered = 0;
public static void Register(string libPath)
{
if (Interlocked.CompareExchange(ref _registered, 1, 0) != 0) return;
_libPath = libPath;
AssemblyLoadContext.Default.Resolving += OnResolving;
AssemblyLoadContext.Default.ResolvingUnmanagedDll += OnResolvingUnmanagedDll;
}
The file lives at the repo root rather than under Style ConcernsString interpolation in newly-added test files
Examples from the newly added files: sb.AppendLine($"{i},Name{i},{i * 10}"); // ThreadSafety.cs:25
$"Column{i}" // CsvReaderBenchmarks.Benchmarks.cs:93The test project does not set an explicit Unexplained Deletion
The file is fully deleted with no explanation in the PR description or commit messages. If this workflow became redundant due to the resolver refactor, that reasoning should be stated. If it is being temporarily disabled, a comment should say so. What's Done Well
Summary
|
Code Review: PR #54 — Refactor files under 400-line limitOverviewThis PR applies a systematic refactoring across the library: large monolithic C# files (some were >4000 lines) are split into focused partial-class files using the What's done wellStructural refactoring:
Test coverage:
Hook:
Issues and suggestions1. The If the intent is dual-use (Claude Code + OpenAI Codex CLI), the formats differ between the two systems and this needs separate configs. 2. Hook only catches tracked/staged files — misses brand-new unstaged files
3. Thread-safety test uses In 4. Empty XML doc summaries on Several constructors have 5. Minor: double blank lines in Lines around 130-131, 145-146, and 191-193 have double blank lines between member groups. Single blank lines are the C# convention. 6. Both are listed as legacy exemptions in CLAUDE.md so this is expected — flagging for completeness since neither was migrated to Specific nits
SummaryThis is a well-executed mechanical refactor. The |
Follow-up Review — PR #54 (after fix commits)This reviews the two fix commits pushed after the earlier reviews: "fix: address refactor review feedback" and "fix: compile core redirector in module loader". Issues Resolved ✅
Remaining Issue — Hook Won't Run in Claude Code
If the intent is for Claude Code to enforce the 400-line limit, the entry needs to be in {
\"hooks\": {
\"Stop\": [{
\"hooks\": [{
\"type\": \"command\",
\"command\": \"\\\"${CLAUDE_PROJECT_DIR:-.}\\\"/.codex/hooks/stop-file-length.sh\",
\"timeout\": 15,
\"statusMessage\": \"Checking file lengths (400-line limit)...\"
}]
}]
}
}If the Minor: Workflow path filter gap
paths:
- 'dbatools.library.psm1'
- 'dbatools.library.CoreRedirector.cs' # ← add this
- 'dbatools.library.psd1'
- 'tests/test-avoidconflicts.ps1'
- '.github/workflows/test-avoidconflicts.yml'Everything Else Looks GoodThe partial-class refactoring is mechanically correct throughout. The |
Code Review: Refactor files under 400-line limitOverviewThis PR mechanically splits large C# source files (some originally 4000+ lines) into partial-class files to stay under a new 400-line limit, extracts the PowerShell Core assembly resolver into a standalone Critical Issue: Hook is Missing for Claude CodeThe hook that enforces the 400-line limit is deployed under
The hook itself is well-written (uses Additional hook note: The Partial Class Splits — Generally Good
The Files Approaching the Limit (no action needed, just awareness)Several files land in the 360–387 line range — these are under the limit but have no headroom:
Specific Code Issues
CoreRedirector.cs — Substantive Change, Looks CorrectExtracting the PowerShell Core assembly resolver from an inline here-string in
Minor inconsistency: The older No unit tests for CoreRedirector.cs: The new class is only tested indirectly via the stress test script. The C# Language Version ComplianceNo C# 8+ features in any new or modified SummaryThe refactoring is mechanically sound and the partial class splits are logically organized. C# 7.3 compliance is maintained throughout. The blocking issue is the missing |
No description provided.