Skip to content
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

PSScriptAnalyzer incorrectly flags a variable as assigned but never used #989

Closed
krissmilne opened this issue Aug 9, 2017 · 1 comment
Closed

Comments

@krissmilne
Copy link

krissmilne commented Aug 9, 2017

System Details

  • Windows 10 1511
  • VS Code Version: 1.14.2
  • PowerShell extension version: 1.4.1
  • $PSVersionTable

PSVersion 5.0.10586.962
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.962
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1


Issue Description

When a variable is declared either in the begin block or statement block of a ForEach-Object pipeline, the PSScriptAnalyzer incorrectly flags it as assigned but never used.

Examples:
$Count is incorreclty flagged as assigned but never used
$myArray = @()
$myArray += "Item1"
$myArray += "Item2"
$myArray += "Item3"
$myArray += "Item4"
$myArray | ForEach-Object {$Count = 0} {$Count++; $Count}

@daviwil
Copy link
Contributor

daviwil commented Aug 14, 2017

This is covered by PowerShell/PSScriptAnalyzer#711, will close this issue in favor of that one.

@daviwil daviwil closed this as completed Aug 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants