PowerShell / PowerShell/PSScriptAnalyzer

PSShouldProcess Rule and module specific adaption

Open
#1,078 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Scenario

One of the default rules checks, whether a command that supports should process, actually uses ...

$PSCmdlet.ShouldProcess( ... )

Now, this is a great rule in principle, but in the framework module I maintain (https://psframework.org) I've got a cmdlet that replaces that method call (for readability and mocking reasons).

My current solution is to disable the specific script analyzer rule (PSShouldProcess) in my automatic tests. Which works well enough for my purposes.
But it would be more awesome if it were to detect the command and equate it with the method call (cause I'd actually appreciate having that check enabled, if it were practical).

Creating my own rule wouldn't be a problem, so my own projects would be covered. But since I'm trying to distribute this to others - with increasing success - distributing the custom rule to their tests would be ... inconvenient outside of PSScriptAnalyzer.

Questions

What's the policy on changes to rules that are module specific?

If I write that update, would it even be considered?

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

Start with the PSShouldProcess rule and the automatic tests described in the issue; no source file or test path is named. Done would require a concrete policy for module-specific command equivalents and an agreed implementation scope, followed by tests showing the rule handles the proposed adaptation.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.