From f84533f130659b0e90a1a6321361d741badfdc10 Mon Sep 17 00:00:00 2001 From: Bill O'Neil Date: Thu, 22 Jul 2021 07:26:28 -0400 Subject: [PATCH] Fix bug found by SonarQube in replaceAll --- .../java/com/stubbornjava/webapp/github/FileContentUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubbornjava-webapp/src/main/java/com/stubbornjava/webapp/github/FileContentUtils.java b/stubbornjava-webapp/src/main/java/com/stubbornjava/webapp/github/FileContentUtils.java index b4c617b7..29d27b43 100644 --- a/stubbornjava-webapp/src/main/java/com/stubbornjava/webapp/github/FileContentUtils.java +++ b/stubbornjava-webapp/src/main/java/com/stubbornjava/webapp/github/FileContentUtils.java @@ -47,8 +47,8 @@ public static Map parseContent(String raw) { int indentSpaces = matcher.group(1).length(); StringBuilder sb = new StringBuilder(); lines.stream().forEach(line -> { - line.replaceAll("\t", " "); // replace tabs with 4 spaces - sb.append(line.substring(Math.min(line.length(), indentSpaces)) + "\n"); + String replaced = line.replaceAll("\t", " "); // replace tabs with 4 spaces + sb.append(line.substring(Math.min(replaced.length(), indentSpaces)) + "\n"); }); sections.put(sectionName, new FileContent.Section(startLineNum, endLineNum, sb.toString())); }