From 45a3f1ede872956f4599df9fe4aa5c5502479f6a Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Wed, 13 Dec 2017 19:03:21 +1000 Subject: [PATCH] tools: Added cppcheck for C/C++ files. --- README.md | 4 ++-- TODO | 2 ++ vigil/tools.py | 9 +++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b7b9ca8..7ae3596 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,9 @@ Extensions | Tools .pl .pm .t | [perl_syntax](https://en.wikipedia.org/wiki/Perl) • [perldoc](http://perldoc.perl.org/) • [perltidy](http://perltidy.sourceforge.net/) .pod .pod6 | [perldoc](http://perldoc.perl.org/) .java | [uncrustify](https://github.com/uncrustify/uncrustify) -.c .h | [c_syntax_gcc](https://gcc.gnu.org/) • [splint](http://www.splint.org/) • [uncrustify](https://github.com/uncrustify/uncrustify) +.c .h | [c_syntax_gcc](https://gcc.gnu.org/) • [splint](http://www.splint.org/) • [uncrustify](https://github.com/uncrustify/uncrustify) • [cppcheck](http://sourceforge.net/p/cppcheck/wiki/Home/) .o | [objdump_headers](https://en.wikipedia.org/wiki/Objdump) • [objdump_disassemble](https://en.wikipedia.org/wiki/Objdump) • [readelf](https://en.wikipedia.org/wiki/Objdump) -.cc .cpp .hpp | [cpp_syntax_gcc](https://gcc.gnu.org/) • bcpp • [uncrustify](https://github.com/uncrustify/uncrustify) +.cc .cpp .hpp | [cpp_syntax_gcc](https://gcc.gnu.org/) • bcpp • [uncrustify](https://github.com/uncrustify/uncrustify) • [cppcheck](http://sourceforge.net/p/cppcheck/wiki/Home/) .pdf | [pdf2txt](http://www.unixuser.org/~euske/python/pdfminer/) .html | [html_syntax](http://www.html-tidy.org/) • [tidy](http://www.html-tidy.org/) • [html2text](http://www.mbayer.de/html2text/) .php | [php7_syntax](https://en.wikipedia.org/wiki/PHP) diff --git a/TODO b/TODO index 20ce04e..c75bf98 100644 --- a/TODO +++ b/TODO @@ -6,6 +6,7 @@ Todo (tool related) - Report on python doctests. (also coverage of) - Cache tools._python_version. - Colourise git_diff. +- Add shellcheck tool for shell scripts. Done @@ -164,6 +165,7 @@ Done <- Yes, but wait for it to be included in python, or until it is an ubuntu package. - Add bandit tool for python. - Created a setup.py file. +- Add cppcheck tool for C and C++. A-syntax, B-tests, C-auto docs, D-lint, E-coverage, F-profile, G-tidy, H-import deps A B C D E F G H diff --git a/vigil/tools.py b/vigil/tools.py index bb80820..d724514 100644 --- a/vigil/tools.py +++ b/vigil/tools.py @@ -612,6 +612,11 @@ def uncrustify(path): return status, _syntax_highlight_using_path(stdout, path) +@deps(deps={"cppcheck"}, url="cppcheck", executables={"cppcheck"}) +def cppcheck(path): + return _run_command(["cppcheck", path]) + + @deps(deps={"php7.1-cli"}, url="https://en.wikipedia.org/wiki/PHP", executables={"php7.1"}) def php7_syntax(path): @@ -815,9 +820,9 @@ TOOLS_FOR_EXTENSIONS = \ # (["p6", "pm6"], [perl6_syntax, perldoc]), (["pod", "pod6"], [perldoc]), (["java"], [uncrustify]), - (["c", "h"], [c_syntax_gcc, splint, uncrustify]), + (["c", "h"], [c_syntax_gcc, splint, uncrustify, cppcheck]), (["o"], [objdump_headers, objdump_disassemble, readelf]), - (["cc", "cpp", "hpp"], [cpp_syntax_gcc, bcpp, uncrustify]), + (["cc", "cpp", "hpp"], [cpp_syntax_gcc, bcpp, uncrustify, cppcheck]), (["pdf"], [pdf2txt]), (["html"], [html_syntax, tidy, html2text]), (["php"], [php7_syntax]),