Skip to content

Rule Request: UnknownLabel #2145

Description

@iRon7

Not sure whether this is a PowerShell a bug or feature but fixing it in PowerShell would probably be a break change.

In any case, I think unknown labels should be notified and even deserve an error severity if the label doesn't exist or is outside the concerned loop.

Invoke-ScriptAnalyzer -ScriptDefinition {
    :foo foreach ($a in 1,2,3) {
        $a
        if ($a -ge $b) { break bar }
    }
}.ToString()

Expected
Something like:

RuleName           Severity     ScriptName Line  Message
--------           --------     ---------- ----  -------
PSUnknownLabel     Error                   4     The label 'bar' is not known in this context

See also: Pester breaks on functions with unknown label

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions