Title: Invoke-Formatter: indent a block even though it should not · Issue #1933 · PowerShell/PSScriptAnalyzer · GitHub
Open Graph Title: Invoke-Formatter: indent a block even though it should not · Issue #1933 · PowerShell/PSScriptAnalyzer
X Title: Invoke-Formatter: indent a block even though it should not · Issue #1933 · PowerShell/PSScriptAnalyzer
Description: Before submitting a bug report: issue is similar, but not exactly, like #1315, so I'm opening a different issue. Note: this has nothing to do with VSCode, only the Invoke-Formatter cmdlet. Steps to reproduce Save the following file as te...
Open Graph Description: Before submitting a bug report: issue is similar, but not exactly, like #1315, so I'm opening a different issue. Note: this has nothing to do with VSCode, only the Invoke-Formatter cmdlet. Steps to...
X Description: Before submitting a bug report: issue is similar, but not exactly, like #1315, so I'm opening a different issue. Note: this has nothing to do with VSCode, only the Invoke-Formatter cmdlet. Step...
Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/1933
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Invoke-Formatter: indent a block even though it should not","articleBody":"Before submitting a bug report:\r\n\r\n- issue is similar, but not exactly, like #1315, so I'm opening a different issue.\r\n\r\nNote: this has nothing to do with VSCode, only the `Invoke-Formatter` cmdlet.\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\nSave the following file as `test.ps1`:\r\n\r\n```PowerShell\r\n$PSStyle.OutputRendering = [System.Management.Automation.OutputRendering]::PlainText;\r\n\r\n$knownProperties = @()\r\nGet-ChildItem -Path . -Recurse -Filter pom.xml | ForEach-Object {\r\n [xml]$pom = Get-Content $_\r\n $knownProperties += $pom.project.properties.getEnumerator() |\r\n Where-Object name -NE '#comment' |\r\n ForEach-Object name\r\n }\r\n\r\nGet-ChildItem -Path . -Recurse -Filter property-*-report.xml | ForEach-Object {\r\n [xml]$report = Get-Content $_\r\n $report.PropertyUpdatesReport.properties.property |\r\n Where-Object { $_.lastVersion -NE $null -and $_.propertyName -in $knownProperties }\r\n\r\n } | Select-Object propertyName, lastVersion | Sort-Object propertyName -Unique\r\n```\r\n\r\nThen, run the formatter:\r\n\r\n```PowerShell\r\nInvoke-Formatter -ScriptDefinition (Get-Content -Raw -Path ./test.ps1)\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\n```PowerShell\r\n$PSStyle.OutputRendering = [System.Management.Automation.OutputRendering]::PlainText;\r\n\r\n$knownProperties = @()\r\nGet-ChildItem -Path . -Recurse -Filter pom.xml | ForEach-Object {\r\n [xml]$pom = Get-Content $_\r\n $knownProperties += $pom.project.properties.getEnumerator() |\r\n Where-Object name -NE '#comment' |\r\n ForEach-Object name\r\n }\r\n\r\nGet-ChildItem -Path . -Recurse -Filter property-*-report.xml | ForEach-Object {\r\n [xml]$report = Get-Content $_\r\n $report.PropertyUpdatesReport.properties.property |\r\n Where-Object { $_.lastVersion -NE $null -and $_.propertyName -in $knownProperties }\r\n\r\n } | Select-Object propertyName, lastVersion | Sort-Object propertyName -Unique\r\n```\r\n\r\nActual behavior\r\n---------------\r\n\r\nThe second line starting with `Get-ChildItem` gets indented and all its pipeline, for no apparent reason:\r\n\r\n```PowerShell\r\n$PSStyle.OutputRendering = [System.Management.Automation.OutputRendering]::PlainText;\r\n\r\n$knownProperties = @()\r\nGet-ChildItem -Path . -Recurse -Filter pom.xml | ForEach-Object {\r\n [xml]$pom = Get-Content $_\r\n $knownProperties += $pom.project.properties.getEnumerator() |\r\n Where-Object name -NE '#comment' |\r\n ForEach-Object name\r\n }\r\n\r\n Get-ChildItem -Path . -Recurse -Filter property-*-report.xml | ForEach-Object {\r\n [xml]$report = Get-Content $_\r\n $report.PropertyUpdatesReport.properties.property |\r\n Where-Object { $_.lastVersion -NE $null -and $_.propertyName -in $knownProperties }\r\n\r\n } | Select-Object propertyName, lastVersion | Sort-Object propertyName -Unique\r\n\r\n```\r\n\r\nEnvironment data\r\n----------------\r\n\r\n```PowerShell\r\n> $PSVersionTable\r\nName Value\r\n---- -----\r\nPSVersion 7.3.6\r\nPSEdition Core\r\nGitCommitId 7.3.6\r\nOS Darwin 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5 22:21:53 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6020\r\nPlatform Unix\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n\r\n> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }\r\n1.21.0\r\n```\r\n","author":{"url":"https://github.com/Jiehong","@type":"Person","name":"Jiehong"},"datePublished":"2023-08-18T11:38:00Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/1933"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:28dc2984-cd10-94f5-f77d-c1d604804663 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BE8E:232E56:222B8B:2D6421:6AFCE087 |
| html-safe-nonce | 0b4f982c2b3f40df144f2575650c1e28550e8a48f490f8b728a09e1c38c927ae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRThFOjIzMkU1NjoyMjJCOEI6MkQ2NDIxOjZBRkNFMDg3IiwidmlzaXRvcl9pZCI6IjkwOTUzMjA3OTI3NjUwOTYwNzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a28d9a3fc6f39be318b1e8c90b0e6a3be8ee8e9cdf1264f5c2666629aa859296 |
| hovercard-subject-tag | issue:1856574456 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PSScriptAnalyzer/1933/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b89beab20380553a41e9da7cb06af90ca6b9a03738004e04cc4a9136fd64f11a/PowerShell/PSScriptAnalyzer/issues/1933 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b89beab20380553a41e9da7cb06af90ca6b9a03738004e04cc4a9136fd64f11a/PowerShell/PSScriptAnalyzer/issues/1933 |
| og:image:alt | Before submitting a bug report: issue is similar, but not exactly, like #1315, so I'm opening a different issue. Note: this has nothing to do with VSCode, only the Invoke-Formatter cmdlet. Steps to... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Jiehong |
| hostname | github.com |
| expected-hostname | github.com |
| None | 99aede4c5f55ec5cf06666a8c9e03ebf9f85f7231223e7f1c38c16e5504835b3 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PSScriptAnalyzer git https://github.com/PowerShell/PSScriptAnalyzer.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 33149177 |
| octolytics-dimension-repository_nwo | PowerShell/PSScriptAnalyzer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 33149177 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PSScriptAnalyzer |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ecfd63ca125ec74b42f74eeb158b3fa081c8c497 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width