Skip to content

Files

Latest commit

 

History

History
49 lines (33 loc) · 872 Bytes

ReviewUnusedParameter.md

File metadata and controls

49 lines (33 loc) · 872 Bytes

Pattern: Unused parameter

Issue: -

Description

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

How

Consider removing the unused parameter.

Example

Example of incorrect code:

function Test-Parameter
{
	Param (
		$Parameter1,
		
		# this parameter is never called in the function
		$Parameter2
	)
	
	Get-Something $Parameter1
}

Example of correct code:

function Test-Parameter
{
	Param (
		$Parameter1,
		
		# now this parameter is being called in the same scope
		$Parameter2
	)
	
	Get-Something $Parameter1 $Parameter2
}

Further Reading