You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PSUseConsistentIndentation: Identation missing if command was broken over multiple lines #1406
If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *
Environment data
Name Value
---------
PSVersion 6.2.4
PSEdition Core
GitCommitId 6.2.4
OS Darwin 19.2.0 Darwin Kernel Version 19.2.0: Sat Nov 903:47:04 PST 2019; root:xnu-6153…
Platform Unix
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.01.18.3
Thanks for raising it and the level of detail. Very interesting and important. Next week is busy for me, but it's definitely on my tracker to investigate more. In the meantime I verified that the behaviour repros in master as well.
I think this could be due to code of PipelineIndentation, it only happens for the non-default options of it (default being NoIndentation).
The problem goes away if I the first line was just foo | and it does not matter if there is a comment line or if a line gets simplified to one line by not using backticks. This should be an easier starting point for being able to investigate what the logic does.
First investigations show that due to having 2 pipelines in the first line, the following expression prevents an increase of the expected pipeline indentation for the rule setting IncreaseIndentationForFirstPipeline
This condition was added in PR #1318 as a fix for a different but similar multi-line bug. I think if we can improve this conditional logic then this bug should be resolvable without side effects. The improvement would be to not only check if the pipe is the first pipe in a Pipeline we need to check if but in addition also if there are multiple pipes on the same line that the pipe in question is the last of those.
Activity
bergmeister commentedon Feb 9, 2020
Thanks for raising it and the level of detail. Very interesting and important. Next week is busy for me, but it's definitely on my tracker to investigate more. In the meantime I verified that the behaviour repros in master as well.
I think this could be due to code of
PipelineIndentation, it only happens for the non-default options of it (default beingNoIndentation).bergmeister commentedon Feb 17, 2020
A more simplified repro is this:
The problem goes away if I the first line was just
foo |and it does not matter if there is a comment line or if a line gets simplified to one line by not using backticks. This should be an easier starting point for being able to investigate what the logic does.bergmeister commentedon Feb 17, 2020
First investigations show that due to having 2 pipelines in the first line, the following expression prevents an increase of the expected pipeline indentation for the rule setting
IncreaseIndentationForFirstPipelinePSScriptAnalyzer/Rules/UseConsistentIndentation.cs
Line 171 in ea49400
This condition was added in PR #1318 as a fix for a different but similar multi-line bug. I think if we can improve this conditional logic then this bug should be resolvable without side effects. The improvement would be to not only check if the pipe is the first pipe in a Pipeline we need to check if but in addition also if there are multiple pipes on the same line that the pipe in question is the last of those.