Skip to content

PSSA: Variable is reported never assigned, but it is #772

Closed
@johlju

Description

@johlju

System Details

  • Operating system name and version:
  • VS Code version:
  • PowerShell extension version:
  • Output from $PSVersionTable:
PS > code -v
1.12.2
19222cdc84ce72202478ba1cec5cb557b71163de
PS > $pseditor.EditorServicesVersion
PS > code --list-extensions --show-versions
DavidAnson.vscode-markdownlint@0.7.2
donjayamanne.githistory@0.2.0
eamodio.gitlens@3.4.9
ms-vscode.csharp@1.9.0
ms-vscode.PowerShell@1.1.0
PeterJausovec.vscode-docker@0.0.14
ryu1kn.annotator@0.10.1
streetsidesoftware.code-spell-checker@1.1.0
Tyriar.theme-sapphire@0.2.1
PS > $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.15063.296
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.296
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

I got variables saying they are not assigned... but they are. If thinking of $testParameters. Those variables starting with $mockDynamic* I can understand that they are reporting this, because they are used in a "dynamic script block" for the Mock (not visible in the screen shot).

image

After reloading VSCode all the PSSA rule warnings for the variables disappeared. So I guess I have to report back when I see it again. Submitting here if someone else encounters the same problem.

Attached Logs

Follow the instructions in the README about capturing and sending logs.

I send logs next time I see this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions