PowerShell / PowerShell/PSScriptAnalyzer

Rule Request: Warn Against Special Characters that PowerShell Accepts

Open
#1,436 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Area - Rules Issue - Enhancement Issue - New Rule Up-for-Grabs
Dominant language
C#
Stars
2.2k
Forks
414
Avg merge
13h 1m
Merged PRs (30d)
2

Description

Powershell 7 supports the use of Em Dash ( – ) for parameter prefixes, while Windows Powershell doesn't and can cause errors such as

Invoke-Command –ComputerName $Computer ...
–ComputerName $Computer
The string is missing the terminator: "

I'm not sure how but in the last month a good dozen Em Dashes were accidentally added to my codebase.

As Em Dashes are almost impossible to notice in a fix width font, I think it should be considered best practice to never use them and put a big error/warning on screen when you come across one.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation file, test, or entry point is named. Start by locating the existing rule registration and rule tests in PSScriptAnalyzer, then determine how an em dash in a PowerShell parameter position should be reported. Done means the analyzer consistently warns about the character and tests cover the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.