PowerShell / PowerShell/PSScriptAnalyzer

The rule PSUseShouldProcessForStateChangingFunctions is far too simple

Open
#283 9 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

You can't determine if a command is "State Changing" based purely on the verb. This is the sort of stuff that makes me SO upset at this module that I just want to throw it out -- it takes too much time to go through and review stuff when most of the warnings/errors are wrong.

For one example, I'm getting that warning on a bunch of XML document commands like "New-XElement" and "New-XAttribute" which obviously don't modify system state, they just create xml nodes and attributes which can at least hypothetically be added to a document in memory.

For another example, almost every single command in the ShowUI module uses the "New" verb to generate UI elements on windows, not to modify the system state.

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 by reviewing the PSUseShouldProcessForStateChangingFunctions rule and the reported cases New-XElement, New-XAttribute, and ShowUI commands. Determine how the rule should distinguish commands that create in-memory XML or UI elements from commands that change system state, then add coverage showing that the false-positive warnings are gone.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.