We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This is a continuation of Issue #699 which I previously opened. It was closed as being resolved, but this issue remains.
$resourceParams = @('a1', 'b1', c1') $params = Get-Variable -Name $resourceParams -ErrorAction SilentlyContinue | ForEach-Object { $m = @{} } { $m[$_.Name] = $_.Value } { $m } # foreach begin{} process{} end{}
No reported issue
PSUseDeclaredVarsMoreThanAssignments Warning The variable 'm' is assigned but never used.
> $PSVersionTable Name Value ---- ----- PSVersion 5.1.18287.1001 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.18287.1001 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.17.1 1.10.0 1.4.0
The text was updated successfully, but these errors were encountered:
+1, I notice this issue too. Another scenario that exposes it is this:
if ( 1+1 = 2) {$a = 'b'} else {$a = 'c'} Write-Output $a
Since $a is declared twice but used once, a problem is reported.
Sorry, something went wrong.
I just wanted to +1 this. My code: ` $Roles = Get-SCUserRoleMembership -UserName $Username $Roles | ForEach-Object {IF ($_.UserRoleProfile -eq "Administrator") {$IsAdmin = $True}}
IF ($IsAdmin -ne $True) { "User is not admin" }`
$ISAdmin is both declared and then used, but I still get "The variable 'IsAdmin' is assigned but never used."
+1, I'm seeing this as well.
$found = $false $repos | % { if ($_.Item1 -ieq $r) { $found = $true } } if (-Not $found) { throw "..." }
$found is said to be declared but never used within the ForEach-Object scope.
$found
ForEach-Object
Duplicate of #1163
No branches or pull requests
This is a continuation of Issue #699 which I previously opened. It was closed as being resolved, but this issue remains.
Steps to reproduce
Expected behavior
Actual behavior
Environment data
The text was updated successfully, but these errors were encountered: