Skip to content

Get PSScriptAnalyzer clean again #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 110 additions & 54 deletions GitHubAnalytics.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
}
}
}
}

Expand Down Expand Up @@ -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(
Expand All @@ -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
}
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions GitHubAssignees.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions GitHubBranches.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand Down
3 changes: 3 additions & 0 deletions GitHubComments.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions GitHubCore.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 2 additions & 0 deletions GitHubIssues.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions GitHubLabels.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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')]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions GitHubMilestones.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading