PSScriptAnalyzer
PSScriptAnalyzer copied to clipboard
WIP: Fix: PSUseConsistentWhitespace formatting for do-while, unary operators, and native commands
PR Summary
Fixes multiple whitespace formatting issues in PSUseConsistentWhitespace rule
Issues Fixed:
- #1561 - CheckParameter removing whitespace inside string literals
- #1742 - False positive on hashtable closing brace with CheckInnerBrace
-
#2094 - Incorrect comma formatting in native command arguments (e.g.,
docker --secret id=x,env=y) -
#2095 - Missing space between
}and keywords in do-while/do-until loops
Changes Made:
Core Fixes:
- Added
FindKeywordAfterBraceViolationsto handle keywords following closing braces - Enhanced unary operator detection and spacing logic in
FindOperatorViolations - Fixed
FindParameterViolationsto skip whitespace inside string literals - Added comma pattern detection in
FindSeparatorViolationsfor 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
- [x] PR has a meaningful title
- Use the present tense and imperative mood when describing your changes
- [x] Summarized changes
- [x] Change is not breaking
- [x] Make sure all
.cs,.ps1and.psm1files have the correct copyright header - [x] 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.
- If the PR is work in progress, please add the prefix
These PRs may just need closed as I couldn't reproduce the issues
- #1168 - Issue may have been fixed as the behavior is corrected when
PSUseConsistentWhitespaceis enabled. - #1288 - Couldn't reproduce this issue
- #1298 - Couldn't reproduce this issue
- #1319 - Couldn't reproduce this issue
PRs that were fixed with this PR
- #1561 - Fixed with this PR
- #1742 - Fixed with this PR
- #2094 - Fixed with this PR
- #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.
- #950
- #1813