PowerShell / PowerShell/PSScriptAnalyzer

New rule to warn against break/continue outside of loops or traps

Open
#1,507 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area - Rules Issue - New Rule Up-for-Grabs
Dominant language
C#
Stars
2.2k
Forks
414
Avg merge
13h 1m
Merged PRs (30d)
2

Description

From https://github.com/PowerShell/PowerShell/issues/12742.

Today break will take control out of a function and up to the first loop in the callstack, possibly exiting the whole script.

Some existing code depends on this, but it's not a good behaviour.

Ideally a rule should warn about this, since using it break outside a loop or trap is usually a mistake that could seriously affect the program.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files, tests, or entry points are named. Start by locating existing analyzer rules and their tests, then confirm whether the intended scope covers both break and continue and how loop or trap context is identified. Done means the rule warns for the targeted misuse and tests cover the warning behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.