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
{{ message }}
Repository navigation
PSSA: Variable is reported never assigned, but it is #772
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).
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.
Pester dot sources the script block given to BeforeEach in the corresponding Context scope. However, there is no way for PSSA to know about this dot-sourcing operation just through static analysis. Hence, unfortunately, the only way around this issue right now is to suppress the violations. More information about suppression can be found here. Due to the limitation of how suppression is implemented, the only way you can suppress these violations in a pester test file is to place an empty param block at the beginning of the test file, and precede it with a suppression attribute. For example, the following will suppress all the PSUseDeclaredVarsMoreThanAssignments violations in the file, including the violations that you have pointed out.
Yes, that makes sense. I have never seen those warnings before when coding in VS Code. It's after this latest version so I figured something was wrong.
But then we file this under "by design" and use that workaround if it gets too annoying 😄
Activity
kapilmb commentedon May 20, 2017
Pester dot sources the script block given to
BeforeEachin the correspondingContextscope. However, there is no way for PSSA to know about this dot-sourcing operation just through static analysis. Hence, unfortunately, the only way around this issue right now is to suppress the violations. More information about suppression can be found here. Due to the limitation of how suppression is implemented, the only way you can suppress these violations in a pester test file is to place an emptyparamblock at the beginning of the test file, and precede it with a suppression attribute. For example, the following will suppress all thePSUseDeclaredVarsMoreThanAssignmentsviolations in the file, including the violations that you have pointed out.johlju commentedon May 20, 2017
Yes, that makes sense. I have never seen those warnings before when coding in VS Code. It's after this latest version so I figured something was wrong.
But then we file this under "by design" and use that workaround if it gets too annoying 😄
Thanks!