You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if ($IsMissingFiles){
Write-Host "Missing files"
}
Shows error:
file: 'file:///c%3A//test.ps1'
severity: 'Warning'
message: 'The variable 'IsMissingFiles' is assigned but never used. (PSUseDeclaredVarsMoreThanAssignments)'
at: '6,9'
source: 'PSScriptAnalyzer'
code: 'PSScriptAnalyzerdb99606b-bfb5-43be-8902-10233d7a4a8c'
I am experiencing a problem with...
False error message
Attached Logs
Follow the instructions in the README
about capturing and sending logs.
The text was updated successfully, but these errors were encountered:
As explained in Powershell Code format (PSScriptAnalyzer) flags variable as unused #889, this has aleady been reported here : PowerShell/PSScriptAnalyzer#827
System Details
$PSVersionTable
:PSVersion 5.1.15063.786
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.786
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Issue Description
For some reason it always complains that my variable is assigned but never used when I assign into a particular loop. Repro code:
$RequredFiles = @("c:\somefile1.txt","c:\somefiles2.txt")
$IsMissingFiles = $false
$RequredFiles | ForEach-Object {
if (!(Test-Path $)){
$IsMissingFiles = $true
Write-Host "Required file missing: $"
}
}
if ($IsMissingFiles){
Write-Host "Missing files"
}
Shows error:
file: 'file:///c%3A//test.ps1'
severity: 'Warning'
message: 'The variable 'IsMissingFiles' is assigned but never used. (PSUseDeclaredVarsMoreThanAssignments)'
at: '6,9'
source: 'PSScriptAnalyzer'
code: 'PSScriptAnalyzerdb99606b-bfb5-43be-8902-10233d7a4a8c'
I am experiencing a problem with...
False error message
Attached Logs
Follow the instructions in the README

about capturing and sending logs.
The text was updated successfully, but these errors were encountered: