Pattern: Unused variable
Issue: -
Generally variables that are not used more than their assignments are considered wasteful and not needed.
Remove the variables that are declared but not used.
Example of incorrect code:
function Test
{
$declaredVar = "Declared and used"
$declaredVar2 = "Not used"
Write-Output $declaredVar
}
Example of correct code:
function Test
{
$declaredVar = "Declared and used"
Write-Output $declaredVar
}