From ac60a41a7ed6045e96c58310402a279b55f6349e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 5 Dec 2010 14:08:49 +0100 Subject: [PATCH] Writing rules: use 'cppcheck --rule=.+' instead of 'cppcheck --debug' to see simplified code --- man/writing-rules.docbook | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/man/writing-rules.docbook b/man/writing-rules.docbook index deb2ba782..3abb2ec12 100644 --- a/man/writing-rules.docbook +++ b/man/writing-rules.docbook @@ -140,24 +140,19 @@ free(p); } - To see the simplified code use cppcheck --debug - dealloc.cpp. + To see the simplified code you can use cppcheck + --rule=".+" dealloc.cpp: - ##file dealloc.cpp -1: void f ( ) { -2: if ( p ) { -3: free ( p ) ; } -4: } + $ ./cppcheck --rule=".+" dealloc.cpp +Checking dealloc.cpp... +[dealloc.cpp:1]: (style) found ' void f ( ) { if ( p ) { free ( p ) ; } }' - In the --debug output there are line feeds and - line numbers. But the newlines and line numbers are only there to make - the output easier to read. The real simplified code is written on a - single line: + In short, the simplified code is: - void f ( ) { if ( p ) { free ( p ) ; } } + void f ( ) { if ( p ) { free ( p ) ; } } - Now we can use cppcheck --rule to develop a - regular expression. + Now that the simplified code is known we can create a regular + expression: $ cppcheck --rule="if \( p \) { free \( p \) ; }" dealloc.cpp Checking dealloc.cpp...