Skip to content

Commit

Permalink
fixed PSScriptAnalyzer rule which requires the process block
Browse files Browse the repository at this point in the history
  • Loading branch information
LIO2MU committed Jun 13, 2024
1 parent ca290a6 commit 556fe4b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
30 changes: 16 additions & 14 deletions JiraPS/Private/Resolve-JiraIssueObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
22 changes: 12 additions & 10 deletions JiraPS/Private/Resolve-JiraUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

0 comments on commit 556fe4b

Please sign in to comment.