Skip to content

Latest commit

 

History

History
70 lines (53 loc) · 1.25 KB

ReviewUnusedParameter.md

File metadata and controls

70 lines (53 loc) · 1.25 KB
description ms.date ms.topic title
ReviewUnusedParameter
03/26/2024
reference
ReviewUnusedParameter

ReviewUnusedParameter

Severity Level: Warning

Description

This rule identifies parameters declared in a script, scriptblock, or function scope that have not been used in that scope.

Configuration settings

By default, this rule doesn't consider child scopes other than scriptblocks provided to Where-Object or ForEach-Object. The CommandsToTraverse setting is an string array allows you to add additional commands that accept scriptblocks that this rule should examine.

@{
    Rules = @{
        PSReviewUnusedParameter = @{
            CommandsToTraverse = @(
                'Invoke-PSFProtectedCommand'
            )
        }
    }
}

How

Consider removing the unused parameter.

Example

Wrong

function Test-Parameter
{
    Param (
        $Parameter1,

        # this parameter is never called in the function
        $Parameter2
    )

    Get-Something $Parameter1
}

Correct

function Test-Parameter
{
    Param (
        $Parameter1,

        # now this parameter is being called in the same scope
        $Parameter2
    )

    Get-Something $Parameter1 $Parameter2
}