Skip to content

Where-Object formatting bug #2051

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
jakauppila opened this issue Jun 26, 2019 · 2 comments
Closed

Where-Object formatting bug #2051

jakauppila opened this issue Jun 26, 2019 · 2 comments

Comments

@jakauppila
Copy link

System Details

System Details Output

### VSCode version: 1.35.1 c7d83e57cd18f18026a8162d042843bda1bcf21f x64

### VSCode extensions:
ms-vscode.powershell-preview@2019.5.0

### PSES version: 2.0.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      5.1.16299.1146
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.1146
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

I am experiencing a problem with auto-formatting when utilizing Where-Object with the following:

function Verb-Noun {
  Begin {
  }
  Process {
    foreach ($foo in $bar) {
      if ($something) {
        $somethingElse = ($something | Where-Object { $_ -eq $null })
    }
  }
  $variable = $null
}
End {
}
}

Expected Behaviour

function Verb-Noun {
  Begin {
  }
  Process {
    foreach ($foo in $bar) {
      if ($something) {
        $somethingElse = ($something | Where-Object { $_ -eq $null } )
      }
    }
    $variable = $null
  }
  End {
  }
}

Actual Behaviour

function Verb-Noun {
  Begin {
  }
  Process {
    foreach ($foo in $bar) {
      if ($something) {
        $somethingElse = ($something | Where-Object { $_ -eq $null })
    }
  }
  $variable = $null
}
End {
}
}
@jakauppila
Copy link
Author

I would note, this is with the IncreaseIndentationForFirstPipeline indentation style set, it works just fine with NoIdentation; not sure if that is expected or not.

@rkeithhill
Copy link
Contributor

I wonder if you are encountering the same PSSA bug as described here - PowerShell/PSScriptAnalyzer#1236

Regardless, the formatting functionality is provided by the PSScriptAnalyzer repo referenced in the issue above. If that issue doesn't match what you're seeing, please submit this issue to that repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants