Skip to content

Commit

Permalink
More default suppressions, minor edit, version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
VioletGiraffe committed Mar 17, 2014
1 parent 787185d commit f929545
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 14 deletions.
4 changes: 2 additions & 2 deletions CPPCheckPlugin/AnalyzerCppcheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ private static bool MatchMasksList(string line, HashSet<string> masks)
{
foreach (var mask in masks)
{
Regex rgx = new Regex(mask);
if (rgx.IsMatch(line))
Regex rgx = new Regex(mask.ToLower());
if (rgx.IsMatch(line.ToLower()))
return true;
}
return false;
Expand Down
45 changes: 37 additions & 8 deletions CPPCheckPlugin/CPPCheckPluginPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,39 @@ private static void CreateDefaultGlobalSuppressions()
suppressionsInfo.SkippedIncludesMask.Add(".*Microsoft Visual Studio.*");
suppressionsInfo.SkippedIncludesMask.Add(".*Microsoft SDKs.*");
suppressionsInfo.SkippedIncludesMask.Add(".*boost.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\ActiveQt.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\Qt.*");

This comment has been minimized.

Copy link
@Altren

Altren Mar 17, 2014

Collaborator

This line is actually include all include\Qt lines below so lines 44-68 are not needed at all.
Also this would not exlude Qt if it is included without backslashes, i.e. with ".../include/Qt..."

This comment has been minimized.

Copy link
@VioletGiraffe

VioletGiraffe Mar 17, 2014

Author Owner

@Altren: hmm, indeed. Then it's not a good solution because I can easily imagine this regexp matching a path within the user's project.

This comment has been minimized.

Copy link
@Altren

Altren Mar 17, 2014

Collaborator

Yep, that's why I not added Qt by default. Default list should be as small as possible to make checks for new user work for few minutes maximum. Excluding relatively small parts makes no sense, and anyone can add those any time later if he want to. First I wanted to add boost with slashes as well (to avoid conflicts with user paths such as, f.e. "booster", but then it would not work even in my case - I use "D:\libs\boost_1_49_0" and some other users might have "1_49_0_boost", so even slash at start or end would not help here.

This comment has been minimized.

Copy link
@VioletGiraffe

VioletGiraffe Mar 18, 2014

Author Owner

@Altren : All the known big libraries must be excluded. That way a new user who don't know all the settings will get a working add-in out of the box. It will not run for hours, and it will not flood the output with issues found in qstring.h. Did you see how many messages almost every Qt header header produces? A ton!

This comment has been minimized.

Copy link
@Altren

Altren Mar 18, 2014

Collaborator

Then there should be default suppressions, but not default excluded paths. Keep in mind, that if cppcheck miss some type (do not have needed includes) it is likely that it would miss suspicious code with that type.

This comment has been minimized.

Copy link
@VioletGiraffe

VioletGiraffe Mar 18, 2014

Author Owner

Yes, I understand that, but cppcheck cannot handle big sources. Otherwise I'd go with checking preprocessed files. But that's just not feasible. We could, instead of excluding libraries altogether from include paths, add individual files to ignore list so that they don't flood output. But then performance is unacceptable, so it's not an option unless cppcheck becomes 10 times faster (which will probably never happen). There are fast static analysis tools (for ex., PVS-studio has no problem checking preprocessed files and finds more issues), but cppcheck is certainly not one of them.

suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtCore.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtDeclarative.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtGui.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtMultimedia.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtNetwork.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtOpenGL.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtOpenVG.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtScript.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtScriptTools.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtSql.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtSvg.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtTest.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtWebKit.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtXml.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtXmlPatterns.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtConcurrent.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtMultimediaWidgets.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtOpenGLExtensions.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtQml.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtQuick.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtSensors.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtWebKitWidgets.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtWidgets.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtZlib.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\include\\QtV8.*");
suppressionsInfo.SkippedIncludesMask.Add(@".*\\mkspecs\\win32-.*");

suppressionsInfo.SkippedFilesMask.Add("^moc_.*\\.cpp$");
suppressionsInfo.SkippedFilesMask.Add("^qrc_.*\\.cpp$");
suppressionsInfo.SkippedFilesMask.Add("^ui_.*\\.h$");

suppressionsInfo.SaveToFile(globalSuppresionsFilePath);
}
}
Expand Down Expand Up @@ -193,7 +226,7 @@ private void documentSaved(Document document)

if (Properties.Settings.Default["CheckSavedFiles"] == null)
{
DialogResult reply = MessageBox.Show("Do you want to start analysis any time file is saved? It will clear previous analysis results.\nYou can change this behavior in cppcheck settings.", "Cppcheck: start analysis when file is saved?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
DialogResult reply = MessageBox.Show("Do you want to start analysis any time a file is saved? It will clear previous analysis results.\nYou can change this behavior in cppcheck settings.", "Cppcheck: start analysis when file is saved?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
Properties.Settings.Default.CheckSavedFiles = (reply == DialogResult.Yes);
if (reply == DialogResult.No)
return;
Expand Down Expand Up @@ -247,13 +280,9 @@ private void checkCurrentProject()
if (fileTypeEnumConstant == "eFileTypeCppCode") // Only checking cpp files (performance)
{
String fileName = file.Name;
// Ignoring Qt MOC and UI files
if (!(fileName.StartsWith("moc_") && fileName.EndsWith(".cpp")) && !(fileName.StartsWith("ui_") && fileName.EndsWith(".h")) && !(fileName.StartsWith("qrc_") && fileName.EndsWith(".cpp")))
{
SourceFile f = createSourceFile(file.FullPath, currentConfig, project);
if (f != null)
files.Add(f);
}
SourceFile f = createSourceFile(file.FullPath, currentConfig, project);
if (f != null)
files.Add(f);
}
}
break; // Only checking one project at a time for now
Expand Down
2 changes: 1 addition & 1 deletion CPPCheckPlugin/CppcheckSettings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private void EditProjectSuppressions(object sender, RoutedEventArgs e)
settings.ShowDialog();
}
else
MessageBox.Show("No active C++ project.");
MessageBox.Show("No C++ project selected in the solution explorer.");
}

private void MessagesListClick(object sender, RoutedEventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions CPPCheckPlugin/SuppressionsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public class SuppressionsInfo
// list of suppressions in cppcheck format
public HashSet<string> SuppressionLines = new HashSet<string>();

// list of regular expresions with files that should be excluded from check
// list of regular expressions with files that should be excluded from check
public HashSet<string> SkippedFilesMask = new HashSet<string>();

// list of regular expresions with include paths that should be excluded from includes list
// list of regular expressions with include paths that should be excluded from includes list
public HashSet<string> SkippedIncludesMask = new HashSet<string>();

public void SaveToFile(string suppresionsFilePath)
Expand Down
2 changes: 1 addition & 1 deletion CPPCheckPlugin/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="127d8bd3-8cd7-491a-9a63-9b4e89118da9" Version="1.0.5" Language="en-US" Publisher="-" />
<Identity Id="127d8bd3-8cd7-491a-9a63-9b4e89118da9" Version="1.1.0" Language="en-US" Publisher="-" />
<DisplayName>cppcheck add-in</DisplayName>
<Description xml:space="preserve">Integration for cppcheck - C/C++ code static analysis tool </Description>
<License>PackageInstallerLicense.txt</License>
Expand Down

0 comments on commit f929545

Please sign in to comment.