Skip to content
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

chore: Fix code formatting according to style guideline #4

Merged
merged 1 commit into from
Jul 11, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Public commands:
- `Convert-PesterSyntax`
- GitHub templates.

### Fixed

- Fixed code formatting according to style guideline.
8 changes: 4 additions & 4 deletions source/Private/Convert-ShouldBe.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function Convert-ShouldBe
)

$assertBoundParameterParameters = @{
BoundParameterList = $PSBoundParameters
BoundParameterList = $PSBoundParameters
MutuallyExclusiveList1 = @('UseNamedParameters')
MutuallyExclusiveList2 = @('UsePositionalParameters')
}
Expand Down Expand Up @@ -96,9 +96,9 @@ function Convert-ShouldBe
}

$getPesterCommandParameterParameters = @{
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = @(
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = @(
'Be'
'EQ'
'Not'
Expand Down
8 changes: 4 additions & 4 deletions source/Private/Convert-ShouldBeExactly.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function Convert-ShouldBeExactly
)

$assertBoundParameterParameters = @{
BoundParameterList = $PSBoundParameters
BoundParameterList = $PSBoundParameters
MutuallyExclusiveList1 = @('UseNamedParameters')
MutuallyExclusiveList2 = @('UsePositionalParameters')
}
Expand Down Expand Up @@ -99,9 +99,9 @@ function Convert-ShouldBeExactly
$newExtentText += ' -CaseSensitive'

$getPesterCommandParameterParameters = @{
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = @(
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = @(
'CEQ'
'BeExactly'
'Not'
Expand Down
8 changes: 4 additions & 4 deletions source/Private/Convert-ShouldBeFalse.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function Convert-ShouldBeFalse
)

$assertBoundParameterParameters = @{
BoundParameterList = $PSBoundParameters
BoundParameterList = $PSBoundParameters
MutuallyExclusiveList1 = @('UseNamedParameters')
MutuallyExclusiveList2 = @('UsePositionalParameters')
}
Expand Down Expand Up @@ -97,9 +97,9 @@ function Convert-ShouldBeFalse
}

$getPesterCommandParameterParameters = @{
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = 'BeFalse', 'Not'
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = 'BeFalse', 'Not'
PositionalParameter = 'Because', 'ActualValue'
}

Expand Down
8 changes: 4 additions & 4 deletions source/Private/Convert-ShouldBeNullOrEmpty.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function Convert-ShouldBeNullOrEmpty
)

$assertBoundParameterParameters = @{
BoundParameterList = $PSBoundParameters
BoundParameterList = $PSBoundParameters
MutuallyExclusiveList1 = @('UseNamedParameters')
MutuallyExclusiveList2 = @('UsePositionalParameters')
}
Expand Down Expand Up @@ -105,9 +105,9 @@ function Convert-ShouldBeNullOrEmpty
}

$getPesterCommandParameterParameters = @{
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = 'BeNullOrEmpty', 'Not'
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = 'BeNullOrEmpty', 'Not'
PositionalParameter = 'Because', 'ActualValue'
}

Expand Down
10 changes: 5 additions & 5 deletions source/Private/Convert-ShouldBeOfType.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function Convert-ShouldBeOfType
)

$assertBoundParameterParameters = @{
BoundParameterList = $PSBoundParameters
BoundParameterList = $PSBoundParameters
MutuallyExclusiveList1 = @('UseNamedParameters')
MutuallyExclusiveList2 = @('UsePositionalParameters')
}
Expand Down Expand Up @@ -109,9 +109,9 @@ function Convert-ShouldBeOfType
}

$getPesterCommandParameterParameters = @{
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = @(
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = @(
'BeOfType'
'HaveType'
'Not'
Expand All @@ -120,7 +120,7 @@ function Convert-ShouldBeOfType
'ExpectedValue'
'Because'
)
NamedParameter = @(
NamedParameter = @(
'ActualValue'
)
}
Expand Down
8 changes: 4 additions & 4 deletions source/Private/Convert-ShouldBeTrue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function Convert-ShouldBeTrue
)

$assertBoundParameterParameters = @{
BoundParameterList = $PSBoundParameters
BoundParameterList = $PSBoundParameters
MutuallyExclusiveList1 = @('UseNamedParameters')
MutuallyExclusiveList2 = @('UsePositionalParameters')
}
Expand Down Expand Up @@ -100,9 +100,9 @@ function Convert-ShouldBeTrue
}

