Skip to content

PSUseDeclaredVarsMoreThanAssignments - mention scoping #17

Closed
@HeyDude378

Description

@HeyDude378

It doesn't seem that variables have to be used more than their assignments; they can also be used the same number of times. You should clarify the language by saying something like "greater than or equal to their assignments".

You should also mention that the variable must be used within the same scope in which it was declared or else it won't be considered to be "used".

I have an example...

**$foo | for-eachobject {if($_ -eq $false){$bar = $true}}

if($bar){write-host "You are still going to get a PSUseDeclaredVarsMoreThanAssignments error even though you are using the bar variable here."}**


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions