Open midacts opened 6 years ago
Anyone else running into this?
Sorry, I have not triaged this yet but I would not be surprised if what you report, is true as I remember having a similar problem last year. I will try to get back to this month
Sorry, I was quite busy, I really hope to have a look at this this month
No problem. I understand. Thanks for the update and for looking into this.
On Mon, Nov 5, 2018, 3:53 PM Christoph Bergmeister [MVP] < notifications@github.com wrote:
Sorry, I was quite busy, I really hope to have a look at this this month
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PowerShell/PSScriptAnalyzer/issues/1055#issuecomment-436030744, or mute the thread https://github.com/notifications/unsubscribe-auth/ADxtkK2QdLT1D4N6xPXaLA1LOVha7M_pks5usKVNgaJpZM4V_1dG .
I can repro now and confirm it is a bug. Related: #769
Another problem is the PSAlignAssignmentStatement
rule, which is not aware of the tabs setting and tabs in general because the AST treats a tab as one indentation (since it does not know how big a tab is, which is a general problem with tabs anyway). I will try to find a generic solution that tackles the underlying problem and not only this problem in the next days
Awesome. Thanks for looking into it and finding the root cause.
: )
On Mon, Nov 26, 2018, 5:30 PM Christoph Bergmeister [MVP] < notifications@github.com wrote:
I can repro now and confirm it is a bug. Related: #769 https://github.com/PowerShell/PSScriptAnalyzer/issues/769 The problem is the interference of the UseConsistentWhitespace rule around the operator. I will try to find a generic solution that tackles the underlying problem and not only this problem in the next days
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PowerShell/PSScriptAnalyzer/issues/1055#issuecomment-441825339, or mute the thread https://github.com/notifications/unsubscribe-auth/ADxtkMWyDWwzf_7PQyw9Rg045B_JMHqVks5uzGtvgaJpZM4V_1dG .
You're welcome. For the moment (as a workaround until I have a fix that gets released), I suggest to disable the PSAlignAssignmentStatement
rule due to the conflict with PSUseConsistentIndentation
(issue # 769):
PSAlignAssignmentStatement = @{
Enable = $false
CheckHashtable = $true
}
If you use VS-Code, then you will also need to turn off the related setting, therefore I suggest to also set the following settings at the moment as a workaround
"powershell.codeFormatting.alignPropertyValuePairs": false,
"powershell.codeFormatting.whitespaceAroundOperator": false,
"editor.insertSpaces": false
To summarise the issues at the moment:
PSAlignAssignmentStatement
conflicts with the definition of PSUseConsistentWhitespace
, which is issue #769 but in addition to that PSAlignAssignmentStatement
is not tab aware -> The PSAlignAssignmentStatement
rule needs to be integrated into the PSUseConsistentWhitespace
rulePSUseConsistentIndentation
also clashes with PSUseConsistentWhitespace
in the sense that PSUseConsistentWhitespace
is not aware of the type of whitespace type (it only uses spaces). Also, the documentation around the IndentationSize
setting of it needs to be refined as this settings only applies only if the Kind
is space
but not tab
because it gets internally set to 1
when using tabs
(IndentationSize
is the number of indendation characters)I propose to merge both PSAlignAssignmentStatement
and PSUseConsistentIndentation
into PSUseConsistentWhitespace
to avoid conflicts between the rules and share the type of whitespace between them
May I ask why you prefer tabs (since VS-Code and its extensions actually make it hard by automatically converting stuff to spaces?)?
Steps to reproduce
Expected behavior
It should preserve tabs (anywhere) but in this case specifically, between the key and the equal sign
Actual behavior
It is changing out tabs for spaces between the key and equal sign. Also, I noticed it is also did not convert some tabs to spaces. If there is only one tab between the key and equal sign, it didn't convert the tab to spaces. My guess is the tab isn't a full tab (meaning it would only be 1-3 spaces and not the full 4)
Environment data