Skip to content

Commit 71026a6

Browse files
maksim-grebeniuk-sonarsourcesonartech
authored andcommitted
SONARIAC-2499 Docker analyzer should not fail to parse file endings with RUN instruction that ends with backslashes (#662)
GitOrigin-RevId: 3fe63e69d82597e205296af284ff275a04a553ee
1 parent e2a2efb commit 71026a6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

iac-extensions/docker/src/main/java/org/sonar/iac/docker/parser/SourceCodeFinder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public String findSourceCode(TextPointer from, TextPointer to) {
5252

5353
var nodeSource = IntStream.rangeClosed(startLine, endLine)
5454
.mapToObj(i -> {
55+
if (i >= lines.size() && lines.get(lines.size() - 1).stripTrailing().endsWith("\\")) {
56+
return "";
57+
}
5558
var line = lines.get(i);
5659
int start = (i == startLine) ? startLineOffset : 0;
5760
int end = (i == endLine) ? endLineOffset : line.length();

0 commit comments

Comments
 (0)