Skip to content

Invoke-Formatter - Allman-to-OTBS with a comment after keyword fails #800

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

Closed
JPRuskin opened this issue Jul 7, 2017 · 0 comments · Fixed by #929
Closed

Invoke-Formatter - Allman-to-OTBS with a comment after keyword fails #800

JPRuskin opened this issue Jul 7, 2017 · 0 comments · Fixed by #929

Comments

@JPRuskin
Copy link

JPRuskin commented Jul 7, 2017

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants