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 — WIP: Fix: PSUseConsistentWhitespace formatting for do-while, unary operators, and native commands by DrSkillIssue · Pull Request #2114 · PowerShell/PSScriptAnalyzer

Conversation

@DrSkillIssue

@DrSkillIssue Dr. Skill Issue (DrSkillIssue) commented Jun 17, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

PR Summary

Fixes multiple whitespace formatting issues in PSUseConsistentWhitespace rule

Issues Fixed:

  • Whitespace Between Parameters Is Trimming Required Quotes #1561 - CheckParameter removing whitespace inside string literals
  • PSUseConsistentWhitespace CheckInnerBrace - false positive on hashtable closing brace #1742 - False positive on hashtable closing brace with CheckInnerBrace
  • Invalid reformatting when docker command executed directly from PS #2094 - Incorrect comma formatting in native command arguments (e.g., docker --secret id=x,env=y)
  • Formatting misses certain keywords (unary operators, 'until') #2095 - Missing space between } and keywords in do-while/do-until loops

Changes Made:

Core Fixes:

  • Added FindKeywordAfterBraceViolations to handle keywords following closing braces
  • Enhanced unary operator detection and spacing logic in FindOperatorViolations
  • Fixed FindParameterViolations to skip whitespace inside string literals
  • Added comma pattern detection in FindSeparatorViolations for native command arguments
  • Added the additional keywords to openParenKeywordAllowList: Until, Do, Else, Catch, Finally

Tests Added:

  • Added test-cases for the above-mentioned changes.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Change is not breaking
  • Make sure all .cs, .ps1 and .psm1 files have the correct copyright header
  • Make sure you've added a new test if existing tests do not effectively test the code changed and/or updated documentation
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready.

Sorry, something went wrong.

Uh oh!

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

SamErde and o-l-a-v reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@DrSkillIssue
fix: Formatting misses certain keywords (unary operators, 'until')
7e60fb3
@DrSkillIssue
Dr. Skill Issue (DrSkillIssue) requested review from Andy Jordan (andyleejordan) and Christoph Bergmeister (bergmeister) as code owners June 17, 2025 12:15
@DrSkillIssue Dr. Skill Issue (DrSkillIssue) changed the title Fix: #2095 - UseConsistentWhitespace formatting for do-while/do-until loops and unary operators WIP: Fix: #2095 - UseConsistentWhitespace formatting for do-while/do-until loops and unary operators Jun 17, 2025
Dr. Skill Issue (DrSkillIssue) added 2 commits June 17, 2025 15:40
@DrSkillIssue
wip: Before-Optimized UseConsistentWhitespace
deb3512
@DrSkillIssue
fix: #1561
ac68598
@DrSkillIssue

Dr. Skill Issue (DrSkillIssue) commented Jun 17, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Author

These PRs may just need closed as I couldn't reproduce the issues

  • Formatting .where and .foreach methods is incorrect #1168 - Issue may have been fixed as the behavior is corrected when PSUseConsistentWhitespace is enabled.
  • Invoke-Formatter: Adding whitespace after opening parenthesis #1288 - Couldn't reproduce this issue
  • PSUseConsistentWhitespace for Pester tests and 'Should Throw' #1298 - Couldn't reproduce this issue
  • PSUseConsistentWhitespace - False validation in switch statements #1319 - Couldn't reproduce this issue

PRs that were fixed with this PR

  • Whitespace Between Parameters Is Trimming Required Quotes #1561 - Fixed with this PR
  • PSUseConsistentWhitespace CheckInnerBrace - false positive on hashtable closing brace #1742 - Fixed with this PR
  • Invalid reformatting when docker command executed directly from PS #2094 - Fixed with this PR
  • Formatting misses certain keywords (unary operators, 'until') #2095 - Fixed with this PR

PRs that can be fixed in another PR(s) once this one is merged

Opting for multiple PRs as this one is large already.

  • Enhance PSUseConsistentWhiteSpace to exclude more special cases when using unary operators #950
  • Lines unaffected from sytax errors get formatted wrong on PowerShell 5 #1813
All reactions

Sorry, something went wrong.

Uh oh!

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

@DrSkillIssue Dr. Skill Issue (DrSkillIssue) changed the title WIP: Fix: #2095 - UseConsistentWhitespace formatting for do-while/do-until loops and unary operators WIP: Fix: PSUseConsistentWhitespace formatting for do-while, unary operators, and native commands Jun 17, 2025
Dr. Skill Issue (DrSkillIssue) added 2 commits July 19, 2025 19:20
@DrSkillIssue
fix: Unary Postfix Operations require whitespace skips
e27fb2b
@DrSkillIssue
chore: aesthetic changes
42d3cd0
@TMA-2 Jon (TMA-2) mentioned this pull request Oct 28, 2025
AlignAssignmentStatement overhaul to fix issues and include handing of Enums. #2132
Merged
5 of 6 tasks
@bergmeister

Christoph Bergmeister (bergmeister) commented Jan 30, 2026

Copy link
Copy Markdown
Collaborator

Dr. Skill Issue (@DrSkillIssue) Can you please resolve merge conflict and re-test please. This is due to PR #2140 , which tweaked the logic of the same area of the rule you modify

All reactions

Sorry, something went wrong.

Uh oh!

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

@bergmeister
Christoph Bergmeister (bergmeister) marked this pull request as draft February 3, 2026 20:09
@kjanat Kaj Kowalski (kjanat) mentioned this pull request Aug 24, 2026
Tracking: five upstream PSScriptAnalyzer bugs kjanat/powershell-formatter#6
Closed
5 tasks done
@DrSkillIssue Dr. Skill Issue (DrSkillIssue) closed this by deleting the head repository Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@andyleejordan Andy Jordan (andyleejordan) Awaiting requested review from andyleejordan
@bergmeister Christoph Bergmeister (bergmeister) Awaiting requested review from bergmeister bergmeister is a code owner
Copilot code review Copilot
Copilot will automatically review once the pull request is marked ready for review

Uh oh!

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

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

@DrSkillIssue @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.