Skip to content

Apache DataFusion SQL Query Engine

ARROW-2981: [C++] improve clang-tidy usability

Benjamin Kietzman2e9d8f5857fc
diff --git a/.clang-tidy b/.clang-tidy
index b05faa4e62..0874ab0785 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -16,7 +16,9 @@
# under the License.
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,modernize-*,readability-*'
-HeaderFilterRegex: 'arrow/.*'
+# produce HeaderFilterRegex from cpp/build-support/lint_exclusions.txt with:
+# echo -n '^('; sed -e 's/*/\.*/g' cpp/build-support/lint_exclusions.txt | tr '\n' '|'; echo ')$'
+HeaderFilterRegex: '^(.*codegen.*|.*_generated.*|.*windows_compatibility.h|.*pyarrow_api.h|.*pyarrow_lib.h|.*python/config.h|.*python/platform.h|.*thirdparty/ae/.*|.*vendored/.*|.*RcppExports.cpp.*|)$'
AnalyzeTemporaryDtors: true
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
diff --git a/dev/lint/run_clang_tidy.sh b/dev/lint/run_clang_tidy.sh
new file mode 100755
index 0000000000..8068e2c1a4
--- /dev/null
+++ b/dev/lint/run_clang_tidy.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -ex
+
+mkdir -p /build/lint
+pushd /build/lint
+ cmake -GNinja /arrow/cpp
+ ninja check-clang-tidy
+popd
diff --git a/docker-compose.yml b/docker-compose.yml
index 361eeb97b1..712190d9b1 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -353,6 +353,16 @@ services:
command: arrow/dev/lint/run_clang_format.sh
volumes: *ubuntu-volumes
+ clang-tidy:
+ # Usage:
+ # docker-compose build cpp
+ # docker-compose build python
+ # docker-compose build lint
+ # docker-compose run clang-tidy
+ image: arrow:lint
+ command: arrow/dev/lint/run_clang_tidy.sh
+ volumes: *ubuntu-volumes
+
docs:
# Usage:
# docker-compose build cpp