Remove dead logic, duplicated helpers, and style slop - #41
Merged
Conversation
The TUI Unicode-logo check computed a Windows Terminal signal that a tautological expression then ignored; documented behavior (interactive UTF-8 output) is unchanged. Stop-WdtProcessTree's membership walk can only exit through in-loop returns, so the trailing return was unreachable. The W32tm shape check accepted a LocalFunctionNames parameter it never read, and two policy functions existed only to forward it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Group-EventLogEvents reimplemented the module's own one-line-message helper inline with the same 240-character truncation; the classification test now imports the helper alongside the function under test. Protect-WdtRegexMatches assigned to the automatic $matches variable, which crash parsing elsewhere reads after -match. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Removing the trailing return in Test-WdtSnapshotMembership left one representable hashtable state uncovered: a parent key present with a null value would end the walk and return nothing. Production code cannot create that state (snapshot entries are always non-null pscustomobjects), but the function is also called directly with synthetic snapshots, so the walk now guards the parent lookup explicitly and stays total. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0x0bug
marked this pull request as ready for review
July 26, 2026 20:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Mechanical clean-code fixes. No intended production behavior changes. Invalid synthetic snapshots with null parent entries now return a structured failure instead of no result; the only user-visible production difference is normalized label spacing in report output (three misaligned columns).
Dead logic removed
Test-WdtTuiUnicodeLogoSupportcomputed a Windows Terminal signal and then ignored it in a tautological expression ($utf8 -and ($wt -or $utf8)≡$utf8). The dead signal and its two parameters are removed from the detection chain (Test-WdtTuiUnicodeLogoSupport,Get-WdtTuiLogoModeDecision,Get-WdtTuiLogoMode). Documented behavior — Unicode logo on interactive UTF-8 output — is unchanged (README "Unicode and ASCII logo modes", docs/usage.md) and is now pinned by direct tests.returninTest-WdtSnapshotMembership(process-runner) was removed as unreachable, which was true for the production path — snapshot entries are always non-null pscustomobjects, so the loop can only exit through in-loop returns. Re-review found the function is also called directly with synthetic snapshots (tests), where a parent key present with a$nullvalue would have ended the walk and returned nothing. The parent lookup is now guarded explicitly (ContainsKey+ null check →SnapshotParentMissing), keeping the function total without reintroducing a dead-looking trailing line, with a regression test that fails without the guard.Test-WdtAllowedW32tmProcessShapeaccepted-LocalFunctionNamesand never read it;Test-WdtAllowedNewObjectCommandandGet-WdtMemberSafetyIssuecarried the parameter only to forward it. The whole forwarding chain is removed.Get-WdtCommandSafetyIssuekeeps its parameter — it genuinely uses it.continuein the TUI resize path now discards explicitly ($null =).Duplication removed
Group-EventLogEventsreimplemented the events module's ownConvertTo-OneLineMessageinline (same 240/237 truncation constants). It now calls the helper.tests/diagnostic-classification.tests.ps1imports the helper alongside the function under test — the isolated-import harness was why the inline copy existed in the first place.Consistency
Protect-WdtRegexMatchesassigned to the automatic$matchesvariable; renamed to$regexMatches. This is hygiene only — modules run in separate child processes, so no cross-contamination was possible. (The same pattern exists inscripts/bootstrap/run.ps1:13, intentionally not fixed here: the bootstrap is under a byte-stability contract with the published site copy and the SHA-256 pinned intests/bootstrap-sync.tests.ps1; it needs a coordinated WDT-change → site-sync pass.)$approvalInventory/$ApprovalInventorycasing unified in the services module.Pending states (Suspicious)(services),Samples(performance), findings-summary hashtable in report-common.Regression tests added
Test-WdtSnapshotMembershipwith a parent key mapped to$nullreturns structuredSnapshotParentMissing(verified to fail without the guard).Get-WdtTuiLogoModeDecisioncontract: overrides, redirected output, UTF-8 vs OEM encodings (6 cases).ConvertTo-OneLineMessagethroughGroup-EventLogEvents: whitespace-only →No message; >240 chars → 240 with...; newline collapse.Verification
scripts/validate.ps1: pass on PowerShell 7 and Windows PowerShell 5.1 (0 parser / 0 safety / 0 layout / 0 generated).-Module Events,Services,Performance -PrivacyMode→ exit 0,Collection completeness: Complete, event messages one-lined and truncated by the shared helper, aligned labels confirmed in the generated report.git diff --check: clean.Not touched
scripts/bootstrap/run.ps1(byte-stability contract), the+4menu-count coupling inGet-WdtTuiVisibleIndexesand cross-module helper consolidation (Write-Section/Format-Bytes/ConvertTo-SafeSingleLine→ report-common) — those need AST-allowlist changes and deserve their own PR.🤖 Generated with Claude Code