From 227e61c61acaeb2821349595f61aaa0a1f30b1bb Mon Sep 17 00:00:00 2001 From: Inho Oh Date: Thu, 2 Nov 2023 14:31:05 +0900 Subject: [PATCH] update for clang-tidy Use `clang` compiler instead of `gcc`. Remove ansi color from `run-clang-tidy` result. Signed-off-by: Inho Oh --- Dockerfile | 10 ++++++---- dotfiles/.clang-tidy | 19 +++++++++++++++++++ run_codereview.sh | 17 ++++++----------- 3 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 dotfiles/.clang-tidy diff --git a/Dockerfile b/Dockerfile index f00f674..b9a4dbe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,8 @@ RUN apt-get update \ && apt-get update && apt-get install -y --no-install-recommends \ apt-utils \ automake \ - clang-format clang-tidy clang-tools \ + clang clang-format clang-tidy clang-tools \ + colorized-logs \ cppcheck \ debianutils \ debhelper \ @@ -24,7 +25,7 @@ RUN apt-get update \ gstreamer1.0-pulseaudio \ iputils-ping \ jq \ - rapidjson-dev \ + rapidjson-dev \ less \ libnugu-epd-dbg \ libnugu-kwd-dbg \ @@ -48,7 +49,7 @@ RUN apt-get update \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY dotfiles/.vimrc dotfiles/.zshrc dotfiles/.tigrc /root/ +COPY dotfiles/.vimrc dotfiles/.zshrc dotfiles/.tigrc dotfiles/.clang-tidy /root/ COPY run_codechecker run_codereview.sh /usr/bin/ COPY patches/* /tmp/ COPY install_ddebs.sh /usr/bin/ @@ -71,4 +72,5 @@ RUN git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh --depth && rm /tmp/*.patch \ && cd /tmp && git clone https://github.com/webispy/mdbus.git && cd mdbus \ && ./autogen.sh --prefix=/usr && make install \ - && rm -rf /tmp/mdbus + && rm -rf /tmp/mdbus \ + && cp /root/.clang-tidy / diff --git a/dotfiles/.clang-tidy b/dotfiles/.clang-tidy new file mode 100644 index 0000000..ba226f1 --- /dev/null +++ b/dotfiles/.clang-tidy @@ -0,0 +1,19 @@ +# Default +# - Disable all +# Enable +# - clang* +# - perf* +# - cert* +# Exclude +# - performance-no-int-to-ptr +# - cert-dcl37-c +# - cert-dcl51-cpp +Checks: '-*, + clang*, + perf*, + cert*, + -performance-no-int-to-ptr, + -cert-dcl37-c, + -cert-dcl51-cpp' +CheckOptions: +InheritParentConfig: true diff --git a/run_codereview.sh b/run_codereview.sh index 8ee4499..dd1a938 100755 --- a/run_codereview.sh +++ b/run_codereview.sh @@ -1,23 +1,18 @@ -#!/bin/sh - -mkdir -p temp_build -cd temp_build +#!/bin/bash CLANG_RESULT_FILE="result.log" CHECKER_REPORT_FILE="report.json" echo "step-1. generate compile_commands.json" -cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../ > /dev/null +cmake -S . -B temp_build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ > /dev/null +cp temp_build/compile_commands.json . echo "step-2. run clang-tidy tools" -run-clang-tidy -checks='-*,clang*,perf*,cert*' > $CLANG_RESULT_FILE +run-clang-tidy | tee >(ansi2txt > $CLANG_RESULT_FILE) -echo "step-3. run code checker" +echo "step-3. run code checker and generate $CHECKER_REPORT_FILE" set -e run_codechecker $CLANG_RESULT_FILE $@ -echo "step-4. codechecker report generate to $CHECKER_REPORT_FILE" -mv $CHECKER_REPORT_FILE .. - -cd .. +echo "step-4. remove temp build directory" rm -rf temp_build