From 3faaa397e94f7ef8b4b0818b4906277bab60d131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 17 Oct 2010 18:06:02 +0200 Subject: [PATCH] manual: added info about warning/style/performance. Ticket: #2106 --- man/manual.docbook | 54 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/man/manual.docbook b/man/manual.docbook index 77d816013..33fb40f11 100644 --- a/man/manual.docbook +++ b/man/manual.docbook @@ -110,10 +110,48 @@ Checking path/file2.cpp...
- Stylistic issues + Warning, Style and Performance - By default Cppcheck will only check for bugs. There are also a few - checks for stylistic issues. + By default Cppcheck will only check for bugs. There are more + checks: + + + + warning + + + suggestions about defensive programming to prevent + bugs + + + + + style + + + stylistic issues related to code cleanup (unused functions, + redundant code, constness, and such) + + + + + performance + + + suggestions for making the code faster + + + + + The scope of style is limited. The focus of + Cppcheck development is to detect bugs. + Cppcheck is not a style-checker. + + You should always be skeptic about performance + messages. Fixing them doesn't necessarily make your code more readable, + at least that is not the intention. Cppcheck doesn't try to detect + hotspots so fixing performance messages might have no + measurable difference. Here is a simple code example: @@ -126,13 +164,15 @@ Checking path/file2.cpp... } } - To enable stylistic checks, use the --style flag: + To enable these checks, use the --enable=style command: - cppcheck --enable=style file1.c + cppcheck --enable=style file3.c - The reported error is: + The output from Cppcheck is: - [file3.c:3]: (style) The scope of the variable i can be limited + Checking file3.c... +[file3.c:3]: (style) Variable 'i' is assigned a value that is never used +[file3.c:3]: (style) The scope of the variable i can be reduced