Skip to content

Commit c530d31

Browse files
[Tool] turn on clang-tidy for all source code files (backport StarRocks#44990) (StarRocks#49112)
Signed-off-by: Kevin Xiaohua Cai <[email protected]> Co-authored-by: Kevin Cai <[email protected]>
1 parent e9e221e commit c530d31

File tree

97 files changed

+255
-287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+255
-287
lines changed

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Checks: >
1313
modernize-replace-auto-ptr,
1414
modernize-replace-disallow-copy-and-assign-macro,
1515
modernize-replace-random-shuffle,
16-
modernize-return-braced-init-list,
16+
-modernize-return-braced-init-list,
1717
modernize-shrink-to-fit,
1818
modernize-unary-static-assert,
1919
modernize-use-bool-literals,

be/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,12 @@ endforeach()
598598
# Check Clang-Tidy
599599
include(cmake_modules/FindClangTidy.cmake)
600600

601+
if (CLANG_TIDY_PATH)
602+
# enable clang-tidy check for all source code files
603+
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}" "--fix" "--fix-errors")
604+
endif()
605+
606+
601607
# Check if functions are supported in this platform. All flags will generated
602608
# in gensrc/build/common/env_config.h.
603609
# You can check funcion here which depends on platform. Don't forget add this

be/cmake_modules/FindClangTidy.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ option(WITH_CLANG_TIDY "Use clang-tidy static analyzer" OFF)
22

33
if (${WITH_CLANG_TIDY})
44
find_program (CLANG_TIDY_CACHE_BIN NAMES "clang-tidy-cache")
5-
find_program (CLANG_TIDY_BIN NAMES "clang-tidy-16" "clang-tidy-15" "clang-tidy-14" "clang-tidy-13" "clang-tidy-12" "clang-tidy")
5+
find_program (CLANG_TIDY_BIN NAMES "clang-tidy-17" "clang-tidy-16" "clang-tidy-15" "clang-tidy-14" "clang-tidy-13" "clang-tidy")
66

77
if (CLANG_TIDY_CACHE_BIN)
88
set (CLANG_TIDY_PATH "${CLANG_TIDY_CACHE_BIN};${CLANG_TIDY_BIN}" CACHE STRING "Cache for clang-tidy")
@@ -14,6 +14,5 @@ if (${WITH_CLANG_TIDY})
1414
message (STATUS "Find clang-tidy: ${CLANG_TIDY_PATH}.")
1515
else ()
1616
message (FATAL_ERROR "clang-tidy is not found")
17-
# message (WARNING "clang-tidy is not found")
1817
endif ()
19-
endif()
18+
endif()

be/src/agent/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
if (CLANG_TIDY_PATH)
16-
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
17-
endif()
18-
1915
set(LIBRARY_OUTPUT_PATH "${BUILD_DIR}/src/agent")
2016

2117
# where to put generated binaries

be/src/bench/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
if (CLANG_TIDY_PATH)
16-
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
17-
endif()
18-
1915
ADD_BE_BENCH(${SRC_DIR}/bench/chunks_sorter_bench)
2016
ADD_BE_BENCH(${SRC_DIR}/bench/runtime_filter_bench)
2117
ADD_BE_BENCH(${SRC_DIR}/bench/csv_reader_bench)

be/src/block_cache/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
if (CLANG_TIDY_PATH)
16-
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
17-
endif()
18-
1915
# where to put generated libraries
2016
set(LIBRARY_OUTPUT_PATH "${BUILD_DIR}/src/block_cache")
2117

be/src/column/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414

1515
set(LIBRARY_OUTPUT_PATH "${BUILD_DIR}/src/column")
1616

17-
if (CLANG_TIDY_PATH)
18-
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
19-
endif()
20-
2117
add_library(Column STATIC
2218
array_column.cpp
2319
adaptive_nullable_column.cpp

be/src/common/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414

1515
set(LIBRARY_OUTPUT_PATH "${BUILD_DIR}/src/common")
1616

17-
if (CLANG_TIDY_PATH)
18-
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
19-
endif()
20-
2117
add_library(Common STATIC
2218
daemon.cpp
2319
greplog.cpp

be/src/connector/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414

1515
set(LIBRARY_OUTPUT_PATH "${BUILD_DIR}/src/connector")
1616

17-
if (CLANG_TIDY_PATH)
18-
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
19-
endif ()
20-
2117
add_library(Connector STATIC
2218
connector.cpp
2319
hive_connector.cpp

be/src/exec/arrow_to_json_converter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ static Status convert_single_arrow_struct(const StructArray* array, int offset,
205205
builder->openObject();
206206
const StructType* struct_type = array->struct_type();
207207
for (int i = 0; i < array->num_fields(); i++) {
208-
auto field = array->field(i);
208+
const auto& field = array->field(i);
209209
RETURN_IF_ERROR(convert_arrow_to_json_element(field.get(), field->type_id(), offset,
210210
struct_type->field(i)->name(), builder));
211211
}
@@ -240,7 +240,7 @@ static StatusOr<std::string> convert_array_element_to_string(const Array* array,
240240
}
241241

242242
static Status convert_single_arrow_map(const MapArray* array, int offset, vpack::Builder* builder) {
243-
auto item_array = array->items();
243+
const auto& item_array = array->items();
244244

245245
builder->openObject();
246246
Type::type item_type = item_array->type_id();

0 commit comments

Comments
 (0)