From 556fe4b685ea1d00c90a9457eb8dd9ed4c6cd370 Mon Sep 17 00:00:00 2001 From: Oliver Lipkau Date: Thu, 13 Jun 2024 12:09:42 +0000 Subject: [PATCH] fixed `PSScriptAnalyzer` rule which requires the `process` block --- JiraPS/Private/Resolve-JiraIssueObject.ps1 | 30 ++++++++++++---------- JiraPS/Private/Resolve-JiraUser.ps1 | 22 ++++++++-------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/JiraPS/Private/Resolve-JiraIssueObject.ps1 b/JiraPS/Private/Resolve-JiraIssueObject.ps1 index 03050755..89104579 100644 --- a/JiraPS/Private/Resolve-JiraIssueObject.ps1 +++ b/JiraPS/Private/Resolve-JiraIssueObject.ps1 @@ -33,19 +33,21 @@ function Resolve-JiraIssueObject { $Credential = [System.Management.Automation.PSCredential]::Empty ) - # As we are not able to use proper type casting in the parameters, this is a workaround - # to extract the data from a JiraPS.Issue object - # This shall be removed once we have custom classes for the module - if ("JiraPS.Issue" -in $InputObject.PSObject.TypeNames -and $InputObject.RestURL) { - Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Using `$InputObject as object" - return $InputObject - } - elseif ("JiraPS.Issue" -in $InputObject.PSObject.TypeNames -and $InputObject.Key) { - Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Resolve Issue to object" - return (Get-JiraIssue -Key $InputObject.Key -Credential $Credential -ErrorAction Stop) - } - else { - Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Resolve Issue to object" - return (Get-JiraIssue -Key $InputObject.ToString() -Credential $Credential -ErrorAction Stop) + process { + # As we are not able to use proper type casting in the parameters, this is a workaround + # to extract the data from a JiraPS.Issue object + # This shall be removed once we have custom classes for the module + if ("JiraPS.Issue" -in $InputObject.PSObject.TypeNames -and $InputObject.RestURL) { + Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Using `$InputObject as object" + return $InputObject + } + elseif ("JiraPS.Issue" -in $InputObject.PSObject.TypeNames -and $InputObject.Key) { + Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Resolve Issue to object" + return (Get-JiraIssue -Key $InputObject.Key -Credential $Credential -ErrorAction Stop) + } + else { + Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Resolve Issue to object" + return (Get-JiraIssue -Key $InputObject.ToString() -Credential $Credential -ErrorAction Stop) + } } } diff --git a/JiraPS/Private/Resolve-JiraUser.ps1 b/JiraPS/Private/Resolve-JiraUser.ps1 index e5ae4a44..7b37f972 100644 --- a/JiraPS/Private/Resolve-JiraUser.ps1 +++ b/JiraPS/Private/Resolve-JiraUser.ps1 @@ -36,15 +36,17 @@ function Resolve-JiraUser { $Credential = [System.Management.Automation.PSCredential]::Empty ) - # As we are not able to use proper type casting in the parameters, this is a workaround - # to extract the data from a JiraPS.Issue object - # This shall be removed once we have custom classes for the module - if ("JiraPS.User" -in $InputObject.PSObject.TypeNames) { - Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Using `$InputObject as object" - return $InputObject - } - else { - Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Resolve User to object" - return (Get-JiraUser -UserName $InputObject -Exact:$Exact -Credential $Credential -ErrorAction Stop) + process { + # As we are not able to use proper type casting in the parameters, this is a workaround + # to extract the data from a JiraPS.Issue object + # This shall be removed once we have custom classes for the module + if ("JiraPS.User" -in $InputObject.PSObject.TypeNames) { + Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Using `$InputObject as object" + return $InputObject + } + else { + Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Resolve User to object" + return (Get-JiraUser -UserName $InputObject -Exact:$Exact -Credential $Credential -ErrorAction Stop) + } } }