Edit

AvoidNullOrEmptyHelpMessageAttribute

Severity Level: Warning

Description

This rule detects HelpMessage attributes that contain null values, empty strings, or no value assignment. The HelpMessage attribute must contain a meaningful, non-empty string value. Omitting the value altogether causes a parse-time syntax error.

Using an empty string or null value causes PowerShell to raise an error at runtime. Always provide a descriptive help message that explains the parameter's purpose and expected input to users.

Example

Noncompliant

Function BadFuncEmptyHelpMessageEmpty
{
    Param(
        [Parameter(HelpMessage='')]
        [String]
        $Param
    )

    $Param
}

Function BadFuncEmptyHelpMessageNull
{
    Param(
        [Parameter(HelpMessage=$null)]
        [String]
        $Param
    )

    $Param
}

Function BadFuncEmptyHelpMessageNoAssignment
{
    Param(
        [Parameter(HelpMessage)]
        [String]
        $Param
    )

    $Param
}

Compliant

Function GoodFuncHelpMessage
{
    Param(
        [Parameter(HelpMessage='This is helpful')]
        [String]
        $Param
    )

    $Param
}