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

false problem reported for "variable assigned but never used" #1431

Closed
mikevaMSFT opened this issue Apr 1, 2020 · 2 comments
Closed

false problem reported for "variable assigned but never used" #1431

mikevaMSFT opened this issue Apr 1, 2020 · 2 comments

Comments

@mikevaMSFT
Copy link

Issue Type: Bug

A "problem" is being reported $errMsg variable is being assigned but never used.
It is assigned inside a Foreach-Object loop and then used to call a .NET method outside the loop.

Example...

$errItem | Foreach-Object {
[string]$errMsg += "'$($PSItem.name)' " + "$($invalidIP) $($PSItem.value)`n"
}
[System.Windows.Forms.MessageBox]::Show($errMsg, $errTitle, [System.Windows.Forms.MessageBoxButtons]::OK)

Extension version: 2020.3.0
VS Code version: Code 1.43.2 (0ba0ca52957102ca3527cf479571617f0de6ed50, 2020-03-24T07:38:38.248Z)
OS version: Windows_NT x64 10.0.18363

System Info
Item Value
CPUs Intel(R) Xeon(R) W-2123 CPU @ 3.60GHz (8 x 3600)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 31.73GB (12.69GB free)
Process Argv
Screen Reader no
VM 0%
@rjmholt rjmholt transferred this issue from PowerShell/vscode-powershell Apr 2, 2020
@ghost ghost added the Needs: Triage 🔍 label Apr 2, 2020
@bergmeister
Copy link
Collaborator

bergmeister commented Apr 4, 2020

@mikevaMSFT This is a well known issue of the rule being limited to just one scriptblock scope for its analysis, see related issues of the Area - PSUseDeclaredVarsMoreThanAssignments label. As this issue is an exact duplicate of #1163, I am going to close it.
@dseeni Not sure what you mean, can you expand please?
@rjmholt @SydneyhSmith I think we need to have a line in the issue template of PSSA and vscode-powershell to tell people that false positives of PSUseDeclaredVarsMoreThanAssignments are a known issue.

@dseeni
Copy link

dseeni commented Apr 10, 2020

@bergmeister My mistake, I think the issue has to do with neovim handlying multi-line messages in the editor output https://github.com/neoclide/coc.nvim/wiki/Language-servers,
unfortunately with this error, in neovim, it will grab focus from the editor and require me to hit enter. Not sure if you can help with that.

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

3 participants