GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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.

Copy link
Copy Markdown
Contributor

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

  • The cause is the same as PSUseConsistentIndentation: Hashtable inside method call gets double-indented #2159: the ( and the { on the opener line each add an indentation level.
  • Improve pipeline indentation handling in UseConsistentIndentation rule #2173 already fixes this on main, though no release includes it yet. When a ( is followed on the same line by an opener that stays unclosed, the ( skips its increment and its matching ) skips the decrement. The check doesn't care what comes before the (, so [Attr({ is covered too.

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.

  • Fixes PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock ([Attr({ … })]) #2216

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Initial plan
128cac4
Copilot AI assigned Copilot and Christoph Bergmeister (bergmeister) Oct 27, 2026
Copilot started work on behalf of Christoph Bergmeister (bergmeister) October 27, 2026 22:29
View session
Copilot AI linked an issue Oct 27, 2026 that may be closed by this pull request
PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock ([Attr({ … })]) #2216
Closed
2 tasks done
@bergmeister
Add regression tests for attribute scriptblock indentation ([Attr({ .…
841dc4c
….. })])

Co-authored-by: bergmeister <[email protected]>
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
Copilot finished work on behalf of Christoph Bergmeister (bergmeister) October 27, 2026 22:33
Copilot AI requested a review from Christoph Bergmeister (bergmeister) October 27, 2026 22:33
@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 28, 2026 07:17
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 07:17
View session
Copilot AI reviewed Oct 28, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

All reactions
@bergmeister
Christoph Bergmeister (bergmeister) marked this pull request as ready for review October 28, 2026 11:36
@bergmeister
Christoph Bergmeister (bergmeister) requested a review from a team as a code owner October 28, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@bergmeister Christoph Bergmeister (bergmeister) Awaiting requested review from bergmeister bergmeister is a code owner

At least 1 approving review is required to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@bergmeister Christoph Bergmeister (bergmeister)

Copilot code review Copilot

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock ([Attr({ … })])

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@bergmeister
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.