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

Incorrect warning generated by PSScriptAnalyzer #190

Closed
KirkMunro opened this Issue May 21, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@KirkMunro
Contributor

KirkMunro commented May 21, 2015

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

This comment has been minimized.

Show comment
Hide comment
@raghushantha

raghushantha Jun 4, 2015

Member

I believe Quoc fixed this. Quoc?

Member

raghushantha commented Jun 4, 2015

I believe Quoc fixed this. Quoc?

@quoctruong

This comment has been minimized.

Show comment
Hide comment
@quoctruong

quoctruong Jun 4, 2015

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

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

@quoctruong

This comment has been minimized.

Show comment
Hide comment
@quoctruong

quoctruong Jun 10, 2015

Close this as the remaining problem is similar to #189

Close this as the remaining problem is similar to #189

@quoctruong quoctruong closed this Jun 10, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment