Patch #3230 2011-11-07 02:43

alpha0010

CppCheck: filter non-C/C++ files; update commandline options
Download
3230-CppCheck_filte.patch (1.3 KB)
Category
Plugin::Bugfix
Status
Accepted
Close date
2012-03-03 12:37
Assigned to
mortenmacfly
Index: src/plugins/contrib/CppCheck/CppCheck.cpp
===================================================================
--- src/plugins/contrib/CppCheck/CppCheck.cpp    (revision 7609)
+++ src/plugins/contrib/CppCheck/CppCheck.cpp    (working copy)
@@ -221,7 +221,15 @@
     for (FilesList::iterator it = Project->GetFilesList().begin(); it != Project->GetFilesList().end(); ++it)
     {
         ProjectFile* pf = *it;
-        Input.Write(pf->relativeFilename + _T("\n"));
+         // filter to avoid including non C/C++ files
+         if (pf->relativeFilename.Mid(2) == wxT(".c")   ||
+             pf->relativeFilename.Mid(4) == wxT(".cpp") ||
+             pf->relativeFilename.Mid(3) == wxT(".cc")  ||
+             pf->relativeFilename.Mid(4) == wxT(".cxx") ||
+             FileTypeOf(pf->relativeFilename) == ftHeader)
+         {
+             Input.Write(pf->relativeFilename + _T("\n"));
+         }
     }
     Input.Close();
     // project include dirs
@@ -248,7 +256,7 @@
         }
     }
 
-    wxString CommandLine = m_CppCheckApp + _T(" --verbose --all --style --xml --file-list=") + InputFileName;
+    wxString CommandLine = m_CppCheckApp + _T(" --verbose --enable=all --enable=style --xml --file-list=") + InputFileName;
     if(!IncludeList.IsEmpty())
     {
         CommandLine += _T(" ") + IncludeList.Trim();
alpha0010 2011-11-07 22:00

If the "--enable=all" option works as it implies, the "--enable=style" option should be omitted.

alpha0010 2011-11-26 04:41

Fixed patch so it works on the trunk again; removed a little redundancy (I found another function in the sdk :) ).

mortenmacfly 2012-03-03 12:37

Applied in trunk. Thank you.