PowerShell / PowerShell/PSScriptAnalyzer

Partial Parameter Name give confusing message

Open
#1,016 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Tested in Version 1.17.0 (and 1.16.1)
No mention of this was found in a search of issues.

Message is confusing when PARTIAL parameter name is supplied (no warning if name omitted, no warning if name fully spelled out) but message doesn't reference the real issue of a partial name:

Cmdlet 'Compare-object' may be used incorrectly.
Please check that all mandatory parameters are
supplied.

Steps to reproduce

$a = 'a','b','c'
$b = 'a','b','c'
Compare-object $a $b
Compare-object -reference $a -difference $b   # Warning one this version
Compare-object -referenceobject $a -differenceobject $b

Message is:
Message

Cmdlet 'Compare-object' may be used incorrectly.
Please check that all mandatory parameters are
supplied.

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.14409.1012
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1012
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.17.0

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

Reproduce the warning with the three Compare-object command forms shown in the issue and compare the diagnostics produced for omitted, partial, and fully spelled-out parameter names. Trace the PSScriptAnalyzer entry point that generates this message; done means the partial-name case identifies the partial parameter name rather than only reporting missing mandatory parameters.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.