Skip to content

Latest commit

 

History

History
67 lines (49 loc) · 1.13 KB

UseSingularNouns.md

File metadata and controls

67 lines (49 loc) · 1.13 KB
description ms.date ms.topic title
Cmdlet Singular Noun
03/27/2024
reference
UseSingularNouns

UseSingularNouns

Severity Level: Warning

Description

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()
}

Configuration

Rules = @{
    PSUseSingularNouns = @{
        Enable           = $true
        NounAllowList    = 'Data', 'Windows', 'Foos'
    }
}

Parameters

  • 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 and Windows are common false positives and are excluded by default.

How

Change plurals to singular.

Example

Wrong

function Get-Files
{
    ...
}

Correct

function Get-File
{
    ...
}