PowerShell / PowerShell/vscode-powershell
Problems tab does not include all problems reported by PSScriptAnalyzer
Nobody has claimed this yet.
- 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
}]

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
}]

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


Logs
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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