Skip to content

The PSShouldProcess rule is missing a condition when it checks for ShouldProcess/ShouldContinue #194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
KirkMunro opened this issue May 22, 2015 · 0 comments

Comments

@KirkMunro
Copy link
Contributor

When you create an advanced function that uses the SupportsShouldProcess flag in the CmdletBinding attribute, you obviously want to support Confirm/WhatIf scenarios. Given that is the case, at a glance it appears to make sense to check to see if ShouldProcess/ShouldContinue are used in these functions; however, functions very often are nothing more than a wrapper around one or more PowerShell commands that they invoke internally.

If the commands invoked by a function support ShouldProcess as well, as they very often do, then in practice you don't really need to call ShouldProcess/ShouldContinue much at all. Sometimes it makes sense to do so, depending on the logic inside of the function, but often times you simply don't need it because the commands you invoke have that covered already.

Therefore, the PSShouldProcess rule should only ever raise a warning when the function where it is used does not invoke ShouldProcess/ShouldContinue AND when the function where it is used does not contain any other commands that support ShouldProcess. Otherwise you're just guessing and, in the case of many of my own modules, you're guessing incorrectly and creating noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants