Skip to content

Commit f262b52

Browse files
committed
Standardise ShouldProcess
1 parent 34a1abf commit f262b52

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
@@ -394,9 +394,6 @@ function New-GitHubTeam
394394
395395
You can also pipe in a list of GitHub users that were returned from a previous command.
396396
#>
397-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '',
398-
Justification = 'Methods called within here make use of PSShouldProcess, and the switch
399-
is passed on to them inherently.')]
400397
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '',
401398
Justification = 'One or more parameters (like NoStatus) are only referenced by helper
402399
methods which get access to it from the stack via Get-Variable -Scope 1.')]
@@ -504,6 +501,11 @@ function New-GitHubTeam
504501
$hashBody['parent_team_id'] = $team.id
505502
}
506503

504+
if (-not $PSCmdlet.ShouldProcess($TeamName, 'Create GitHub Team'))
505+
{
506+
return
507+
}
508+
507509
$params = @{
508510
UriFragment = $uriFragment
509511
Body = (ConvertTo-Json -InputObject $hashBody)
@@ -574,9 +576,6 @@ filter Set-GitHubTeam
574576
575577
You can also pipe in a GitHub team that was returned from a previous command.
576578
#>
577-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '',
578-
Justification = 'Methods called within here make use of PSShouldProcess, and the switch
579-
is passed on to them inherently.')]
580579
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '',
581580
Justification = 'One or more parameters (like NoStatus) are only referenced by helper
582581
methods which get access to it from the stack via Get-Variable -Scope 1.')]
@@ -653,6 +652,11 @@ filter Set-GitHubTeam
653652
$hashBody['parent_team_id'] = $parentTeam.id
654653
}
655654

655+
if (-not $PSCmdlet.ShouldProcess($TeamName, 'Set GitHub Team'))
656+
{
657+
return
658+
}
659+
656660
$params = @{
657661
UriFragment = $uriFragment
658662
Body = (ConvertTo-Json -InputObject $hashBody)
@@ -721,9 +725,6 @@ filter Remove-GitHubTeam
721725
722726
You can also pipe in a GitHub team that was returned from a previous command.
723727
#>
724-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '',
725-
Justification = 'Methods called within here make use of PSShouldProcess, and the switch
726-
is passed on to them inherently.')]
727728
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '',
728729
Justification = 'One or more parameters (like NoStatus) are only referenced by helper
729730
methods which get access to it from the stack via Get-Variable -Scope 1.')]
@@ -787,23 +788,25 @@ filter Remove-GitHubTeam
787788
$ConfirmPreference = 'None'
788789
}
789790

790-
if ($PSCmdlet.ShouldProcess($TeamName, "Remove Team"))
791+
if (-not $PSCmdlet.ShouldProcess($TeamName, 'Remove Github Team'))
791792
{
792-
Write-InvocationLog
793+
return
794+
}
793795

794-
$params = @{
795-
UriFragment = $uriFragment
796-
Method = 'Delete'
797-
Description = "Deleting $TeamName"
798-
AccessToken = $AccessToken
799-
TelemetryEventName = $MyInvocation.MyCommand.Name
800-
TelemetryProperties = $telemetryProperties
801-
NoStatus = (Resolve-ParameterWithDefaultConfigurationValue `
802-
-Name NoStatus -ConfigValueName DefaultNoStatus)
803-
}
796+
Write-InvocationLog
804797

805-
Invoke-GHRestMethod @params | Out-Null
798+
$params = @{
799+
UriFragment = $uriFragment
800+
Method = 'Delete'
801+
Description = "Deleting $TeamName"
802+
AccessToken = $AccessToken
803+
TelemetryEventName = $MyInvocation.MyCommand.Name
804+
TelemetryProperties = $telemetryProperties
805+
NoStatus = (Resolve-ParameterWithDefaultConfigurationValue `
806+
-Name NoStatus -ConfigValueName DefaultNoStatus)
806807
}
808+
809+
Invoke-GHRestMethod @params | Out-Null
807810
}
808811

809812
filter Add-GitHubTeamAdditionalProperties

0 commit comments

Comments
 (0)