Skip to content

PSAvoidUsingCmdletAliases whitelist should be case-insensitive #737

Closed
@ajansveld

Description

@ajansveld

When using a settings file for the Script Analyzer and specifying whitelisted aliases, the rule is only skipped if the alias matches using the exact case.

For example, if we use the following settings file (from the ReadMe):

# PSScriptAnalyzerSettings.psd1

@{
    'Rules' = @{
        'PSAvoidUsingCmdletAliases' = @{
            'Whitelist' = @('cd')
        }
    }
}

If the user now uses "CD C:\Windows" the rule is still flagged. This may seem trivial but the typical user will expect that casing shouldn't matter when using aliases (e.g. people often use select/Select, foreach/ForEach interchangeably).

This is the relevant code in AvoidAlias.cs:

if (aliasName == null
    || whiteList.Contains(aliasName))
{
    continue;
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions