diff --git a/GitHubAnalytics.ps1 b/GitHubAnalytics.ps1 index 955dae4d..e4bba220 100644 --- a/GitHubAnalytics.ps1 +++ b/GitHubAnalytics.ps1 @@ -37,6 +37,7 @@ function Group-GitHubIssue SupportsShouldProcess, DefaultParameterSetName='Weekly')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="DateType due to PowerShell/PSScriptAnalyzer#1472")] param ( [Parameter( @@ -55,41 +56,68 @@ function Group-GitHubIssue [string] $DateType = 'Created' ) - Write-InvocationLog - - if ($PSCmdlet.ParameterSetName -eq 'Weekly') + begin { - $totalIssues = 0 - $weekDates = Get-WeekDate -Weeks $Weeks - $endOfWeek = Get-Date + Write-InvocationLog - foreach ($week in $weekDates) + if ($PSCmdlet.ParameterSetName -eq 'Weekly') { - $filteredIssues = @($Issue | Where-Object { - (($DateType -eq 'Created') -and ($_.created_at -ge $week) -and ($_.created_at -le $endOfWeek)) -or - (($DateType -eq 'Closed') -and ($_.closed_at -ge $week) -and ($_.closed_at -le $endOfWeek)) - }) - - $endOfWeek = $week - $count = $filteredIssues.Count - $totalIssues += $count - - Write-Output -InputObject ([PSCustomObject]([ordered]@{ - 'WeekStart' = $week - 'Count' = $count - 'Issues' = $filteredIssues + $weekDates = Get-WeekDate -Weeks $Weeks + + $result = [ordered]@{} + foreach ($week in $weekDates) + { + $result[$week] = ([PSCustomObject]([ordered]@{ + 'WeekStart' = $week + 'Count' = 0 + 'Issues' = @() + })) + } + + $result['total'] = ([PSCustomObject]([ordered]@{ + 'WeekStart' = 'total' + 'Count' = 0 + 'Issues' = @() })) } + } - Write-Output -InputObject ([PSCustomObject]([ordered]@{ - 'WeekStart' = 'total' - 'Count' = $totalIssues - 'Issues' = $Issue - })) + process + { + if ($PSCmdlet.ParameterSetName -eq 'Weekly') + { + $endOfWeek = Get-Date + foreach ($week in $weekDates) + { + $filteredIssues = @($Issue | Where-Object { + (($DateType -eq 'Created') -and ($_.created_at -ge $week) -and ($_.created_at -le $endOfWeek)) -or + (($DateType -eq 'Closed') -and ($_.closed_at -ge $week) -and ($_.closed_at -le $endOfWeek)) + }) + + $endOfWeek = $week + + $result[$week].Issues += $filteredIssues + $result[$week].Count += ($filteredIssues.Count) + + $result['total'].Issues += $filteredIssues + $result['total'].Count += ($filteredIssues.Count) + } + } + else + { + Write-Output -InputObject $Issue + } } - else + + end { - Write-Output -InputObject $Issue + if ($PSCmdlet.ParameterSetName -eq 'Weekly') + { + foreach ($entry in $result.Values.GetEnumerator()) + { + Write-Output -InputObject $entry + } + } } } @@ -130,6 +158,7 @@ function Group-GitHubPullRequest SupportsShouldProcess, DefaultParameterSetName='Weekly')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="DateType due to PowerShell/PSScriptAnalyzer#1472")] param ( [Parameter( @@ -148,41 +177,68 @@ function Group-GitHubPullRequest [string] $DateType = 'Created' ) - Write-InvocationLog - - if ($PSCmdlet.ParameterSetName -eq 'Weekly') + begin { - $totalPullRequests = 0 - $weekDates = Get-WeekDate -Weeks $Weeks - $endOfWeek = Get-Date + Write-InvocationLog - foreach ($week in $weekDates) + if ($PSCmdlet.ParameterSetName -eq 'Weekly') { - $filteredPullRequests = @($PullRequest | Where-Object { - (($DateType -eq 'Created') -and ($_.created_at -ge $week) -and ($_.created_at -le $endOfWeek)) -or - (($DateType -eq 'Merged') -and ($_.merged_at -ge $week) -and ($_.merged_at -le $endOfWeek)) - }) - - $endOfWeek = $week - $count = $filteredPullRequests.Count - $totalPullRequests += $count - - Write-Output -InputObject ([PSCustomObject]([ordered]@{ - 'WeekStart' = $week - 'Count' = $count - 'PullRequests' = $filteredPullRequests + $weekDates = Get-WeekDate -Weeks $Weeks + + $result = [ordered]@{} + foreach ($week in $weekDates) + { + $result[$week] = ([PSCustomObject]([ordered]@{ + 'WeekStart' = $week + 'Count' = 0 + 'PullRequests' = @() + })) + } + + $result['total'] = ([PSCustomObject]([ordered]@{ + 'WeekStart' = 'total' + 'Count' = 0 + 'PullRequests' = @() })) } + } - Write-Output -InputObject ([PSCustomObject]([ordered]@{ - 'WeekStart' = 'total' - 'Count' = $totalPullRequests - 'PullRequests' = $PullRequest - })) + process + { + if ($PSCmdlet.ParameterSetName -eq 'Weekly') + { + $endOfWeek = Get-Date + foreach ($week in $weekDates) + { + $filteredPullRequests = @($PullRequest | Where-Object { + (($DateType -eq 'Created') -and ($_.created_at -ge $week) -and ($_.created_at -le $endOfWeek)) -or + (($DateType -eq 'Merged') -and ($_.merged_at -ge $week) -and ($_.merged_at -le $endOfWeek)) + }) + + $endOfWeek = $week + + $result[$week].PullRequests += $filteredPullRequests + $result[$week].Count += ($filteredPullRequests.Count) + + $result['total'].PullRequests += $filteredPullRequests + $result['total'].Count += ($filteredPullRequests.Count) + } + } + else + { + Write-Output -InputObject $PullRequest + } } - else + + end { - Write-Output -InputObject $PullRequest + if ($PSCmdlet.ParameterSetName -eq 'Weekly') + { + foreach ($entry in $result.Values.GetEnumerator()) + { + Write-Output -InputObject $entry + } + } } } diff --git a/GitHubAssignees.ps1 b/GitHubAssignees.ps1 index ad29002d..f88ce789 100644 --- a/GitHubAssignees.ps1 +++ b/GitHubAssignees.ps1 @@ -41,6 +41,7 @@ function Get-GitHubAssignee SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, @@ -128,6 +129,7 @@ function Test-GitHubAssignee DefaultParameterSetName='Elements')] [OutputType([bool])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, @@ -228,6 +230,7 @@ function New-GithubAssignee SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, @@ -330,6 +333,7 @@ function Remove-GithubAssignee SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, diff --git a/GitHubBranches.ps1 b/GitHubBranches.ps1 index d73075a5..3770c436 100644 --- a/GitHubBranches.ps1 +++ b/GitHubBranches.ps1 @@ -55,6 +55,7 @@ function Get-GitHubRepositoryBranch SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] [Alias('Get-GitHubBranch')] param( [Parameter(ParameterSetName='Elements')] diff --git a/GitHubComments.ps1 b/GitHubComments.ps1 index f56a2e16..82aef916 100644 --- a/GitHubComments.ps1 +++ b/GitHubComments.ps1 @@ -244,6 +244,7 @@ function New-GitHubComment SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, @@ -355,6 +356,7 @@ function Set-GitHubComment SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, @@ -456,6 +458,7 @@ function Remove-GitHubComment DefaultParameterSetName='Elements')] [Alias('Delete-GitHubComment')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, diff --git a/GitHubCore.ps1 b/GitHubCore.ps1 index 485ce381..2bf3f185 100644 --- a/GitHubCore.ps1 +++ b/GitHubCore.ps1 @@ -612,6 +612,7 @@ function Invoke-GHRestMethodMultipleResult #> [CmdletBinding(SupportsShouldProcess)] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] [OutputType([Object[]])] param( [Parameter(Mandatory)] diff --git a/GitHubIssues.ps1 b/GitHubIssues.ps1 index 74ea3973..c12aefd6 100644 --- a/GitHubIssues.ps1 +++ b/GitHubIssues.ps1 @@ -378,6 +378,7 @@ function Get-GitHubIssueTimeline SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, @@ -861,6 +862,7 @@ function Unlock-GitHubIssue SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, diff --git a/GitHubLabels.ps1 b/GitHubLabels.ps1 index 47ab1c73..172361e7 100644 --- a/GitHubLabels.ps1 +++ b/GitHubLabels.ps1 @@ -206,6 +206,7 @@ function New-GitHubLabel SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, @@ -320,6 +321,7 @@ function Remove-GitHubLabel SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] [Alias('Delete-GitHubLabel')] param( [Parameter(ParameterSetName='Elements')] @@ -551,6 +553,7 @@ function Set-GitHubLabel SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, @@ -662,6 +665,7 @@ function Add-GitHubIssueLabel SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(Mandatory, ParameterSetName='Elements')] [string] $OwnerName, @@ -763,6 +767,7 @@ function Set-GitHubIssueLabel SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, diff --git a/GitHubMilestones.ps1 b/GitHubMilestones.ps1 index 05a3055f..c67ecef7 100644 --- a/GitHubMilestones.ps1 +++ b/GitHubMilestones.ps1 @@ -506,6 +506,7 @@ function Remove-GitHubMilestone DefaultParameterSetName='Elements')] [Alias('Delete-GitHubMilestone')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(Mandatory, ParameterSetName='Elements')] [string] $OwnerName, diff --git a/GitHubMiscellaneous.ps1 b/GitHubMiscellaneous.ps1 index aaba73c4..28e9d08d 100644 --- a/GitHubMiscellaneous.ps1 +++ b/GitHubMiscellaneous.ps1 @@ -53,6 +53,7 @@ function Get-GitHubRateLimit #> [CmdletBinding(SupportsShouldProcess)] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [string] $AccessToken, @@ -119,6 +120,7 @@ function ConvertFrom-GitHubMarkdown #> [CmdletBinding(SupportsShouldProcess)] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter( Mandatory, @@ -137,36 +139,42 @@ function ConvertFrom-GitHubMarkdown [switch] $NoStatus ) - Write-InvocationLog + begin + { + Write-InvocationLog - $telemetryProperties = @{ - 'Mode' = $Mode - } + $telemetryProperties = @{ + 'Mode' = $Mode + } - $modeConverter = @{ - 'Markdown' = 'markdown' - 'GitHubFlavoredMarkdown' = 'gfm' + $modeConverter = @{ + 'Markdown' = 'markdown' + 'GitHubFlavoredMarkdown' = 'gfm' + } } - $hashBody = @{ - 'text' = $Content - 'mode' = $modeConverter[$Mode] - } - - if (-not [String]::IsNullOrEmpty($Context)) { $hashBody['context'] = $Context } - - $params = @{ - 'UriFragment' = 'markdown' - 'Body' = (ConvertTo-Json -InputObject $hashBody) - 'Method' = 'Post' - 'Description' = "Converting Markdown to HTML" - 'AccessToken' = $AccessToken - 'TelemetryEventName' = $MyInvocation.MyCommand.Name - 'TelemetryProperties' = $telemetryProperties - 'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -Name NoStatus -ConfigValueName DefaultNoStatus) + process + { + $hashBody = @{ + 'text' = $Content + 'mode' = $modeConverter[$Mode] + } + + if (-not [String]::IsNullOrEmpty($Context)) { $hashBody['context'] = $Context } + + $params = @{ + 'UriFragment' = 'markdown' + 'Body' = (ConvertTo-Json -InputObject $hashBody) + 'Method' = 'Post' + 'Description' = "Converting Markdown to HTML" + 'AccessToken' = $AccessToken + 'TelemetryEventName' = $MyInvocation.MyCommand.Name + 'TelemetryProperties' = $telemetryProperties + 'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -Name NoStatus -ConfigValueName DefaultNoStatus) + } + + Write-Output -InputObject (Invoke-GHRestMethod @params) } - - return Invoke-GHRestMethod @params } function Get-GitHubLicense @@ -318,6 +326,7 @@ function Get-GitHubEmoji #> [CmdletBinding(SupportsShouldProcess)] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [string] $AccessToken, diff --git a/GitHubOrganizations.ps1 b/GitHubOrganizations.ps1 index fd5e6165..db2073ba 100644 --- a/GitHubOrganizations.ps1 +++ b/GitHubOrganizations.ps1 @@ -32,6 +32,7 @@ function Get-GitHubOrganizationMember Get-GitHubOrganizationMember -OrganizationName PowerShell #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] [CmdletBinding(SupportsShouldProcess)] param ( @@ -96,6 +97,7 @@ function Test-GitHubOrganizationMember Test-GitHubOrganizationMember -OrganizationName PowerShell -UserName Octocat #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] [CmdletBinding(SupportsShouldProcess)] [OutputType([bool])] param diff --git a/GitHubProjectCards.ps1 b/GitHubProjectCards.ps1 index 33395df2..86ea7988 100644 --- a/GitHubProjectCards.ps1 +++ b/GitHubProjectCards.ps1 @@ -166,8 +166,8 @@ function New-GitHubProjectCard SupportsShouldProcess, DefaultParameterSetName = 'Note')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification = "Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( - [Parameter(Mandatory)] [int64] $Column, @@ -371,6 +371,7 @@ function Remove-GitHubProjectCard ConfirmImpact = 'High')] [Alias('Delete-GitHubProjectCard')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification = "Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(Mandatory)] [int64] $Card, diff --git a/GitHubProjectColumns.ps1 b/GitHubProjectColumns.ps1 index bb178d0c..c1e84173 100644 --- a/GitHubProjectColumns.ps1 +++ b/GitHubProjectColumns.ps1 @@ -39,6 +39,7 @@ function Get-GitHubProjectColumn SupportsShouldProcess, DefaultParameterSetName = 'Project')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification = "Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(Mandatory, ParameterSetName = 'Project')] [int64] $Project, @@ -118,6 +119,7 @@ function New-GitHubProjectColumn [CmdletBinding( SupportsShouldProcess)] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification = "Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(Mandatory)] @@ -190,6 +192,7 @@ function Set-GitHubProjectColumn [CmdletBinding( SupportsShouldProcess)] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification = "Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(Mandatory)] [int64] $Column, @@ -264,6 +267,7 @@ function Remove-GitHubProjectColumn ConfirmImpact = 'High')] [Alias('Delete-GitHubProjectColumn')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification = "Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(Mandatory)] [int64] $Column, @@ -346,6 +350,7 @@ function Move-GitHubProjectColumn [CmdletBinding( SupportsShouldProcess)] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification = "Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(Mandatory)] [int64] $Column, diff --git a/GitHubProjects.ps1 b/GitHubProjects.ps1 index 8c60d22f..df4ecc50 100644 --- a/GitHubProjects.ps1 +++ b/GitHubProjects.ps1 @@ -477,6 +477,7 @@ function Remove-GitHubProject ConfirmImpact = 'High')] [Alias('Delete-GitHubProject')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification = "Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(Mandatory)] [int64] $Project, diff --git a/GitHubRepositoryForks.ps1 b/GitHubRepositoryForks.ps1 index 212a316a..f50b2af9 100644 --- a/GitHubRepositoryForks.ps1 +++ b/GitHubRepositoryForks.ps1 @@ -47,6 +47,7 @@ function Get-GitHubRepositoryFork SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, diff --git a/GitHubRepositoryTraffic.ps1 b/GitHubRepositoryTraffic.ps1 index c72d031b..c27ab1be 100644 --- a/GitHubRepositoryTraffic.ps1 +++ b/GitHubRepositoryTraffic.ps1 @@ -44,6 +44,7 @@ function Get-GitHubReferrerTraffic SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, @@ -128,6 +129,7 @@ function Get-GitHubPathTraffic SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, @@ -216,6 +218,7 @@ function Get-GitHubViewTraffic SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, @@ -308,6 +311,7 @@ function Get-GitHubCloneTraffic SupportsShouldProcess, DefaultParameterSetName='Elements')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='Elements')] [string] $OwnerName, diff --git a/GitHubTeams.ps1 b/GitHubTeams.ps1 index 039825b4..6c27c294 100644 --- a/GitHubTeams.ps1 +++ b/GitHubTeams.ps1 @@ -48,6 +48,7 @@ function Get-GitHubTeam Get-GitHubTeam -OrganizationName PowerShell #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] [CmdletBinding( SupportsShouldProcess, DefaultParameterSetName='Elements')] diff --git a/GitHubUsers.ps1 b/GitHubUsers.ps1 index e6465e67..3a77bca4 100644 --- a/GitHubUsers.ps1 +++ b/GitHubUsers.ps1 @@ -57,6 +57,7 @@ function Get-GitHubUser SupportsShouldProcess, DefaultParameterSetName='ListAndSearch')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(ParameterSetName='ListAndSearch')] [string] $User, @@ -129,6 +130,7 @@ function Get-GitHubUserContextualInformation #> [CmdletBinding(SupportsShouldProcess)] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")] param( [Parameter(Mandatory)] [string] $User, diff --git a/Helpers.ps1 b/Helpers.ps1 index c22c54ec..1813d168 100644 --- a/Helpers.ps1 +++ b/Helpers.ps1 @@ -262,6 +262,7 @@ function Write-Log [CmdletBinding(SupportsShouldProcess)] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidGlobalVars", "", Justification="We need to be able to access the PID for logging purposes, and it is accessed via a global variable.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidOverwritingBuiltInCmdlets", "", Justification="Write-Log is an internal function being incorrectly exported by PSDesiredStateConfiguration. See PowerShell/PowerShell#7209")] param( [Parameter(ValueFromPipeline)] [AllowEmptyCollection()] @@ -618,19 +619,27 @@ function Write-InteractiveHost [System.ConsoleColor] $BackgroundColor ) - # Determine if the host is interactive - if ([Environment]::UserInteractive -and ` - ![Bool]([Environment]::GetCommandLineArgs() -like '-noni*') -and ` - (Get-Host).Name -ne 'Default Host') + begin { - # Special handling for OutBuffer (generated for the proxy function) - $outBuffer = $null - if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) + $hostIsInteractive = ([Environment]::UserInteractive -and + ![Bool]([Environment]::GetCommandLineArgs() -like '-noni*') -and + ((Get-Host).Name -ne 'Default Host')) + } + + process + { + # Determine if the host is interactive + if ($hostIsInteractive) { - $PSBoundParameters['OutBuffer'] = 1 - } + # Special handling for OutBuffer (generated for the proxy function) + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) + { + $PSBoundParameters['OutBuffer'] = 1 + } - Write-Host @PSBoundParameters + Write-Host @PSBoundParameters + } } } @@ -679,15 +688,18 @@ function Resolve-UnverifiedPath [string] $Path ) - $resolvedPath = Resolve-Path -Path $Path -ErrorVariable resolvePathError -ErrorAction SilentlyContinue - - if ($null -eq $resolvedPath) + process { - return $resolvePathError[0].TargetObject - } - else - { - return $resolvedPath.ProviderPath + $resolvedPath = Resolve-Path -Path $Path -ErrorVariable resolvePathError -ErrorAction SilentlyContinue + + if ($null -eq $resolvedPath) + { + Write-Output -InputObject ($resolvePathError[0].TargetObject) + } + else + { + Write-Output -InputObject ($resolvedPath.ProviderPath) + } } } diff --git a/NugetTools.ps1 b/NugetTools.ps1 index fbc7dd8b..3c6755f7 100644 --- a/NugetTools.ps1 +++ b/NugetTools.ps1 @@ -82,9 +82,7 @@ function Get-NugetPackage #> [CmdletBinding(SupportsShouldProcess)] param( - [Parameter( - Mandatory, - ValueFromPipeline)] + [Parameter(Mandatory)] [string] $PackageName, [Parameter(Mandatory)] diff --git a/PowerShellForGitHub.psd1 b/PowerShellForGitHub.psd1 index 35ba76fa..7bcec540 100644 --- a/PowerShellForGitHub.psd1 +++ b/PowerShellForGitHub.psd1 @@ -92,6 +92,7 @@ 'Get-GitHubUserContextualInformation', 'Get-GitHubViewTraffic', 'Group-GitHubIssue', + 'Group-GitHubPullRequest', 'Invoke-GHRestMethod', 'Invoke-GHRestMethodMultipleResult', 'Lock-GitHubIssue', diff --git a/Tests/GitHubProjectCards.tests.ps1 b/Tests/GitHubProjectCards.tests.ps1 index 0b286e8b..e7a571d9 100644 --- a/Tests/GitHubProjectCards.tests.ps1 +++ b/Tests/GitHubProjectCards.tests.ps1 @@ -41,7 +41,12 @@ try $card = New-GitHubProjectCard -Column $column.id -Note $defaultCard $cardArchived = New-GitHubProjectCard -Column $column.id -Note $defaultArchivedCard $null = Set-GitHubProjectCard -Card $cardArchived.id -Archive + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $card = $card + $cardArchived = $cardArchived } + AfterAll { $null = Remove-GitHubProjectCard -Card $card.id -Confirm:$false } @@ -85,7 +90,13 @@ try $card = New-GitHubProjectCard -Column $column.id -Note $defaultCard $cardTwo = New-GitHubProjectCard -Column $column.id -Note $defaultCardTwo $cardArchived = New-GitHubProjectCard -Column $column.id -Note $defaultArchivedCard + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $card = $card + $cardTwo = $cardTwo + $cardArchived = $cardArchived } + AfterAll { $null = Remove-GitHubProjectCard -Card $card.id -Confirm:$false } @@ -167,7 +178,11 @@ try Context 'Create project card with note' { BeforeAll { $card = @{id = 0} + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $card = $card } + AfterAll { $null = Remove-GitHubProjectCard -Card $card.id -Confirm:$false Remove-Variable -Name card @@ -188,7 +203,11 @@ try Context 'Create project card from issue' { BeforeAll { $card = @{id = 0} + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $card = $card } + AfterAll { $null = Remove-GitHubProjectCard -Card $card.id -Confirm:$false Remove-Variable -Name card @@ -211,6 +230,9 @@ try Context 'Remove card' { BeforeAll { $card = New-GitHubProjectCard -Column $column.id -Note $defaultCard + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $card = $card } $null = Remove-GitHubProjectCard -Card $card.id -Confirm:$false diff --git a/Tests/GitHubProjectColumns.tests.ps1 b/Tests/GitHubProjectColumns.tests.ps1 index 7ba99041..2adf2a26 100644 --- a/Tests/GitHubProjectColumns.tests.ps1 +++ b/Tests/GitHubProjectColumns.tests.ps1 @@ -27,7 +27,11 @@ try Describe 'Getting Project Columns' { BeforeAll { $column = New-GitHubProjectColumn -Project $project.id -Name $defaultColumn + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $column = $column } + AfterAll { $null = Remove-GitHubProjectColumn -Column $column.id -Confirm:$false } @@ -48,7 +52,12 @@ try BeforeAll { $column = New-GitHubProjectColumn -Project $project.id -Name $defaultColumn $columntwo = New-GitHubProjectColumn -Project $project.id -Name $defaultColumnTwo + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $column = $column + $columnTwo = $columnTwo } + AfterAll { $null = Remove-GitHubProjectColumn -Column $column.id -Confirm:$false $null = Remove-GitHubProjectColumn -Column $columntwo.id -Confirm:$false @@ -96,7 +105,11 @@ try Context 'Create project column' { BeforeAll { $column = @{id = 0} + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $column = $column } + AfterAll { $null = Remove-GitHubProjectColumn -Column $column.id -Confirm:$false Remove-Variable -Name column @@ -119,6 +132,9 @@ try Context 'Remove project column' { BeforeAll { $column = New-GitHubProjectColumn -Project $project.id -Name $defaultColumn + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $column = $column } $null = Remove-GitHubProjectColumn -Column $column.id -Confirm:$false diff --git a/Tests/GitHubProjects.tests.ps1 b/Tests/GitHubProjects.tests.ps1 index 6674a3e2..1ae123b8 100644 --- a/Tests/GitHubProjects.tests.ps1 +++ b/Tests/GitHubProjects.tests.ps1 @@ -35,11 +35,14 @@ try $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit Describe 'Getting Project' { - Context 'Get User projects' { BeforeAll { $project = New-GitHubProject -UserProject -Name $defaultUserProject -Description $defaultUserProjectDesc + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $project = $project } + AfterAll { $null = Remove-GitHubProject -Project $project.id -Confirm:$false } @@ -61,7 +64,11 @@ try Context 'Get Organization projects' { BeforeAll { $project = New-GitHubProject -OrganizationName $script:organizationName -Name $defaultOrgProject -Description $defaultOrgProjectDesc + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $project = $project } + AfterAll { $null = Remove-GitHubProject -Project $project.id -Confirm:$false } @@ -83,7 +90,11 @@ try Context 'Get Repo projects' { BeforeAll { $project = New-GitHubProject -OwnerName $script:ownerName -RepositoryName $repo.name -Name $defaultRepoProject -Description $defaultRepoProjectDesc + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $project = $project } + AfterAll { $null = Remove-GitHubProject -Project $project.id -Confirm:$false } @@ -106,7 +117,11 @@ try BeforeAll { $project = New-GitHubProject -OwnerName $script:ownerName -RepositoryName $repo.name -Name $defaultProjectClosed -Description $defaultProjectClosedDesc $null = Set-GitHubProject -Project $project.id -State Closed + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $project = $project } + AfterAll { $null = Remove-GitHubProject -Project $project.id -Confirm:$false } @@ -134,7 +149,11 @@ try Context 'Modify User projects' { BeforeAll { $project = New-GitHubProject -UserProject -Name $defaultUserProject -Description $defaultUserProjectDesc + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $project = $project } + AfterAll { $null = Remove-GitHubProject -Project $project.id -Confirm:$false } @@ -157,7 +176,11 @@ try Context 'Modify Organization projects' { BeforeAll { $project = New-GitHubProject -OrganizationName $script:organizationName -Name $defaultOrgProject -Description $defaultOrgProjectDesc + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $project = $project } + AfterAll { $null = Remove-GitHubProject -Project $project.id -Confirm:$false } @@ -189,7 +212,11 @@ try Context 'Modify Repo projects' { BeforeAll { $project = New-GitHubProject -OwnerName $script:ownerName -RepositoryName $repo.name -Name $defaultRepoProject -Description $defaultRepoProjectDesc + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $project = $project } + AfterAll { $null = Remove-GitHubProject -Project $project.id -Confirm:$false } @@ -214,7 +241,11 @@ try Context 'Create User projects' { BeforeAll { $project = @{id = 0} + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $project = $project } + AfterAll { $null = Remove-GitHubProject -Project $project.id -Confirm:$false Remove-Variable project @@ -238,7 +269,11 @@ try Context 'Create Organization projects' { BeforeAll { $project = @{id = 0} + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $project = $project } + AfterAll { $null = Remove-GitHubProject -Project $project.id -Confirm:$false Remove-Variable project @@ -262,7 +297,11 @@ try Context 'Create Repo projects' { BeforeAll { $project = @{id = 0} + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $project = $project } + AfterAll { $null = Remove-GitHubProject -Project $project.id -Confirm:$false Remove-Variable project @@ -288,6 +327,9 @@ try Context 'Remove User projects' { BeforeAll { $project = New-GitHubProject -UserProject -Name $defaultUserProject -Description $defaultUserProjectDesc + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $project = $project } $null = Remove-GitHubProject -Project $project.id -Confirm:$false @@ -299,6 +341,9 @@ try Context 'Remove Organization projects' { BeforeAll { $project = New-GitHubProject -OrganizationName $script:organizationName -Name $defaultOrgProject -Description $defaultOrgProjectDesc + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $project = $project } $null = Remove-GitHubProject -Project $project.id -Confirm:$false @@ -310,6 +355,9 @@ try Context 'Remove Repo projects' { BeforeAll { $project = New-GitHubProject -OwnerName $script:ownerName -RepositoryName $repo.name -Name $defaultRepoProject -Description $defaultRepoProjectDesc + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $project = $project } $null = Remove-GitHubProject -Project $project.id -Confirm:$false diff --git a/build/scripts/Write-SignConfigXml.ps1 b/build/scripts/Write-SignConfigXml.ps1 index 5b3c6e01..803974cd 100644 --- a/build/scripts/Write-SignConfigXml.ps1 +++ b/build/scripts/Write-SignConfigXml.ps1 @@ -154,21 +154,24 @@ function Get-HashtableFromModuleManifest [System.IO.FileInfo] $Path ) - try + process { - $content = Get-Content -Path $Path -Encoding UTF8 -Raw - $scriptBlock = [scriptblock]::Create($content) + try + { + $content = Get-Content -Path $Path -Encoding UTF8 -Raw + $scriptBlock = [scriptblock]::Create($content) - [string[]] $allowedCommands = @() - [string[]] $allowedVariables = @() - $allowEnvronmentVariables = $false - $scriptBlock.CheckRestrictedLanguage($allowedCommands, $allowedVariables, $allowEnvronmentVariables) + [string[]] $allowedCommands = @() + [string[]] $allowedVariables = @() + $allowEnvronmentVariables = $false + $scriptBlock.CheckRestrictedLanguage($allowedCommands, $allowedVariables, $allowEnvronmentVariables) - return & $scriptBlock - } - catch - { - throw + Write-Output -InputObject (& $scriptBlock) + } + catch + { + throw + } } } @@ -183,7 +186,7 @@ function Get-FilesFromModuleManifest The path to the .psd1 file for the module. .OUTPUTS - [string[]] A list of full paths of all PowerShell files referenced by ModuleManifestPath. + [FileInfo[]] A list of full paths of all PowerShell files referenced by ModuleManifestPath. #> [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "", Justification = "This is the preferred way of writing output for Azure DevOps.")] @@ -195,23 +198,26 @@ function Get-FilesFromModuleManifest [System.IO.FileInfo] $Path ) - Write-Host "$($scriptName): Getting list of PowerShell files referenced by [$Path]." + process + { + Write-Host "$($scriptName): Getting list of PowerShell files referenced by [$Path]." + + $manifest = Get-HashtableFromModuleManifest -Path $Path - $manifest = Get-HashtableFromModuleManifest -Path $Path + $files = @($Path) + $moduleRoot = Split-Path -Path $Path -Parent + if (-not [String]::IsNullOrEmpty($manifest['RootModule'])) + { + $files += (Get-Item -Path (Join-Path -Path $moduleRoot -ChildPath $manifest['RootModule'])) + } - $files = @($Path) - $moduleRoot = Split-Path -Path $Path -Parent - if (-not [String]::IsNullOrEmpty($manifest['RootModule'])) - { - $files += Join-Path -Path $moduleRoot -ChildPath $manifest['RootModule'] - } + foreach ($file in $manifest['NestedModules']) + { + $files += (Get-Item -Path (Join-Path -Path $moduleRoot -ChildPath $file)) + } - foreach ($file in $manifest['NestedModules']) - { - $files += Join-Path -Path $moduleRoot -ChildPath $file + Write-Output -InputObject $files } - - return $files } # Script body