Skip to content

Commit 3b46642

Browse files
author
Kapil Borle
committed
Add logic for indentation in multi-line pipeline
1 parent 2ef5b54 commit 3b46642

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Rules/UseConsistentIndentation.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,21 @@ public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string file
9999
// we add this redundant check
100100
if (onNewLine)
101101
{
102-
AddViolation(token, indentationLevel, diagnosticRecords, ref onNewLine);
102+
var tempIndentationLevel = indentationLevel;
103+
104+
// Ignore comments
105+
int j = k - 2;
106+
while (j > 0 && tokens[j].Kind == TokenKind.Comment)
107+
{
108+
--j;
109+
}
110+
111+
if (j >= 0 && tokens[j].Kind == TokenKind.Pipe)
112+
{
113+
++tempIndentationLevel;
114+
}
115+
116+
AddViolation(token, tempIndentationLevel, diagnosticRecords, ref onNewLine);
103117
}
104118
break;
105119
}

0 commit comments

Comments
 (0)