PowerShell / PowerShell/PSScriptAnalyzer

Feature request: Mark specific lines or blocks to ignore for specific rules

Open
#849 25 comments 49 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue - Enhancement
Dominant language
C#
Stars
2.2k
Forks
414
Avg merge
13h 1m
Merged PRs (30d)
2

Description

Like pragma in c# can disable a warning for a line and then enable it again.

As an example, I've got a few variables that are used to within Invoke-Expression's, and the script analyzer flags them as unused variables but they are actually used. I dont want to ignore the rule for the entire script, just these few variables.

Is there a way to do this?

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

The issue requests rule-specific suppression for individual PowerShell lines or blocks, especially variables used within Invoke-Expression. No files, tests, or entry points are named; begin by locating the existing rule-suppression behavior and determine how line and block scope should be represented. Done should include suppression for selected rules without disabling those rules for the entire script.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.