Comments (9)
Feature Team - Triaged - Approved
from psscriptanalyzer.
Should this rule only be applied to exported functions? There should be cases where helper functions contain these verbs in their function definition?
from psscriptanalyzer.
I was thinking maybe this should apply to function that has CmdletBinding property in the parameter?
from psscriptanalyzer.
Correct. Any function that supports cmdlet-style parameter binding needs to have this rule.
from psscriptanalyzer.
Also, ShouldProcess applies to -whatif and -confirm parameters
"Another pair of common parameters is -whatif and -confirm. Any cmdlet that makes some kind of change to the computer is supposed to recognize those. They give you the option of having the cmdlet display what it would normally do (-whatif), or have it individually confirm each action (-confirm). "
There is a good technet article on this:
https://technet.microsoft.com/en-us/magazine/ff677563.aspx
from psscriptanalyzer.
So the implementation should be: if a function definition has Verbs that change system status and has CmdletBinding property in the parameter, we should make sure it also include these two attributes:ShouldProcess and ConfirmImpact.
from psscriptanalyzer.
I think that sounds good
from psscriptanalyzer.
Sorry, I don't think "ConfirmImpact" should be mandatory here."ShouldProcess" is required but "ConfirmImpact" should be optional in this case.
According to MSDN:
"To support confirmation requests, the cmdlet must set the SupportsShouldProcess parameter of the Cmdlet attribute to true. This enables the Confirm and WhatIf cmdlet parameters that are provided by Windows PowerShell."
"For most cmdlets, you do not have to explicitly specify ConfirmImpact. Instead, use the default setting of the parameter, which is Medium. If you set ConfirmImpact to High, the operation will be confirmed by default. Reserve this setting for highly disruptive actions, such as reformatting a hard-disk volume."
from psscriptanalyzer.
New Rule UseShouldProcessForStateChangingFunctions added (4/17).
from psscriptanalyzer.
Related Issues (20)
- Invoke-Formatter - Custom rules? HOT 1
- Always return a `RuleSuppressionID` HOT 2
- Linux Build for PSScriptAnalyzer Module HOT 2
- Missing approved verbs HOT 3
- Rules for Rules HOT 1
- Halo HOT 1
- Add a pre-commit hook for psscriptanalyzer HOT 2
- PSAvoidAssignmentToAutomaticVariable Errors on validateset HOT 4
- Rule PSReservedParams generates Warning instead of Error HOT 2
- Revert or Redo PossibleIncorrectUsageOfRedirectionOperator HOT 1
- Indentation breaks using anything other than pipelineIndentationStyle: None using a second pipe within parenthesis HOT 3
- Proposal: Signal invalid syntax in switch statement condition HOT 2
- Adds whitespace around operators with `whitespaceAroundOperator` set to false in some cases HOT 3
- Include release asset for v1.22.0 HOT 3
- Testing PSSA Warning Rules.PSUseLiteralInitializerForHashtable HOT 2
- add warning or error when using bigint with floating point types HOT 1
- The PSAvoidTrailingWhitespace rule is not applied when using Invoke-Formatter HOT 6
- Unable to format document in special circumstances HOT 7
- Rule request: `AvoidSecureStringDisclosure` HOT 2
- Rule request: Use Ascii HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from psscriptanalyzer.