GeezerVison is showing github.com — Add regression tests for attribute scriptblock indentation (`[Attr({ … })]`) by Copilot · Pull Request #2263 · PowerShell/PSScriptAnalyzer
Conversation
Copilot
AI
commented
Oct 27, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
In 1.25.0, PSUseConsistentIndentation double-indents the body of an attribute that opens a scriptblock, such as [ArgumentCompleter({ … })] or [ValidateScript({ … })]. The body gets two levels and the closing })] gets one.
# 1.25.0 output
[ArgumentCompleter({
Param($commandName, $parameterName)
})]
# Expected (current main)
[ArgumentCompleter({
Param($commandName, $parameterName)
})]
Root cause / status
Changes
-
Tests only, no rule changes. Two cases are added to the "When multiple openers appear on the same line" context in Tests/Rules/UseConsistentIndentation.tests.ps1:
- top-level
[ArgumentCompleter({ … })], using the issue's example
[ValidateScript({ … })] nested inside a function's param() block
Both start from double-indented input and check that it is corrected. They fail against 1.25.0, so a regression would be caught.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Copilot
AI
changed the title
[WIP] Fix double indent issue for attribute bodies in scripting
Add regression tests for attribute scriptblock indentation ([Attr({ … })])
Oct 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 Approval recommended
No active review issues were identified for the added attribute scriptblock indentation regression tests.
No open issues 🎉
What changed in this PR
Adds regression coverage for attribute scriptblock indentation reported in #2216, protecting the existing fix from #2173 without changing rule behavior.
Changes:
- Tests correction of double-indented bodies and closing delimiters in top-level
[ArgumentCompleter({ … })].
- Tests the same correction for
[ValidateScript({ … })] nested inside a function’s param() block.
| File |
Description |
| Tests/Rules/UseConsistentIndentation.tests.ps1 |
Adds two attribute scriptblock cases to the multiple-openers indentation tests. |
Review effort: Balanced
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
At least 1 approving review is required to merge this pull request.
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.