Skip to content

Unexpected UseDeclaredVarsMoreThanAssignments warning in pipeline #1702

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
tk627 opened this issue Aug 11, 2021 · 1 comment
Closed

Unexpected UseDeclaredVarsMoreThanAssignments warning in pipeline #1702

tk627 opened this issue Aug 11, 2021 · 1 comment

Comments

@tk627
Copy link

tk627 commented Aug 11, 2021

Steps to reproduce

Run Invoke-ScriptAnalyzer against the following with the new 1.19.1 release.

$foundFile = $false
Get-ChildItem -Path . -File -Filter *.msi | ForEach-Object {
    $foundFile = $true
}
Write-Output "File found $foundFile"

Expected behavior

No rule violations.

Actual behavior

The variable 'foundFile' is assigned but never used. PSScriptAnalyzer(PSUseDeclaredVarsMoreThanAssignments) [3, 5]

If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.18362.1474
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.1474
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.1
@ghost ghost added the Needs: Triage 🔍 label Aug 11, 2021
@rjmholt
Copy link
Contributor

rjmholt commented Aug 11, 2021

Duplicate of #1163

@rjmholt rjmholt marked this as a duplicate of #1163 Aug 11, 2021
@rjmholt rjmholt closed this as completed Aug 11, 2021
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