Skip to content

Commit

Permalink
Merge pull request SonarOpenCommunity#1925 from guwirth/cppcheck-2.1
Browse files Browse the repository at this point in the history
support cppcheck v2.1 rules
  • Loading branch information
guwirth authored Aug 23, 2020
2 parents 447990d + dcedc26 commit 29a7a9d
Show file tree
Hide file tree
Showing 6 changed files with 1,819 additions and 344 deletions.
2,147 changes: 1,811 additions & 336 deletions cxx-sensors/src/main/resources/cppcheck.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void createRulesTest() {
def.define(context);

RulesDefinition.Repository repo = context.repository(CxxCppCheckRuleRepository.KEY);
assertEquals(494, repo.rules().size());
assertEquals(499, repo.rules().size());
}

}
Binary file added cxx-sensors/src/tools/cwec_latest.xml.zip
Binary file not shown.
Binary file removed cxx-sensors/src/tools/cwec_v3.2.xml.zip
Binary file not shown.
10 changes: 5 additions & 5 deletions cxx-sensors/src/tools/generate_cppcheck_resources.cmd
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@ECHO OFF
rem @ECHO OFF

SET SCRIPT_DIR=%~dp0
SET CPPCHECK_DIR=C:\Program Files\Cppcheck
SET PYTHON_DIR=C:\Perforce\Helix-QAC-2019.2\components\python-2.7.10
SET PYTHON_DIR=C:\Perforce\Helix-QAC-2020.1\components\python-2.7.10

SET CPPCHECK_LIBRARY_ARGS=--library=avr.cfg --library=boost.cfg --library=bsd.cfg --library=cppunit.cfg --library=embedded_sql.cfg --library=gnu.cfg --library=googletest.cfg --library=gtk.cfg --library=libcerror.cfg --library=microsoft_sal.cfg --library=motif.cfg --library=nspr.cfg --library=opengl.cfg --library=posix.cfg --library=python.cfg --library=qt.cfg --library=ruby.cfg --library=sdl.cfg --library=sfml.cfg --library=sqlite3.cfg --library=std.cfg --library=windows.cfg --library=wxwidgets.cfg --library=zlib.cfg
SET CPPCHECK_LIBRARY_ARGS=--library=avr.cfg --library=boost.cfg --library=bsd.cfg --library=cfg.txt --library=cppunit.cfg --library=embedded_sql.cfg --library=gnu.cfg --library=googletest.cfg --library=gtk.cfg --library=libcerror.cfg --library=microsoft_sal.cfg --library=motif.cfg --library=nspr.cfg --library=opengl.cfg --library=posix.cfg --library=python.cfg --library=qt.cfg --library=ruby.cfg --library=sdl.cfg --library=sfml.cfg --library=sqlite3.cfg --library=std.cfg --library=windows.cfg --library=wxwidgets.cfg --library=zlib.cfg

rem wget https://cwe.mitre.org/data/xml/cwec_v3.2.xml.zip --output-document=cwec_v3.2.xml.zip && unzip -j -o cwec_v3.2.xml.zip
rem wget https://cwe.mitre.org/data/xml/cwec_latest.xml.zip --output-document=cwec_latest.xml.zip && unzip -j -o cwec_latest.xml.zip

"%CPPCHECK_DIR%\cppcheck.exe" %CPPCHECK_LIBRARY_ARGS% --errorlist --xml-version=2 > cppcheck-errorlist.xml
"%CPPCHECK_DIR%\cppcheck.exe" %CPPCHECK_LIBRARY_ARGS% --errorlist --xml-version=2 | "%PYTHON_DIR%\python.exe" cppcheck_createrules.py rules cwec_v3.2.xml > cppcheck.xml
"%CPPCHECK_DIR%\cppcheck.exe" %CPPCHECK_LIBRARY_ARGS% --errorlist --xml-version=2 | "%PYTHON_DIR%\python.exe" cppcheck_createrules.py rules cwec_v4.2.xml > cppcheck.xml
"%PYTHON_DIR%\python.exe" utils_createrules.py comparerules "%SCRIPT_DIR%\..\main\resources\cppcheck.xml" cppcheck.xml > cppcheck-comparison.md
4 changes: 2 additions & 2 deletions cxx-sensors/src/tools/generate_cppcheck_resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ done

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

wget https://cwe.mitre.org/data/xml/cwec_v3.2.xml.zip --output-document=cwec_v3.2.xml.zip && unzip -j -o cwec_v3.2.xml.zip
wget https://cwe.mitre.org/data/xml/cwec_latest.xml.zip --output-document=cwec_latest.xml.zip && unzip -j -o cwec_latest.xml.zip

cppcheck ${CPPCHECK_LIBRARY_ARGS} --errorlist --xml-version=2 > cppcheck-errorlist.xml
cppcheck ${CPPCHECK_LIBRARY_ARGS} --errorlist --xml-version=2 | python cppcheck_createrules.py rules cwec_v3.2.xml > cppcheck.xml
cppcheck ${CPPCHECK_LIBRARY_ARGS} --errorlist --xml-version=2 | python cppcheck_createrules.py rules cwec_v4.2.xml > cppcheck.xml
python utils_createrules.py comparerules $SCRIPT_DIR/../main/resources/cppcheck.xml cppcheck.xml > cppcheck-comparison.md

0 comments on commit 29a7a9d

Please sign in to comment.