Skip to content

Incorrect warning generated by PSScriptAnalyzer #190

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
KirkMunro opened this issue May 21, 2015 · 3 comments
Closed

Incorrect warning generated by PSScriptAnalyzer #190

KirkMunro opened this issue May 21, 2015 · 3 comments
Assignees

Comments

@KirkMunro
Copy link
Contributor

I have a module called HistoryPx. In the manifest, I have the following:

$PSModule.OnRemove = {
# ...
}

$PSModule is initialized outside of this file in a snippet. That causes PSAvoidUnitializedVariable to be raise a warning. However, it seems the assignment that I am performing here is also generating a warning, but the warning is completely undecipherable. Here is the warning type/text:

RuleName: PSUseDeclaredVarsMoreThanAssignments
Message: The variable 'PSModule' is assigned but never used

First, what does PSUseDeclaredVarsMoreThanAssignments even mean? That name doesn't make any sense to me whatsoever.

Second, PSModule is not assigned but never used. In this scenario, I am assigning a value to a property on PSModule.

Third, I was already warned that PSModule is not initialized (even though it is), so why am I receiving another warning at all?

This warning simply doesn't make any sense whatsoever. The name should change to something that clearly indicates what rule is being checked, and the message should change to properly identify what is the issue that is being raised.

You may want to consider leaving the warning out in this case though because you already told me that PSModule is not initialized (which would be the one and only warning I would expect to see if I was assigning a value to a property of an uninitialized variable).

@raghushantha
Copy link
Member

I believe Quoc fixed this. Quoc?

@quoctruong
Copy link

Yes I fixed the PSUseDeclaredVarsMorehanAssignments bug but not the UninitializedVariable across module.

@quoctruong
Copy link

Close this as the remaining problem is similar to #189

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

3 participants