From 69498906d3f2853343256e8e4623f2b3050505a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20R=C3=B8nnestad=20Birkeland?= <6450056+o-l-a-v@users.noreply.github.com> Date: Sun, 1 Mar 2026 12:00:24 +0100 Subject: [PATCH 1/2] feat: added new code formatting preset OTPS --- Engine/Settings/CodeFormattingOTPS.psd1 | 55 +++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Engine/Settings/CodeFormattingOTPS.psd1 diff --git a/Engine/Settings/CodeFormattingOTPS.psd1 b/Engine/Settings/CodeFormattingOTPS.psd1 new file mode 100644 index 000000000..83514c7f9 --- /dev/null +++ b/Engine/Settings/CodeFormattingOTPS.psd1 @@ -0,0 +1,55 @@ +@{ + IncludeRules = @( + 'PSPlaceOpenBrace', + 'PSPlaceCloseBrace', + 'PSUseConsistentWhitespace', + 'PSUseConsistentIndentation', + 'PSAlignAssignmentStatement', + 'PSUseCorrectCasing' + ) + + Rules = @{ + PSPlaceOpenBrace = @{ + Enable = $true + OnSameLine = $true + NewLineAfter = $true + IgnoreOneLineBlock = $true + } + + PSPlaceCloseBrace = @{ + Enable = $true + NewLineAfter = $true + IgnoreOneLineBlock = $true + NoEmptyLineBefore = $false + } + + PSUseConsistentIndentation = @{ + Enable = $true + Kind = 'space' + PipelineIndentation = 'IncreaseIndentationForFirstPipeline' + IndentationSize = 4 + } + + PSUseConsistentWhitespace = @{ + Enable = $true + CheckInnerBrace = $true + CheckOpenBrace = $true + CheckOpenParen = $true + CheckOperator = $true + CheckPipe = $true + CheckPipeForRedundantWhitespace = $false + CheckSeparator = $true + CheckParameter = $false + IgnoreAssignmentOperatorInsideHashTable = $true + } + + PSAlignAssignmentStatement = @{ + Enable = $true + CheckHashtable = $true + } + + PSUseCorrectCasing = @{ + Enable = $true + } + } +} From 5e8ed23c0ad5374ba291a287bd3b7ddbcf118126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20R=C3=B8nnestad=20Birkeland?= <6450056+o-l-a-v@users.noreply.github.com> Date: Sun, 1 Mar 2026 12:00:50 +0100 Subject: [PATCH 2/2] feat: added new code formatting preset OTPS to some tests where i found OTBS mentioned --- Tests/Rules/PlaceOpenBrace.tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tests/Rules/PlaceOpenBrace.tests.ps1 b/Tests/Rules/PlaceOpenBrace.tests.ps1 index 4c8206102..424e511b2 100644 --- a/Tests/Rules/PlaceOpenBrace.tests.ps1 +++ b/Tests/Rules/PlaceOpenBrace.tests.ps1 @@ -56,6 +56,7 @@ foreach ($x in $y) { Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings $settings | Should -Be $expected Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings 'CodeFormattingStroustrup' | Should -Be $expected Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings 'CodeFormattingOTBS' | Should -Be $expected + Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings 'CodeFormattingOTPS' | Should -Be $expected } It "Should correct violation when brace should be on the same line and take comment into account" { @@ -73,6 +74,7 @@ foreach ($x in $y) { # useful comment Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings $settings | Should -Be $expected Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings 'CodeFormattingStroustrup' | Should -Be $expected Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings 'CodeFormattingOTBS' | Should -Be $expected + Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings 'CodeFormattingOTPS' | Should -Be $expected } It "Should correct violation when the brace should be on the next line and take comment into account" { @@ -90,6 +92,7 @@ foreach ($x in $y) { # useful comment Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings $settings | Should -Be $expected Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings 'CodeFormattingStroustrup' | Should -Be $expected Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings 'CodeFormattingOTBS' | Should -Be $expected + Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings 'CodeFormattingOTPS' | Should -Be $expected } }