From 12a39bf06ccaea97266e587b6e0d61f848acf2e0 Mon Sep 17 00:00:00 2001 From: Trent Blackburn Date: Sun, 10 May 2026 02:15:06 -0400 Subject: [PATCH] style: replace IsNullOrEmpty guard with ValidateNotNullOrEmpty attribute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Syncs the same cleanup landed in PowerShellModuleTemplate PR #23 (commit abf5d46). The runtime IsNullOrEmpty check + throw on $VersionString is fail-at-bind-time material — switching to [ValidateNotNullOrEmpty()] makes the contract self-documenting and removes the redundant guard. Atomic single edit: add validator and remove guard together so the function never goes through a transient dead-code state where both exist (which is what Copilot and CodeRabbit caught on the template PR). Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/ManifestHelpers.psm1 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/ManifestHelpers.psm1 b/tests/ManifestHelpers.psm1 index b797866..7f93868 100644 --- a/tests/ManifestHelpers.psm1 +++ b/tests/ManifestHelpers.psm1 @@ -36,13 +36,10 @@ function Split-SemVerString { [OutputType([hashtable])] param( [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] [string]$VersionString ) - if ([string]::IsNullOrEmpty($VersionString)) { - throw "VersionString cannot be empty or null" - } - # Strip build metadata per SemVer 2.0.0 — it does not affect precedence and is # not valid for [System.Version], so it must be removed before further parsing. $coreVersion = ($VersionString -split '\+', 2)[0]