Skip to content

Powershell PSScriptAnalyzer, error in PSUseDeclaredVarsMoreThanAssignments #1226

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
ingemar-hn opened this issue Mar 12, 2018 · 1 comment
Closed

Comments

@ingemar-hn
Copy link

System Details

  • Operating system name and version: Windows 10
  • VS Code version:
    Version 1.22.0-insider
    Commit 5450fdc79778b5a76a27ea7e5fd68e9ebbe44107
    Date 2018-03-12T05:15:51.483Z
    Shell 1.7.9
    Renderer 58.0.3029.110
    Node 7.9.0
    Architecture x64
  • PowerShell extension version: 1.6.0
  • Output from $PSVersionTable:
Name                           Value
----                           -----
PSVersion                      5.1.16299.248
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.248
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Copy / paste the following commands into the PowerShell Integrated Console, and paste the output here:

code -v
$pseditor.EditorServicesVersion
code --list-extensions --show-versions
$PSVersionTable

PS [A] > code -v
1.17.2
b813d12980308015bcd2b3a2f6efa5c810c33ba5
PS [A] > $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      6      0      0


PS [A] > code --list-extensions --show-versions
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
PS [A] > $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.16299.248
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.248
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

Error occurs in the below code:

$a = 0
foreach ($i in 0..3) {
        $a = 1
}
0..3 | ForEach-Object {
        $a = 1
}
$a

In the first loop it works as it should. In the second $a is reported to be assigned but never used.

Attached Logs

Follow the instructions in the README
about capturing and sending logs.
logs.zip

@rkeithhill
Copy link
Contributor

This issue has been submitted on the PSScriptAnalyzer repo where it needs to be addressed. Please vote up that issue - PowerShell/PSScriptAnalyzer#831

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