From 545a98c6895f3adbef6f29ae4677d8b37098f0f7 Mon Sep 17 00:00:00 2001 From: Vitalii Arteev Date: Tue, 11 Aug 2020 19:29:03 +0200 Subject: [PATCH] =?UTF-8?q?Add=20the=20clang-tidy=20is=20a=20clang-based?= =?UTF-8?q?=20C++=20=E2=80=9Clinter=E2=80=9D=20tool.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/clang_tidy/read.me | 14 ++++++++++++++ tests/clang_tidy/test_clang_tidy.sh | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/clang_tidy/read.me create mode 100755 tests/clang_tidy/test_clang_tidy.sh diff --git a/tests/clang_tidy/read.me b/tests/clang_tidy/read.me new file mode 100644 index 00000000..87bfb043 --- /dev/null +++ b/tests/clang_tidy/read.me @@ -0,0 +1,14 @@ +# clang-tidy is a clang-based C++ “linter” tool. + +# source code: https://llvm.org/docs/GettingStarted.html#checkout +# docs: http://clang.llvm.org/extra/clang-tidy/ +# install clang-tidy, clang-tools using apt-get: + $ sudo apt install clang-tidy clang-tools + +# How to use + Create a build folder and jump into it: + $ mkdir build && cd "$_" + Run the script: + $ facelift/tests/clang_tidy/test_clang_tidy.sh + Results of analysis will be available in the folder + $ clang_tidy/report_yy-mm-dd-hhmmss/report diff --git a/tests/clang_tidy/test_clang_tidy.sh b/tests/clang_tidy/test_clang_tidy.sh new file mode 100755 index 00000000..67e18913 --- /dev/null +++ b/tests/clang_tidy/test_clang_tidy.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -eu +# for info see 'read.me' + +DIR_BUILD=$PWD +DIR_SRC=$(cd $(dirname "$0")/../..; pwd -P) +DIR_REPORT="$DIR_BUILD/clang-tidy/report_$(date +"%y-%m-%d-%H%M%S")" +REPORT_ANALYZER="$DIR_REPORT/report" +# Use -checks=* to see all available checks. See more settings: https://clang.llvm.org/extra/clang-tidy/ +CLANG_TIDY_FLAGS="clang-tidy;-extra-arg=-std=c++14;-header-filter=. -p=${DIR_BUILD};-checks=*;-enable-check-profile" + +# Build facelift with flags +mkdir -p $DIR_REPORT +cmake -DCMAKE_CXX_CLANG_TIDY=${CLANG_TIDY_FLAGS} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DFACELIFT_BUILD_TESTS=ON ${DIR_SRC} && cmake --build ${DIR_BUILD} 2>$REPORT_ANALYZER +# Show reports +echo "clang-tidy report generated: "$REPORT_ANALYZER