Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Severity Level: Warning
Default state: Always enabled
Description
This rule detects parameters that have multiple type specifiers applied to them. Parameters shouldn't have multiple type specifiers. When you apply more than one type attribute to a parameter, it can lead to unexpected type coercion or runtime errors.
Each parameter should have exactly one type specifier to ensure predictable behavior and type safety.
Example
Noncompliant
function Test-Script
{
[CmdletBinding()]
Param
(
[switch]
[int]
$Switch
)
}
Compliant
function Test-Script
{
[CmdletBinding()]
Param
(
[switch]
$Switch
)
}
Configure rule
This rule is always enabled and isn't configurable. Use one of the following methods to avoid using this rule:
- Create a custom rule configuration file to include only the rules you want or exclude the rules you don't want.
- Add the appropriate rule suppression attributes to your code to suppress the rule for specific code blocks. For more information, see the Suppressing rules section of Using PSScriptAnalyzer.