PSSlack
PSSlack copied to clipboard
Private cmdlets use unapproved verbs (PSUseApprovedVerbs)
A number of the private cmdlets are flagged by PSScriptAnalyzer for using an unapproved PowerShell verb:-
RuleName | Severity | ScriptName | Line | Message |
---|---|---|---|---|
PSUseApprovedVerbs | Warning | Color-ToNumber.ps1 | 1 | The cmdlet 'Color-ToNumber' uses an unapproved verb. |
PSUseApprovedVerbs | Warning | Parse-SlackChannel.ps1 | 2 | The cmdlet 'Parse-SlackChannel' uses an unapproved verb. |
PSUseApprovedVerbs | Warning | Parse-SlackGroup.ps1 | 1 | The cmdlet 'Parse-SlackGroup' uses an unapproved verb. |
PSUseApprovedVerbs | Warning | Parse-SlackMessage.ps1 | 2 | The cmdlet 'Parse-SlackMessage' uses an unapproved verb. |
PSUseApprovedVerbs | Warning | Parse-SlackMessage.ps1 | 9 | The cmdlet 'Extract-Previous' uses an unapproved verb. |
PSUseApprovedVerbs | Warning | Parse-SlackTeam.ps1 | 2 | The cmdlet 'Parse-SlackTeam' uses an unapproved verb. |
PSUseApprovedVerbs | Warning | Parse-SlackUser.ps1 | 2 | The cmdlet 'Parse-SlackUser' uses an unapproved verb. |
The easiest way to fix this would be to explicitly suppress the PSUseApprovedVerbs
rule for the Private\Parse-Slack* cmdlets by adding something like the below to each.
[Diagnostics.CodeAnalysis.SuppressMessage("PSUseApprovedVerbs", Scope="function")]
IMO, the cleaner way to fix this would be to rename those cmdlets to use an approved verb.
For the Parse-
cmdlets, ConvertTo-
or New-
may be a suitable candidate from the current list of approved verbs, perhaps coupled with an Object
or Type
suffix (e.g., ConvertTo-SlackTeamObject
),
Thoughts? Is a clean bill of health from PSScriptAnalyzer even worth pursuing?
I feel it's a bit of semantics, however I see your point. Color-ToNumber could become Convert-ColorToNumber, and Extract-Precious could become Export-Previous, but looking at Microsoft's docu on this there really isn't anything that could be interchangeable for Parse. Without looking at what each of those Parse commands do I would assume Get could possibly be used? But as a whole does this really matter besides it would pass some validation tool? Is there confusion with the commands?
https://msdn.microsoft.com/en-us/library/ms714428(v=vs.85).aspx
IMO, the only time I personally leverage PSScriptAnalyzer suppression is for things like Password parameters when the actual use case for the function doesn't really allow something unsafe to be passed there. Resolving the PSScriptAnalyzer messages with approved verbs would be ideal.
Here are my thoughts on best replacements with approved verbs:
Existing | Suggested |
---|---|
Color-ToNumber | Convert-ColorToNumber |
Extract-Previous | Get-Previous |
Parse-SlackChannel | Resolve-SlackChannel |
Parse-SlackGroup | Resolve-SlackGroup |
Parse-SlackMessage | Resolve-SlackMessage |
Parse-SlackTeam | Resolve-SlackTeam |
Parse-SlackUser | Resolve-SlackUser |
Would it be proper to use the "diagnostic" verb Resolve? MS suggests diag verbs are "used to diagnose the health of something." I finally got to look those cmdlets over and ConvertTo might be closer to what I understand those scripts to be doing since it is a PSSlack type they are creating. Maybe?
I'm thinking along the lines of Resolve-Path's behavior and looking at Resolve in that light, although Resolve is technically a diagnostic verb in PowerShell's definition. Maybe it's diagnosing the initial intention? 🙃
Ah, right. Good point. Yeah, totally agree with that. Just wish MS didn't use it like that and create the contradiction and confusion.
Receive-<...>Response
(e.g. Receive-SlackUserResponse
) might be an option as well.