-
Notifications
You must be signed in to change notification settings - Fork 798
Static Code Analysis
Gökhan Şimşek edited this page Jan 6, 2021
·
19 revisions
In addition to scripts below, we also use real time clang-tidy
code analysis which is visible while coding in visual studio editor - a new feature in Visual Studio 2019. (https://devblogs.microsoft.com/cppblog/code-analysis-with-clang-tidy-in-visual-studio/)
Our list of checks: clang-checks.txt
Note: Currently, cmake
does not support enabling this feature. That's why, bin/configure
script uses enable-visual-studio-clang-tidy.py to enable this feature automatically.
To run static code analysis, go to bin
directory. And execute one of the following scripts:
(Runs in release
mode by default, add debug
when needed & supported)
|-- Run Static Code Analysis:
|
| // macOS, Linux
| $ bin/run-clang-tidy
| $ bin/run-scan-build
|
| // Windows
| $ bin/run-cppcheck <FILE_PATH OR DIR> (Default: /src/robomongo/)
| $ bin/run-vs-code-analysis
|__________________________________________________________________
E.g.:
// macOS, Linux
\robo\bin>run-clang-tidy
....
------------------------------------------------
clang-tidy finished
Mode : Release
CLANG_TIDY_BUILD_DIR: /opt/robo/build/clang-tidy-Release
Command executed : /opt/robo/bin/run-clang-tidy.py -checks=bugprone-*,cert-*,clang-analyzer-*,cppcoreguidelines-*,concurrency-*,hicpp-*,llvm-*,misc-*,performance-*,readability-* /opt/robo/src/robomongo/
------------------------------------------------
// Windows
\robo\bin>run-cppcheck.bat
---------------------- Running cppcheck ----------------------
Checking ..\src\robomongo\app\main.cpp ...
Checking ..\src\robomongo\app\main.cpp: Q_OS_MAC...
Checking ..\src\robomongo\app\main.cpp: Q_OS_WIN...
1/125 files checked 0% done
Checking ..\src\robomongo\app\main_mongo.cpp ...
...
---------------------- Info ----------------------
Cppcheck 2.1
Command called: cppcheck ..\src\robomongo\ --enable=all --std=c++17
---------------------- End of cppcheck ----------------------