Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 540 Bytes

UseDeclaredVarsMoreThanAssignments.md

File metadata and controls

34 lines (24 loc) · 540 Bytes

UseDeclaredVarsMoreThanAssignments

Severity Level: Warning

Description

Generally variables that are not used more than their assignments are considered wasteful and not needed.

How

Remove the variables that are declared but not used.

Example

Wrong

function Test
{
    $declaredVar = "Declared just for fun"
    $declaredVar2 = "Not used"
    Write-Output $declaredVar
}

Correct

function Test
{
    $declaredVar = "Declared just for fun"
    Write-Output $declaredVar
}