Skip to content

Commit d4c56b5

Browse files
committed
Ignore some message of cppcheck
1 parent aa64a42 commit d4c56b5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

app/src/main/java/com/duy/ccppcompiler/compiler/analyze/CppCheckOutputParser.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@
4242
*/
4343

4444
public class CppCheckOutputParser implements PatternAwareOutputParser {
45+
//ignore message: analysis:::information:Cppcheck cannot find all the include files (use --check-config for details)
46+
public static final String PREFIX = "analysis:";
47+
public static final String TEMPLATE = /* */"--template=\"" + PREFIX + "{file}:{line}:{severity}:{message}\"";
48+
private static final Pattern PATTERN = Pattern.compile("^" + PREFIX + "(\\S+):([0-9]+):([^:]+):(.*)");
4549

46-
public static final String TEMPLATE = "--template=\"analysis:{file}:{line}:{severity}:{message}\"";
47-
private static final Pattern PATTERN = Pattern.compile("^analysis:(\\S+):([0-9]+):([^:]+):(.*)");
50+
//ignore message: Checking /data/user/0/com.duy.c.cpp.compiler/cache/cppcheck/tmp/binary-operator-overloading.cpp...
51+
private static final String CHECKING = "Checking";
4852

4953
public CppCheckOutputParser() {
5054
}
@@ -54,7 +58,6 @@ public boolean parse(@NonNull String line, @NonNull OutputLineReader reader, @No
5458
@NonNull ILogger logger) {
5559
Matcher matcher = PATTERN.matcher(line);
5660
try {
57-
5861
if (matcher.find()) {
5962
File file = new File(matcher.group(1));
6063
int lineNumber = Integer.parseInt(matcher.group(2));
@@ -65,6 +68,12 @@ public boolean parse(@NonNull String line, @NonNull OutputLineReader reader, @No
6568
messages.add(message);
6669
return true;
6770
}
71+
if (line.startsWith(PREFIX)) {
72+
return true;
73+
}
74+
if (line.startsWith(CHECKING)) {
75+
return true;
76+
}
6877
} catch (Exception e) {
6978
e.printStackTrace();
7079
}

0 commit comments

Comments
 (0)