$getPesterCommandParameterParameters = @{
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = 'BeTrue', 'Not'
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = 'BeTrue', 'Not'
PositionalParameter = 'Because', 'ActualValue'
}

Expand Down
10 changes: 5 additions & 5 deletions source/Private/Convert-ShouldContain.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function Convert-ShouldContain
)

$assertBoundParameterParameters = @{
BoundParameterList = $PSBoundParameters
BoundParameterList = $PSBoundParameters
MutuallyExclusiveList1 = @('UseNamedParameters')
MutuallyExclusiveList2 = @('UsePositionalParameters')
}
Expand Down Expand Up @@ -95,17 +95,17 @@ function Convert-ShouldContain
}

$getPesterCommandParameterParameters = @{
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = @(
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = @(
'Contain'
'Not'
)
PositionalParameter = @(
'ExpectedValue'
'Because'
)
NamedParameter = @(
NamedParameter = @(
'ActualValue'
)
}
Expand Down
8 changes: 4 additions & 4 deletions source/Private/Convert-ShouldMatch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function Convert-ShouldMatch
)

$assertBoundParameterParameters = @{
BoundParameterList = $PSBoundParameters
BoundParameterList = $PSBoundParameters
MutuallyExclusiveList1 = @('UseNamedParameters')
MutuallyExclusiveList2 = @('UsePositionalParameters')
}
Expand Down Expand Up @@ -97,9 +97,9 @@ function Convert-ShouldMatch
}

$getPesterCommandParameterParameters = @{
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = @(
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = @(
'Match'
'Not'
)
Expand Down
8 changes: 4 additions & 4 deletions source/Private/Convert-ShouldMatchExactly.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function Convert-ShouldMatchExactly
)

$assertBoundParameterParameters = @{
BoundParameterList = $PSBoundParameters
BoundParameterList = $PSBoundParameters
MutuallyExclusiveList1 = @('UseNamedParameters')
MutuallyExclusiveList2 = @('UsePositionalParameters')
}
Expand Down Expand Up @@ -99,9 +99,9 @@ function Convert-ShouldMatchExactly
$newExtentText += ' -CaseSensitive'

$getPesterCommandParameterParameters = @{
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = @(
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = @(
'CMATCH'
'MatchExactly'
'Not'
Expand Down
2 changes: 1 addition & 1 deletion source/Private/Convert-ShouldNotThrow.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function Convert-ShouldNotThrow
)

$assertBoundParameterParameters = @{
BoundParameterList = $PSBoundParameters
BoundParameterList = $PSBoundParameters
MutuallyExclusiveList1 = @('UseNamedParameters')
MutuallyExclusiveList2 = @('UsePositionalParameters')
}
Expand Down
10 changes: 5 additions & 5 deletions source/Private/Convert-ShouldThrow.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function Convert-ShouldThrow
)

$assertBoundParameterParameters = @{
BoundParameterList = $PSBoundParameters
BoundParameterList = $PSBoundParameters
MutuallyExclusiveList1 = @('UseNamedParameters')
MutuallyExclusiveList2 = @('UsePositionalParameters')
}
Expand Down Expand Up @@ -116,9 +116,9 @@ function Convert-ShouldThrow
}

$getPesterCommandParameterParameters = @{
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = @(
CommandAst = $CommandAst
CommandName = 'Should'
IgnoreParameter = @(
'Throw'
'Not'
'PassThru'
Expand All @@ -129,7 +129,7 @@ function Convert-ShouldThrow
'ExceptionType'
'Because'
)
NamedParameter = @(
NamedParameter = @(
'ActualValue'
)
}
Expand Down
16 changes: 8 additions & 8 deletions source/Private/Get-CommandAst.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ function Get-CommandAst
Write-Verbose -Message "Retrieving the AST of the command: $CommandName"

$commandAsts = $Ast.FindAll({
param
(
[Parameter()]
$node
)

return $node -is [System.Management.Automation.Language.CommandAst] -and $node.GetCommandName() -eq $CommandName
}, $true)
param
(
[Parameter()]
$node
)

return $node -is [System.Management.Automation.Language.CommandAst] -and $node.GetCommandName() -eq $CommandName
}, $true)

return $commandAsts
}
Expand Down
18 changes: 9 additions & 9 deletions source/Private/Get-PesterCommandParameter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ function Get-PesterCommandParameter

