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 and ForEach-Object, says variable "is assigned but never used" but it is #1639

Closed
mlduber opened this issue Feb 9, 2021 · 2 comments

Comments

@mlduber
Copy link

mlduber commented Feb 9, 2021

Steps to reproduce

'foo' | ForEach-Object { $guy = 'bar' }; $guy

Expected behavior

Zero problem. Scope issue should be expected with Invoke-Command but not with ForEach-Object.

Actual behavior

The variable 'guy' is assigned but never used.PSScriptAnalyzer(PSUseDeclaredVarsMoreThanAssignments)

image

Environment data

PSScriptAnalyzer module version is 1.19.0.

@rjmholt
Copy link
Contributor

rjmholt commented Feb 9, 2021

Duplicate of #1163

@rjmholt rjmholt marked this as a duplicate of #1163 Feb 9, 2021
@rjmholt rjmholt closed this as completed Feb 9, 2021
@rjmholt
Copy link
Contributor

rjmholt commented Feb 10, 2021

I've written up #1641 now to explain the state of play here

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