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
Description
This rule detects semicolons used as line terminators at the end of statements. In PowerShell, line-ending semicolons are redundant and detract from code readability. Although semicolons serve as statement separators on a single line, using them as line terminators is discouraged. Avoid using semicolons at the end of lines.
This rule promotes cleaner, more maintainable code by removing unnecessary semicolons. This rule isn't enabled by default.
Example
Noncompliant
Install-Module -Name PSScriptAnalyzer; $a = 1 + $b;
Install-Module -Name PSScriptAnalyzer;
$a = 1 + $b
Compliant
Install-Module -Name PSScriptAnalyzer; $a = 1 + $b
Install-Module -Name PSScriptAnalyzer
$a = 1 + $b
Configuration
Rules = @{
PSAvoidSemicolonsAsLineTerminators = @{
Enable = $true
}
}
Parameters
Enable
This parameter controls whether ScriptAnalyzer checks the code against this rule. It accepts a
boolean value. To enable this rule, set this parameter to $true. The default value is $false.