description | ms.date | ms.topic | title |
---|---|---|---|
Cmdlet Singular Noun |
03/27/2024 |
reference |
UseSingularNouns |
Severity Level: Warning
PowerShell team best practices state cmdlets should use singular nouns and not plurals. Suppression allows you to suppress the rule for specific function names. For example:
function Get-Elements {
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', 'Get-Elements')]
Param()
}
Rules = @{
PSUseSingularNouns = @{
Enable = $true
NounAllowList = 'Data', 'Windows', 'Foos'
}
}
-
Enable
:bool
(Default value is$true
)Enable or disable the rule during ScriptAnalyzer invocation.
-
NounAllowList
:string[]
(Default value is{'Data', 'Windows'}
)Commands to be excluded from this rule.
Data
andWindows
are common false positives and are excluded by default.
Change plurals to singular.
function Get-Files
{
...
}
function Get-File
{
...
}