Module: check_mk
Branch: master
Commit: 14dd66ab533cbedc519a6540a3104d68c54b54f3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=14dd66ab533cbe…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Feb 3 15:15:05 2016 +0100
Added clang-tidy Makefile target plus initial configuration.
---
.clang-tidy | 37 +++++++++++++++++++++++++++++++++++++
Makefile | 10 +++++++---
compiled_sources | 7 +++++++
3 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 0000000..23e8d35
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,37 @@
+---
+# Classification of the excludes:
+#
+# * unclear, need to figure out if we want that:
+# * cert-err58-cpp ("construction of 'foo' with static storage
duration may throw an exception that cannot be caught")
+# * cppcoreguidelines-pro-bounds-array-to-pointer-decay ("do not implicitly
decay an array into a pointer; consider using gsl::array_view or an explicit cast
instead")
+# * cppcoreguidelines-pro-bounds-constant-array-index ("do not use array
subscript when the index is not an integer constant expression; use gsl::at()
instead")
+# * cppcoreguidelines-pro-bounds-pointer-arithmetic ("do not use pointer
arithmetic")
+# * google-runtime-int ("consider replacing 'unsigned long' with
'uint64'")
+#
+# * undesirable checks:
+# * cppcoreguidelines-pro-type-static-cast-downcast ("do not use static_cast
to downcast from a base to a derived class; use dynamic_cast instead")
+# * llvm-include-order ("#includes are not sorted properly")
+#
+# * desirable checks, but hard to fix currently:
+# * cert-dcl50-cpp ("do not define a C-style variadic function; consider using
a function parameter pack or currying instead")
+# * cppcoreguidelines-pro-type-vararg ("do not call c-style vararg
functions")
+#
+# * desirable checks, but some places need to be suppressed:
+# * cppcoreguidelines-pro-type-const-cast ("do not use const_cast")
+#
+# * desirable checks, but not yet fixed:
+# * cppcoreguidelines-pro-type-cstyle-cast ("do not use C-style cast to
convert between unrelated types")
+# * cppcoreguidelines-pro-type-reinterpret-cast ("do not use
reinterpret_cast")
+# * google-readability-braces-around-statements ("statement should be inside
braces")
+# * google-readability-casting ("C-style casts are discouraged; use
reinterpret_cast")
+# * readability-braces-around-statements ("statement should be inside
braces")
+# * readability-else-after-return ("don't use else after return")
+# * readability-implicit-bool-cast ("implicit cast 'foo' ->
bool")
+# * readability-inconsistent-declaration-parameter-name ("function
'foo' has a definition with different parameter names")
+# * readability-named-parameter ("all parameters should be named in a
function")
+#
+Checks:
'*,-cert-dcl50-cpp,-cert-err58-cpp,-clang-analyzer-alpha*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-cstyle-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-vararg,-google-readability-braces-around-statements,-google-readability-casting,-google-runtime-int,-llvm-include-order,-readability-braces-around-statements,-readability-else-after-return,-readability-implicit-bool-cast,-readability-inconsistent-declaration-parameter-name,-readability-named-parameter'
+CheckOptions:
+ - key: google-readability-namespace-comments.SpacesBeforeComments
+ value: '1'
+...
diff --git a/Makefile b/Makefile
index aa2e4bc..f35e1a5 100644
--- a/Makefile
+++ b/Makefile
@@ -35,6 +35,7 @@ TAROPTS := --owner=root --group=root --exclude=.svn
--exclude=*~ \
CLANG_VERSION := 3.8
CLANG_FORMAT := clang-format-$(CLANG_VERSION)
+CLANG_TIDY := clang-tidy-$(CLANG_VERSION)
SCAN_BUILD := scan-build-$(CLANG_VERSION)
CPPCHECK := cppcheck
DOXYGEN := doxygen
@@ -70,9 +71,9 @@ FILES_TO_FORMAT := $(wildcard $(addprefix agents/,*.cc *.c *.h)) \
$(wildcard $(addprefix mkeventd/src/,*.cc *.c *.h))
.PHONY: all check-binaries check check-permissions check-spaces check-version \
- clang-analyzer clean cppcheck dist documentation format headers \
- healspaces help iwyu minify-js mk-eventd mk-livestatus mrproper \
- optimize-images packages setup setversion version
+ clang-analyzer clang-tidy clean cppcheck dist documentation format \
+ headers healspaces help iwyu minify-js mk-eventd mk-livestatus \
+ mrproper optimize-images packages setup setversion version
all: dist packages
@@ -262,6 +263,9 @@ compile_commands.json: $(FILES_TO_FORMAT)
$(MAKE) -C livestatus clean
$(BEAR) $(MAKE) -C livestatus -j8
+clang-tidy: compile_commands.json
+ ./compiled_sources | xargs $(CLANG_TIDY)
+
# Not really perfect rules, but better than nothing
iwyu:
$(MAKE) -C livestatus clean
diff --git a/compiled_sources b/compiled_sources
new file mode 100755
index 0000000..89c6d23
--- /dev/null
+++ b/compiled_sources
@@ -0,0 +1,7 @@
+#!/usr/bin/python
+
+import json
+
+with open('compile_commands.json') as cc:
+ for command_object in json.load(cc):
+ print('"%s"' % command_object['file'])