Remove unused internal functions#2907
Draft
nohwnd wants to merge 2 commits into
Draft
Conversation
test.ps1 -CC traces the parent process, but the Output and InNewProcess tests run Pester in a child process through Invoke-InNewProcess and assert on its output. So the failure rendering, CI format output and discovery messages are covered by tests, the tracer just never sees them and reports them as missed, which makes the coverage number lie about what is actually tested. When -CC is on the parent now points the children at a drop folder and the same coverage target via PESTER_CC_CHILD_* env vars, which the child process inherits. Each child traces itself the same way the parent does, dumps the path + line:column it hit, and the parent merges those into the measure before the report. Parent and child trace the same files, so a child hit maps onto the same not yet hit point and we just flip it to Hit (the point is a struct, so copy, set, write back, same as the tracer does on a live hit). When -CC is off nothing changes, the child just runs . $ScriptBlock as before. Output.ps1 goes from 74% to 80%, overall from 85.7% to 86.4%. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| @@ -1,4 +1,4 @@ | |||
| function Count-Scopes { | |||
| function Count-Scopes { | |||
These internal functions have no callers left in src or tst (checked case insensitively, ignoring comments and their own definition), and none are exported. Grouped: - Old v4 assertion messages: the orphaned Should<Name>FailureMessage and NotShould<Name>FailureMessage pairs for BeGreaterThan, BeIn, BeLessThan, BeLike, BeLikeExactly, BeOfType, BeTrueOrFalse, Contain and HaveCount, plus Get-FailureMessage. The operators build the message inline now. Be, Match and FileContentMatch still call theirs so they stay, and Exist and Throw stay because Should.Tests.ps1 asserts their message functions exist. - Unfinished pretty printer in Format.ps1: Format-Object, Format-Hashtable, Format-Dictionary, Get-DisplayProperty. Format-Nicely returns the value as a string and the advanced path is commented out. - Orphaned helpers across Mock, RSpec, Runtime, Coverage, Debugging and Utility (Run-Test, Merge-CommandCoverage, Show-ParentList, Add-MockBehavior, FindMock, LastThat, Test-IsClosure, Reset-ConflictingParameters, New-BlockWithoutParameterAliases, New-OneTimeBlockSetup, Set-CurrentBlock, Reset-TestSuiteTimer, New-DiscoveredBlockContainerObject, Get-SessionStateHint, Assert-RunInProgress, and the Pester.Utility dictionary helpers). Full test.ps1 run passes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
nohwnd
force-pushed
the
remove-unused-internal-functions
branch
from
July 18, 2026 10:55
b5b92cd to
a5680b7
Compare
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.
Draft, and stacked on #2906. It branches off that PR, so until #2906 merges the diff here shows both changes, review this one after that lands and it rebases clean.
While generating a full coverage report I noticed a chunk of the missed lines are not gaps, they are internal functions that nothing calls anymore. This removes 51 of them. Each one has no callers in
srcortst(checked case insensitively, ignoring comments and its own definition), and none are exported.By group:
Should<Name>FailureMessage/NotShould<Name>FailureMessagepairs for BeGreaterThan, BeIn, BeLessThan, BeLike, BeLikeExactly, BeOfType, BeTrueOrFalse, Contain and HaveCount, plusGet-FailureMessage. The operators build the message inline now. Be, Match and FileContentMatch still call theirs so they stay. Exist and Throw also stay, becauseShould.Tests.ps1asserts their message functions exist (it builds the names as strings, so a plain grep does not see that use).Format-Object,Format-Hashtable,Format-Dictionary,Get-DisplayProperty.Format-Nicelyreturns the value as a string and the advanced path is commented out.Run-Test,Merge-CommandCoverage,Show-ParentList,Add-MockBehavior,FindMock,LastThat,Test-IsClosure,Reset-ConflictingParameters,New-BlockWithoutParameterAliases,New-OneTimeBlockSetup,Set-CurrentBlock,Reset-TestSuiteTimer,New-DiscoveredBlockContainerObject,Get-SessionStateHint,Assert-RunInProgress, and thePester.Utilitydictionary helpers.Verification
Full
test.ps1run passes (P tests and Pester tests, 2606 passed, 0 failed). Every touched file parses.Notes for review
Sort-Propertyin Format.ps1 is now only reachable from the removedGet-DisplayProperty, so it is dead too, I left it in this pass, easy to drop as a follow up.PostProcess-RspecTestRunandRemove-RSpecNonPublicPropertiesare defined with lowercaseRspecbut called withRSpec/RSPec, they only work because PowerShell is case insensitive.ConvertTo-PesterResulthas no production caller, it is kept because a test uses it as the canary for "internals do not leak to the SUT".