Skip to content

Commit 3ca3e74

Browse files
authored
Merge pull request #62 from firewave/stuff
some notification cleanups and suppressions of unwanted errors
2 parents 8e46962 + e956606 commit 3ca3e74

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

src/com/github/johnthagen/cppcheck/CppCheckInspectionImpl.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
import com.intellij.execution.configurations.GeneralCommandLine;
88
import com.intellij.execution.process.CapturingProcessHandler;
99
import com.intellij.execution.process.ProcessOutput;
10-
import com.intellij.notification.Notification;
1110
import com.intellij.notification.NotificationType;
12-
import com.intellij.notification.Notifications;
1311
import com.intellij.openapi.editor.Document;
1412
import com.intellij.openapi.progress.EmptyProgressIndicator;
1513
import com.intellij.openapi.progress.ProcessCanceledException;
@@ -69,10 +67,9 @@ public static List<ProblemDescriptor> parseOutput(@NotNull final PsiFile psiFile
6967

7068
if (VERBOSE_LOG) {
7169
// TODO: provide XML output via a "Show Cppcheck output" action - event log messages are truncated
72-
Notifications.Bus.notify(new Notification("Cppcheck",
73-
"Cppcheck execution output for " + psiFile.getName(),
70+
CppcheckNotification.send("execution output for " + psiFile.getVirtualFile().getCanonicalPath(),
7471
cppcheckOutput,
75-
NotificationType.INFORMATION));
72+
NotificationType.INFORMATION);
7673
}
7774

7875
final List<ProblemDescriptor> descriptors = new ArrayList<>();
@@ -119,6 +116,16 @@ public static List<ProblemDescriptor> parseOutput(@NotNull final PsiFile psiFile
119116
continue;
120117
}
121118

119+
// suppress this warnings for now - will be properly handled in an upcoming patch
120+
if (id.equals("noValidConfiguration") || id.equals("missingInclude")) {
121+
continue;
122+
}
123+
124+
// we are never interested in these
125+
if (id.equals("unmatchedSuppression") || id.equals("purgedConfiguration")) {
126+
continue;
127+
}
128+
122129
// suppress this warning for headers until Cppcheck handles them in a better way
123130
if (SupportedExtensions.isHeaderFile(psiFile.getVirtualFile()) && id.equals("unusedStructMember")) {
124131
continue;
@@ -143,6 +150,9 @@ public static List<ProblemDescriptor> parseOutput(@NotNull final PsiFile psiFile
143150

144151
// ignore entries without location e.g. missingIncludeSystem
145152
if (location == null) {
153+
CppcheckNotification.send("no location for " + psiFile.getVirtualFile().getCanonicalPath(),
154+
id + " " + severity + " " + inconclusive + " " + errorMessage,
155+
NotificationType.ERROR);
146156
continue;
147157
}
148158

@@ -160,10 +170,9 @@ public static List<ProblemDescriptor> parseOutput(@NotNull final PsiFile psiFile
160170

161171
// Cppcheck error
162172
if (lineNumber <= 0 || lineNumber > document.getLineCount()) {
163-
Notifications.Bus.notify(new Notification("Cppcheck",
164-
"Cppcheck line number out-of-bounds " + i,
173+
CppcheckNotification.send("line number out-of-bounds for " + psiFile.getVirtualFile().getCanonicalPath(),
165174
id + " " + severity + " " + inconclusive + " " + errorMessage + " " + fileName + " " + lineNumber + " " + column,
166-
NotificationType.ERROR));
175+
NotificationType.ERROR);
167176
continue;
168177
}
169178

src/com/github/johnthagen/cppcheck/CppcheckInspection.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
import com.intellij.codeInspection.LocalInspectionTool;
55
import com.intellij.codeInspection.ProblemDescriptor;
66
import com.intellij.execution.ExecutionException;
7-
import com.intellij.notification.Notification;
87
import com.intellij.notification.NotificationType;
9-
import com.intellij.notification.Notifications;
108
import com.intellij.openapi.editor.Document;
119
import com.intellij.openapi.fileEditor.FileDocumentManager;
1210
import com.intellij.openapi.util.io.FileUtil;
@@ -66,10 +64,9 @@ public ProblemDescriptor[] checkFile(@NotNull final PsiFile file,
6664
tempFile.getName());
6765
return descriptors.toArray(new ProblemDescriptor[0]);
6866
} catch (final ExecutionException | CppcheckError | IOException | SAXException | ParserConfigurationException ex) {
69-
Notifications.Bus.notify(new Notification("Cppcheck",
70-
"Cppcheck execution failed.",
67+
CppcheckNotification.send("execution failed for " + file.getVirtualFile().getCanonicalPath(),
7168
ex.getClass().getSimpleName() + ": " + ex.getMessage(),
72-
NotificationType.ERROR));
69+
NotificationType.ERROR);
7370
} finally {
7471
if (tempFile != null) {
7572
FileUtil.delete(tempFile);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.github.johnthagen.cppcheck;
2+
3+
import com.intellij.notification.Notification;
4+
import com.intellij.notification.NotificationType;
5+
import com.intellij.notification.Notifications;
6+
import org.jetbrains.annotations.NotNull;
7+
8+
class CppcheckNotification {
9+
public static void send(@NotNull final String title, @NotNull final String content, final NotificationType type) {
10+
Notifications.Bus.notify(new Notification("Cppcheck",
11+
"Cppcheck " + title,
12+
content,
13+
type));
14+
}
15+
}

0 commit comments

Comments
 (0)