Skip to content

Commit 1185492

Browse files
committed
Standardise ShouldProcess
1 parent 9d8d8fa commit 1185492

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

GitHubTeams.ps1

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,6 @@ function New-GitHubTeam
388388
389389
You can also pipe in a list of GitHub users that were returned from a previous command.
390390
#>
391-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '',
392-
Justification = 'Methods called within here make use of PSShouldProcess, and the switch
393-
is passed on to them inherently.')]
394391
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '',
395392
Justification = 'One or more parameters (like NoStatus) are only referenced by helper
396393
methods which get access to it from the stack via Get-Variable -Scope 1.')]
@@ -498,6 +495,11 @@ function New-GitHubTeam
498495
$hashBody['parent_team_id'] = $team.id
499496
}
500497

498+
if (-not $PSCmdlet.ShouldProcess($TeamName, 'Create GitHub Team'))
499+
{
500+
return
501+
}
502+
501503
$params = @{
502504
UriFragment = $uriFragment
503505
Body = (ConvertTo-Json -InputObject $hashBody)
@@ -568,9 +570,6 @@ filter Set-GitHubTeam
568570
569571
You can also pipe in a GitHub team that was returned from a previous command.
570572
#>
571-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '',
572-
Justification = 'Methods called within here make use of PSShouldProcess, and the switch
573-
is passed on to them inherently.')]
574573
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '',
575574
Justification = 'One or more parameters (like NoStatus) are only referenced by helper
576575
methods which get access to it from the stack via Get-Variable -Scope 1.')]
@@ -647,6 +646,11 @@ filter Set-GitHubTeam
647646
$hashBody['parent_team_id'] = $parentTeam.id
648647
}
649648

649+
if (-not $PSCmdlet.ShouldProcess($TeamName, 'Set GitHub Team'))
650+
{
651+
return
652+
}
653+
650654
$params = @{
651655
UriFragment = $uriFragment
652656
Body = (ConvertTo-Json -InputObject $hashBody)
@@ -715,9 +719,6 @@ filter Remove-GitHubTeam
715719
716720
You can also pipe in a GitHub team that was returned from a previous command.
717721
#>
718-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '',
719-
Justification = 'Methods called within here make use of PSShouldProcess, and the switch
720-
is passed on to them inherently.')]
721722
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '',
722723
Justification = 'One or more parameters (like NoStatus) are only referenced by helper
723724
methods which get access to it from the stack via Get-Variable -Scope 1.')]
@@ -781,23 +782,25 @@ filter Remove-GitHubTeam
781782
$ConfirmPreference = 'None'
782783
}
783784

784-
if ($PSCmdlet.ShouldProcess($TeamName, "Remove Team"))
785+
if (-not $PSCmdlet.ShouldProcess($TeamName, 'Remove Github Team'))
785786
{
786-
Write-InvocationLog
787+
return
788+
}
787789

788-
$params = @{
789-
UriFragment = $uriFragment
790-
Method = 'Delete'
791-
Description = "Deleting $TeamName"
792-
AccessToken = $AccessToken
793-
TelemetryEventName = $MyInvocation.MyCommand.Name
794-
TelemetryProperties = $telemetryProperties
795-
NoStatus = (Resolve-ParameterWithDefaultConfigurationValue `
796-
-Name NoStatus -ConfigValueName DefaultNoStatus)
797-
}
790+
Write-InvocationLog
798791

799-
Invoke-GHRestMethod @params | Out-Null
792+
$params = @{
793+
UriFragment = $uriFragment
794+
Method = 'Delete'
795+
Description = "Deleting $TeamName"
796+
AccessToken = $AccessToken
797+
TelemetryEventName = $MyInvocation.MyCommand.Name
798+
TelemetryProperties = $telemetryProperties
799+
NoStatus = (Resolve-ParameterWithDefaultConfigurationValue `
800+
-Name NoStatus -ConfigValueName DefaultNoStatus)
800801
}
802+
803+
Invoke-GHRestMethod @params | Out-Null
801804
}
802805

803806
filter Add-GitHubTeamAdditionalProperties

0 commit comments

Comments
 (0)