Skip to content

PSScriptAnalyzer reports false positive problem PSUseDeclaredVarsMoreThanAssignments #1437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gmerkh opened this issue Apr 9, 2020 · 1 comment

Comments

@gmerkh
Copy link

gmerkh commented Apr 9, 2020

Issue Type: Bug

Create a PowerShell file in VSCode with the following content:

5..10 | ForEach-Object {$id=1} {
Write-Output $id
$id++
}

Expected result: Code has 0 problems
Actual result: Code has 1 problem:
{
"resource": "Untitled-1.ps1",
"owner": "generated_diagnostic_collection_name#2",
"code": "PSUseDeclaredVarsMoreThanAssignments",
"severity": 4,
"message": "The variable 'id' is assigned but never used.",
"source": "PSScriptAnalyzer",
"startLineNumber": 1,
"startColumn": 25,
"endLineNumber": 1,
"endColumn": 28
}

Extension version: 2020.3.0
VS Code version: Code 1.44.0 (2aae1f26c72891c399f860409176fe435a154b13, 2020-04-07T23:31:18.860Z)
OS version: Windows_NT x64 10.0.18363

@bergmeister
Copy link
Collaborator

This is a known issue due to the analysis of this role being limited to the scope of one scriptblock. Therefore closing as a duplicate of #1163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants