PowerShell / PowerShell/vscode-powershell

Problems tab does not include all problems reported by PSScriptAnalyzer

Open
#4,421 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Script Analysis Issue-Bug
Dominant language
TypeScript
Stars
1.9k
Forks
547
PR merge metrics
No merged PRs in 30d

Description

Prerequisites
  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.
Summary

Here is a sample function:

function Set-Numeric {[CmdletBinding()] param([Parameter(ValueFromPipeline)]$a,[string]$b,$c) $a.save(); $c |%{
    @($a.$b.cells['A1:Z1'].value).indexof($_)+1 |set-ExcelColumn -ExcelPackage $a -WorksheetName $b -NumberFormat '$#,##0.00;-$#,##0.00;"- "'};
$a.save()}

When opening this in a file, I see a single problem:
[{ "resource": "Untitled-1", "owner": "_generated_diagnostic_collection_name_#3", "code": "PSAvoidUsingCmdletAliases", "severity": 4, "message": "'%' is an alias of 'ForEach-Object'. Alias can introduce possible problems and make scripts hard to maintain. Please consider changing alias to its full content.", "source": "PSScriptAnalyzer", "startLineNumber": 1, "startColumn": 110, "endLineNumber": 1, "endColumn": 111 }]

Code_duFbPD8P7d
Running the script analyzer on this definition shows 4 issues.

PowerShell Version
PS> $psversiontable

Name                           Value
----                           -----
PSVersion                      7.3.2
PSEdition                      Core
GitCommitId                    7.3.2
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visual Studio Code Version
PS > code --version
1.75.1
441438abd1ac652551dbe4d408dfcec8a499b8bf
x64
Extension Version
ms-vscode.powershell@2023.1.0
Steps to Reproduce

Here is a sample function:

function Set-Numeric {[CmdletBinding()] param([Parameter(ValueFromPipeline)]$a,[string]$b,$c) $a.save(); $c |%{
    @($a.$b.cells['A1:Z1'].value).indexof($_)+1 |set-ExcelColumn -ExcelPackage $a -WorksheetName $b -NumberFormat '$#,##0.00;-$#,##0.00;"- "'};
$a.save()}

When opening this in a file, I see a single problem:
[{ "resource": "Untitled-1", "owner": "_generated_diagnostic_collection_name_#3", "code": "PSAvoidUsingCmdletAliases", "severity": 4, "message": "'%' is an alias of 'ForEach-Object'. Alias can introduce possible problems and make scripts hard to maintain. Please consider changing alias to its full content.", "source": "PSScriptAnalyzer", "startLineNumber": 1, "startColumn": 110, "endLineNumber": 1, "endColumn": 111 }]

Code_duFbPD8P7d
Running the script analyzer on this definition shows 4 issues.

Visuals

image
image

Logs

No response

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

Start by opening the sample function in VS Code and comparing the Problems tab with the four issues reported by PSScriptAnalyzer when run directly. Trace the extension's PSScriptAnalyzer diagnostic reporting path and verify that all analyzer findings are surfaced in the Problems tab; done means the editor displays the same four issues.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.