Closed
Description
Using Invoke-Formatter
, the suggested correction for correcting an Allman style brace with the pre-existing OTBS rules fails if there is a comment after the keyword.
if ($bar) # this is the test {
Expected behavior would be that the brace is moved to a non-comment section.
if ($bar) { # this is the test
Full Example:
$RulesDirectory = Join-Path -Path (Get-Module PSScriptAnalyzer -ListAvailable).ModuleBase -ChildPath 'Settings'
$Settings = Import-PowerShellDataFile (Join-Path $RulesDirectory 'CodeFormattingOTBS.psd1')
$Script = @'
function foo {
if ($bar) # this is the test
{
Write-Host "bar"
}
}
'@
$Formatted = Invoke-Formatter -Settings $Settings -ScriptDefinition $Script