Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
Fixes issue #90: added support for Cppcheck result containing file "n…
Browse files Browse the repository at this point in the history
…ofile" and line-number "0"
  • Loading branch information
Hansvdsteen committed Nov 29, 2018
1 parent b5ffbf7 commit 9435690
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public void testParseResultLines() throws Exception {
String line3 = ";;information;missingInclude;Cppcheck cannot find all the include files (use --check-config for details)";
Problem problem3 = CppcheckCommand.parseResult(line3, null);
assertProblem(problem3, null, -1, "information", "missingInclude", "Cppcheck cannot find all the include files (use --check-config for details)");

String line4="nofile;0;information;missingInclude;Cppcheck cannot find all the include files (use --check-config for details)";
Problem problem4 = CppcheckCommand.parseResult(line4, null);
assertProblem(problem4, null, -1, "information", "missingInclude", "Cppcheck cannot find all the include files (use --check-config for details)");
}

private void assertProblem(Problem problem, File file, int line, String category, String id, String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,14 @@ public static Problem parseResult(String line, IProject project) {
try {

File filename;
if (Strings.isNullOrEmpty(lineParts[0])) {
if (Strings.isNullOrEmpty(lineParts[0]) || "nofile".equals(lineParts[0])) {
filename = null;
} else {
filename = new File(lineParts[0]);
}
// if line is empty set it to -1
int lineNumber;
if (Strings.isNullOrEmpty(lineParts[1])) {
if (Strings.isNullOrEmpty(lineParts[1]) || "0".equals(lineParts[1])) {
lineNumber = -1;
} else {
lineNumber = Integer.parseInt(lineParts[1]);
Expand Down

0 comments on commit 9435690

Please sign in to comment.