Skip to content

Latest commit

 

History

History
73 lines (57 loc) · 1.13 KB

File metadata and controls

73 lines (57 loc) · 1.13 KB
description Avoid using null or empty HelpMessage parameter attribute.
ms.custom PSSA v1.21.0
ms.date 06/28/2023
ms.topic reference
title AvoidNullOrEmptyHelpMessageAttribute

AvoidNullOrEmptyHelpMessageAttribute

Severity Level: Warning

Description

The value of the HelpMessage attribute should not be an empty string or a null value as this causes PowerShell's interpreter to throw an error when executing the function or cmdlet.

How

Specify a value for the HelpMessage attribute.

Example

Wrong

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
}

Correct

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

    $Param
}