# Filter out the command name from the command elements.
$commandElement = $CommandAst.CommandElements |
Where-Object -FilterScript {
-not (
$_ -is [System.Management.Automation.Language.StringConstantExpressionAst] `
Where-Object -FilterScript {
-not (
$_ -is [System.Management.Automation.Language.StringConstantExpressionAst] `
-and $_.Extent.Text -eq $CommandName
)
}
)
}

Write-Debug -Message "Ignoring the parameters: $($IgnoreParameter -join ', ')"

Expand All @@ -86,7 +86,7 @@ function Get-PesterCommandParameter
Where-Object -FilterScript {
-not (
$_ -is [System.Management.Automation.Language.CommandParameterAst] `
-and $_.ParameterName -in $IgnoreParameter
-and $_.ParameterName -in $IgnoreParameter
)
}

Expand All @@ -103,7 +103,7 @@ function Get-PesterCommandParameter
- ExpectedValue
- Because
#>
$parameterElements = $commandElement.Where({$_ -is [System.Management.Automation.Language.CommandParameterAst] -and ($_.ParameterName -in $PositionalParameter -or $_.ParameterName -in $NamedParameter)})
$parameterElements = $commandElement.Where({ $_ -is [System.Management.Automation.Language.CommandParameterAst] -and ($_.ParameterName -in $PositionalParameter -or $_.ParameterName -in $NamedParameter) })

$filterCommandElements = @()

Expand All @@ -117,7 +117,7 @@ function Get-PesterCommandParameter
$parameterName = $commandElement[$parameterIndex].ParameterName

$positionalParameterHashtable.$parameterName = @{
Position = 0
Position = 0
Positional = $false
ExtentText = $commandElement[$parameterIndex + 1].Extent.Text
}
Expand Down Expand Up @@ -147,7 +147,7 @@ function Get-PesterCommandParameter
{
# Only add positional parameter if there actually a value for it.
$positionalParameterHashtable.$parameter = @{
Position = $positionalCounter
Position = $positionalCounter
Positional = $true
ExtentText = $commandElement[$elementCounter].Extent.Text #? $commandElement.Extent.Text : $null
}
Expand Down
28 changes: 14 additions & 14 deletions source/Private/Get-ShouldCommandOperatorName.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,25 @@ function Get-ShouldCommandOperatorName

# Operator aliases. Output from Pester's command Get-ShouldOperator.
$possibleShouldOperatorAlias = @{
'EQ' = 'Be'
'CEQ' = 'BeExactly'
'GT' = 'BeGreaterThan'
'LE' = 'BeLessOrEqual'
'LT' = 'BeLessThan'
'GE' = 'BeGreaterOrEqual'
'EQ' = 'Be'
'CEQ' = 'BeExactly'
'GT' = 'BeGreaterThan'
'LE' = 'BeLessOrEqual'
'LT' = 'BeLessThan'
'GE' = 'BeGreaterOrEqual'
'HaveType' = 'BeOfType'
'CMATCH' = 'MatchExactly'
'CMATCH' = 'MatchExactly'
}

$shouldOperatorAsts = $CommandAst.Find({
param
(
[Parameter()]
$node
)
param
(
[Parameter()]
$node
)

return $node -is [System.Management.Automation.Language.CommandParameterAst] -and ($node.ParameterName -in $possibleShouldOperator -or $node.ParameterName -in $possibleShouldOperatorAlias.Keys)
}, $true)
return $node -is [System.Management.Automation.Language.CommandParameterAst] -and ($node.ParameterName -in $possibleShouldOperator -or $node.ParameterName -in $possibleShouldOperatorAlias.Keys)
}, $true)

if ($shouldOperatorAsts.ParameterName -in $possibleShouldOperatorAlias.Keys)
{
Expand Down
4 changes: 2 additions & 2 deletions source/Private/Test-PesterCommandNegated.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ function Test-PesterCommandNegated
$negateCommandParameterAst = $CommandAst.CommandElements |
Where-Object -FilterScript {
$_ -is [System.Management.Automation.Language.CommandParameterAst] `
-and $_.ParameterName -eq 'Not' `
-and $_.Argument.Extent.Text -ne '$false'
-and $_.ParameterName -eq 'Not' `
-and $_.Argument.Extent.Text -ne '$false'
}

$negated = $false
Expand Down
Loading