-
Notifications
You must be signed in to change notification settings - Fork 393
False positive for PSUseConsistentIndentation inside Visual Studio Code #1202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, thanks for the very detailed info (that was definitely necessary due to the recent releases of the extension and PSSA). $dummy2 = ($item |
Where-Object field1 -like 'dummyValue' |
Select-Object field1 |
Sort-Object field1)[0].field2 Not related to your problem specifically, but be aware that PSSA 1.18.0 added the new |
@bergmeister Thanks for the quick response. As you suggested, I set: PSScriptAnalyzerSettings.psd1: 'PSUseConsistentIndentation' = @{
'Enable' = $true
'IndentationSize' = 4
'PipelineIndentation' = 'IncreaseIndentationForFirstPipeline'
'Kind' = 'space'
} I also commented out all other rules in the Settings:
Then I split line 7 after the vertical bar, and formatted the document. It formats without squigglies. So, it seems like this PSSA rule (in VS Code) requires pipelined commands to be split over multiple lines. Do you think this could be the case? |
@bergmeister Based on your information, I've figured out what is happening. In my command prompt test I did not point to the As you stated, it's all about the |
@bergmeister I've re-opened the issue as I find that to stop swigglies I have to use multiple lines for all pipelined statements. This does not seem right. In my sample code, line 7 does not need splitting. I looked at other code I have and found the following line Can you confirm if the |
|
@bergmeister Thanks. I've set |
@bergmeister A new version of vscode-powershell (v2019.5.0-preview) has been released. Is this issue fixed in this release? |
No, PSSA has not released 1.18.1 yet but hopefully in the coming weeks. From the time we release you will be able to just install the newer version, which will override the one shipped with the vscode extension until the vscode extension ships a newer version. |
@bergmeister Thanks for the quick response. I'll wait for the release of the new version of PSSA. |
Steps to reproduce
ps1
file. Note this is sample code cut down to the minimun to show the issueExpected behavior
No green swigglies.
Actual behavior
From the PowerShell command prompt it works fine, and only reports the unused variable.
If I move the Select-Object statement, on line 7, to a new line:
It introduces a new false positive for lines 20-22.
Environment data
I'm using the following VS Code
PSScriptAnalyzerSettings.ps1
file:PSScriptAnalyzerSettings.zip
From the terminal inside VS Code:
From the PowerShell command prompt:
The text was updated successfully, but these errors were encountered: