René's URL Explorer Experiment


Title: PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock (`[Attr({ … })]`) · Issue #2216 · PowerShell/PSScriptAnalyzer · GitHub

Open Graph Title: PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock (`[Attr({ … })]`) · Issue #2216 · PowerShell/PSScriptAnalyzer

X Title: PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock (`[Attr({ … })]`) · Issue #2216 · PowerShell/PSScriptAnalyzer

Description: Prerequisites I have read the documentation and my issue is not covered there. I have searched the existing issues and my issue is not already reported. Summary PSUseConsistentIndentation (and therefore Invoke-Formatter) double-indents t...

Open Graph Description: Prerequisites I have read the documentation and my issue is not covered there. I have searched the existing issues and my issue is not already reported. Summary PSUseConsistentIndentation (and ther...

X Description: Prerequisites I have read the documentation and my issue is not covered there. I have searched the existing issues and my issue is not already reported. Summary PSUseConsistentIndentation (and ther...

Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/2216

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock (`[Attr({ … })]`)","articleBody":"### Prerequisites\n\n- [x] I have read the [documentation](https://learn.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/overview) and my issue is not covered there.\n- [x] I have searched the [existing issues](https://github.com/PowerShell/PSScriptAnalyzer/issues) and my issue is not already reported.\n\n### Summary\n\n`PSUseConsistentIndentation` (and therefore `Invoke-Formatter`) double-indents the body of an **attribute that opens a scriptblock**, e.g. `[ArgumentCompleter({...})]`. The body gets `IndentationSize * 2` and the closing `})]` gets `IndentationSize * 1`.\n\nThis looks like the same root cause as #2159 (hashtable inside a method call: the `LParen` and the `AtCurly` each add an indentation level). Here the two adjacent openers are `(` and `{` from a **type/attribute literal** instead of `@{`, so `[AttributeName({` hits it too. #2159 was fixed on `main` by #2173 (\"only the last unclosed opener on a line affects indentation\"), but neither that fix nor #2159 covers the attribute form, and it is still broken in the latest release **1.25.0**.\n\n### Steps to reproduce\n\n```powershell\n$code = @'\n[ArgumentCompleter({\n\tParam($commandName, $parameterName)\n\t$validKeys = @('a', 'b')\n\t$validKeys | Where-Object { $_ } | ForEach-Object { \"$_=\" }\n})]\n'@\n\n$settings = @{\n\tIncludeRules = @('PSUseConsistentIndentation')\n\tRules = @{\n\t\tPSUseConsistentIndentation = @{\n\t\t\tEnable        = $true\n\t\t\tIndentationSize = 4\n\t\t\tKind          = 'tab'\n\t\t}\n\t}\n}\n\nInvoke-Formatter -ScriptDefinition $code -Settings $settings\n```\n\n### Expected behavior\n\nOne level of indentation for the body, matching the opener line, and the closing `})]` at the opener's level:\n\n```powershell\n[ArgumentCompleter({\n\tParam($commandName, $parameterName)\n\t$validKeys = @('a', 'b')\n\t$validKeys | Where-Object { $_ } | ForEach-Object { \"$_=\" }\n})]\n```\n\n### Actual behavior\n\nTwo levels for the body and one level for the closing `})]`:\n\n```powershell\n[ArgumentCompleter({\n\t\tParam($commandName, $parameterName)\n\t\t$validKeys = @('a', 'b')\n\t\t$validKeys | Where-Object { $_ } | ForEach-Object { \"$_=\" }\n\t})]\n```\n\nThe same happens with spaces (`Kind = 'space'`, `IndentationSize = 4`) and with `NewLineAfterOpenBrace`/`PSPlaceOpenBrace` not involved at all — `PSUseConsistentIndentation` alone is enough.\n\nIt also affects other attribute forms that open a scriptblock, e.g.\n\n```powershell\n[ValidateScript({\n\t$_ -gt 0\n})]\n```\n\nand the buggy output is **not idempotent in a harmless way**: because the opener line itself is not re-indented, re-running the formatter keeps the body at the wrong level, and any tool that re-applies formatting sees a permanent diff.\n\n### Environment\n\n```\nPSVersion: 7.6.6\nPSEdition: Core\nOS: Windows 11 (26100)\nPSScriptAnalyzer: 1.25.0\n```\n\nAlso reproduced with PSScriptAnalyzer 1.24.0 (bundled with ms-vscode.powershell 2025.4.0) and with Windows PowerShell 5.1 / 26100 (Desktop edition), so it is not host- or edition-specific.\n\n### Related\n\n- #2159 — `PSUseConsistentIndentation`: Hashtable inside method call gets double-indented (same `LParen`+`XCurly` double count; fixed by #2173)\n- #2173 — the fix that pops the level when an opener is not the last unclosed opener on the line; it does not catch the attribute opening `({`\n- #1168 — \"Formatting `.where` and `.foreach` methods is incorrect\" (adjacent-opener family)\n","author":{"url":"https://github.com/steve02081504","@type":"Person","name":"steve02081504"},"datePublished":"2026-09-18T04:10:30Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/2216"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:6b810492-a09f-499b-50be-09d2acbd6de3
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD942:13EF97:1EA5B6:2A847F:6AFCE209
html-safe-nonce311deccb15b8d802f84df73ecbfa35414d99e1158d091e0106fce4674856b530
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTQyOjEzRUY5NzoxRUE1QjY6MkE4NDdGOjZBRkNFMjA5IiwidmlzaXRvcl9pZCI6IjU2ODY0NDgxMjY1ODg0MTI0MjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacf7b3d8fdd29de3cd2bba3e9f876c76ad10bfe0833d29a321263d381cb6ff6ecd
hovercard-subject-tagissue:5495552467
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PSScriptAnalyzer/2216/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4569e930dc015e7be965fb76b9625f0ecdb6c99c4073da01657d2b956290d8cb/PowerShell/PSScriptAnalyzer/issues/2216
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4569e930dc015e7be965fb76b9625f0ecdb6c99c4073da01657d2b956290d8cb/PowerShell/PSScriptAnalyzer/issues/2216
og:image:altPrerequisites I have read the documentation and my issue is not covered there. I have searched the existing issues and my issue is not already reported. Summary PSUseConsistentIndentation (and ther...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesteve02081504
hostnamegithub.com
expected-hostnamegithub.com
None0c05b7eb5b95e29725d01bb1f560a020e3fafd0f033c6b9ed3918fa3161254dd
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PSScriptAnalyzer git https://github.com/PowerShell/PSScriptAnalyzer.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id33149177
octolytics-dimension-repository_nwoPowerShell/PSScriptAnalyzer
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id33149177
octolytics-dimension-repository_network_root_nwoPowerShell/PSScriptAnalyzer
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release79d9154e55368884c8c93766ba4fee076343d37f
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/PowerShell/PSScriptAnalyzer/issues/2216#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPSScriptAnalyzer%2Fissues%2F2216
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPSScriptAnalyzer%2Fissues%2F2216
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPSScriptAnalyzer
Reloadhttps://github.com/PowerShell/PSScriptAnalyzer/issues/2216
Reloadhttps://github.com/PowerShell/PSScriptAnalyzer/issues/2216
Reloadhttps://github.com/PowerShell/PSScriptAnalyzer/issues/2216
PowerShellhttps://github.com/PowerShell
PSScriptAnalyzerhttps://github.com/PowerShell/PSScriptAnalyzer
Codehttps://github.com/PowerShell/PSScriptAnalyzer
Issues407 (407)https://github.com/PowerShell/PSScriptAnalyzer/issues
Pull requests34 (34)https://github.com/PowerShell/PSScriptAnalyzer/pulls
Discussionshttps://github.com/PowerShell/PSScriptAnalyzer/discussions
Actionshttps://github.com/PowerShell/PSScriptAnalyzer/actions
Projectshttps://github.com/PowerShell/PSScriptAnalyzer/projects
Wikihttps://github.com/PowerShell/PSScriptAnalyzer/wiki
Security and qualityhttps://github.com/PowerShell/PSScriptAnalyzer/security
Insightshttps://github.com/PowerShell/PSScriptAnalyzer/insights
https://github.com/PowerShell/PSScriptAnalyzer
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/2216
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/2216
#2263https://github.com/PowerShell/PSScriptAnalyzer/pull/2263
PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock ([Attr({ … })])https://github.com/PowerShell/PSScriptAnalyzer/issues/2216#top
#2263https://github.com/PowerShell/PSScriptAnalyzer/pull/2263
https://github.com/bergmeister
https://github.com/copilot-swe-agent
Resolution - Fixedhttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Resolution%20-%20Fixed%22
https://github.com/steve02081504
steve green (steve02081504)https://github.com/steve02081504
on Sep 18, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2216#issue-5495552467
documentationhttps://learn.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/overview
existing issueshttps://github.com/PowerShell/PSScriptAnalyzer/issues
#2159https://github.com/PowerShell/PSScriptAnalyzer/issues/2159
#2159https://github.com/PowerShell/PSScriptAnalyzer/issues/2159
#2173https://github.com/PowerShell/PSScriptAnalyzer/pull/2173
#2159https://github.com/PowerShell/PSScriptAnalyzer/issues/2159
PSUseConsistentIndentation: Hashtable inside method call gets double-indented #2159https://github.com/PowerShell/PSScriptAnalyzer/issues/2159
Improve pipeline indentation handling in UseConsistentIndentation rule #2173https://github.com/PowerShell/PSScriptAnalyzer/pull/2173
Improve pipeline indentation handling in UseConsistentIndentation rule #2173https://github.com/PowerShell/PSScriptAnalyzer/pull/2173
Formatting .where and .foreach methods is incorrect #1168https://github.com/PowerShell/PSScriptAnalyzer/issues/1168
https://github.com/steve02081504
steve green (steve02081504)https://github.com/steve02081504
on Sep 18, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2216#issuecomment-5725025529
ps12exehttps://github.com/steve02081504/ps12exe
#2159https://github.com/PowerShell/PSScriptAnalyzer/issues/2159
#2173https://github.com/PowerShell/PSScriptAnalyzer/pull/2173
#2173https://github.com/PowerShell/PSScriptAnalyzer/pull/2173
https://github.com/steve02081504
steve green (steve02081504)https://github.com/steve02081504
on Sep 18, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2216#issuecomment-5725849171
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
Copilothttps://github.com/apps/copilot-swe-agent
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
on Oct 27, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2216#event-34418966223
Copilothttps://github.com/apps/copilot-swe-agent
Add regression tests for attribute scriptblock indentation (`[Attr({ … })]`) #2263https://github.com/PowerShell/PSScriptAnalyzer/pull/2263
on Oct 27, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2216#event-34419004931
https://github.com/bergmeister
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
on Oct 28, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2216#issuecomment-6467995931
#2173https://github.com/PowerShell/PSScriptAnalyzer/pull/2173
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
Resolution - Fixedhttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Resolution%20-%20Fixed%22
on Oct 28, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2216#event-34469000601
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
completedhttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 4, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2216#event-35146766805
Sign up for freehttps://github.com/signup?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/2216
Sign in to commenthttps://github.com/login?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/2216
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
Copilothttps://github.com/apps/copilot-swe-agent
Resolution - Fixedhttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Resolution%20-%20Fixed%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.