Repository navigation
Fix PSAvoidLongLines violations blocking CI in New-Jwt, Test-Jwt, and ConvertTo-Base64UrlString #24
Description
The CI pipeline fails on every platform (Linux, macOS, Windows) for both Lint-SourceCode and Lint-Module jobs due to PSAvoidLongLines violations detected by PSScriptAnalyzer. The default maximum line length enforced by the rule is 120 characters.
Request
What happens
Running the Process-PSModule workflow on PR #18 produces lint failures across all three platforms:
❌ Some [1] tests failed.
[-] Avoid long lines (PSAvoidLongLines) 63ms (61ms|2ms)
The same failure is reproduced on the built module artifact during Lint-Module, confirming the violations originate in source rather than being introduced by the build step. The Get-TestResults job then aggregates these failures and exits with a non-zero code, blocking the rest of the pipeline.
Reproduction steps
- Check out the
initbranch of this repository - Run PSScriptAnalyzer against
src/functions/public/:
Invoke-ScriptAnalyzer -Path ./src/functions/public/ -IncludeRule PSAvoidLongLines- Observe violations reported in
New-Jwt.ps1,Test-Jwt.ps1, andConvertTo-Base64UrlString.ps1
What is expected
All source files pass PSAvoidLongLines with no violations so that the Lint-SourceCode and Lint-Module CI jobs succeed and the pipeline can continue through to publish.
Environment
- Module version: unreleased (
initbranch, Actions run 25694258038) - PSScriptAnalyzer rule:
PSAvoidLongLines(max 120 characters) - Platforms affected: Linux, macOS, Windows (all three matrix legs)
Regression
This has been present since the init branch was first pushed. Not a regression from a previously passing state.
Workaround
None. The CI gate cannot be bypassed without skipping the linter.
Acceptance criteria
- All files under
src/functions/public/passPSAvoidLongLineswith no violations - No functional behavior of
New-Jwt,Test-Jwt, orConvertTo-Base64UrlStringchanges as a result of the reformatting Lint-SourceCodeandLint-ModuleCI jobs pass on all three platforms
Technical decisions
Affected files and line counts: The violations are isolated to three files — New-Jwt.ps1 (7 lines), Test-Jwt.ps1 (6 lines), and ConvertTo-Base64UrlString.ps1 (2 lines — one in the .NOTES comment block, one in the throw statement). All exceed 120 characters.
Fix strategy: Each long line falls into one of three categories:
- Long
throwmessage strings — extract the message into a$messagevariable on a preceding line, thenthrowusing that variable. - Long inline conditionals (
if ($Secret -is [byte[]]) { $Secret } else { ... }) — split across multiple lines using PowerShell's implicit line continuation inside grouping expressions. - Long
.NOTEScomment text — wrap the sentence at a natural word boundary within 120 characters.
Scope: Pure formatting change. No logic, parameter names, error types, or test assertions are altered.
Implementation plan
Source fixes
- In
New-Jwt.ps1, extract longthrowmessage strings into$messagevariables (lines 80, 90, 101, 106, 128, 144) - In
New-Jwt.ps1, split the long$hmacsha256.Key = if (...) {...} else {...}assignment across multiple lines (line 132) - In
Test-Jwt.ps1, extract longthrowmessage strings into$messagevariables (lines 78, 88, 103, 121, 154) - In
Test-Jwt.ps1, split the long$hmacsha256.Key = if (...) {...} else {...}assignment across multiple lines (line 125) - In
ConvertTo-Base64UrlString.ps1, wrap the.NOTEScomment line at a word boundary under 120 characters (line 24) - In
ConvertTo-Base64UrlString.ps1, extract the longthrowmessage string into a$messagevariable (line 51)
Validation
- Confirm
Invoke-ScriptAnalyzer -Path ./src/functions/public/ -IncludeRule PSAvoidLongLinesreturns no results - Confirm all existing Pester tests in
tests/Jwt.Tests.ps1still pass after reformatting
Activity
🩹 [Patch]: Linting passes on all platforms (#25)