Prompts/GenXdev.Coding.PowerShell.Modules/Assert-ImproveUnitTest.txt

Your task:
Ensure that this function has the a unit test that invokes
GenXdev.Coding\Invoke-GenXdevScriptAnalyzer
or
Invoke-ScriptAnalyzer
and if so, replace that test with the one below;
if it doesn't have such a test, add the one below;
 
################################################################################
Pester\Describe "$CmdletName" {
 
    Pester\It "Should pass PSScriptAnalyzer rules" {
 
        # get the script path for analysis
        $scriptPath = GenXdev.FileSystem\Expand-Path "$PSScriptRoot\..\..\Functions\$FullModuleName\$CmdLetNoTestName.ps1"
 
        # run analyzer with explicit settings
        $analyzerResults = GenXdev.Coding\Invoke-GenXdevScriptAnalyzer `
            -Path $scriptPath
 
        [string] $message = ""
        $analyzerResults | Microsoft.PowerShell.Core\ForEach-Object {
 
            $message = $message + @"
--------------------------------------------------
Rule: $($_.RuleName)`
Description: $($_.Description)
Message: $($_.Message)
`r`n
"@
        }
 
        $analyzerResults.Count | Should -Be 0 -Because @"
The following PSScriptAnalyzer rules are being violated:
$message
"@;
    }
}
 
################################################################################
 
If really necessary you can create a rule exception for ScriptAnalyzer rules:
 
function Get-SpotifyLyrics {
 
    [CmdLetBinding(DefaultParameterSetName = "")]
    [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "Get-SpotifyLyrics")] [Alias("lyrics")]
    param(
        # params
    )
 
    # function implementation
}
 
################################################################################
 
Only add a Describe {} block if there isn't one yet.
Ensure that the block above is the first one in the Describe block.
 
Never ask if I want to proceed, assume yes in those cases.
Always proceed by implementing these changes systematically.
 
$Prompt