-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add clang-tidy for pika #1515
Merged
Merged
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
b871a44
feature:add clang-tidy for pika
ForestLH 79db0eb
feature:WIP modified clang-tidy file
ForestLH 8bb85f1
feature:disable compile command clang-tidy check
ForestLH 8827ff5
style:Make the code standard according to clang-tidy
ForestLH 78e327d
merge upstream unstable
AlexStocks 09558b9
delete double std::move
AlexStocks 6200048
auto* -> auto
AlexStocks 6bad717
using noncopyable
AlexStocks 0f19c14
add space for override{}
AlexStocks 341e190
add spaces
AlexStocks 54cef5b
delete != 0
AlexStocks ff42430
format if-return
AlexStocks 68b70a8
clear inheritage
AlexStocks 487cb0f
format codes
AlexStocks 9b9ca7c
format codes
AlexStocks 569c68a
delete == 0
AlexStocks 168277d
fix:fix build error
ForestLH b508696
style:disable check bool implicit convert in clang-tidy
ForestLH 93b7a0d
Merge pull request #1 from AlexStocks/lihao-clang
ForestLH 9f902dd
style:update code style
ForestLH d27094a
delete '!= nullptr'
AlexStocks 02e17e5
format if/while
AlexStocks deaa4bb
Merge pull request #2 from ForestLH/style/clang
ForestLH f6a68d7
Merge pull request #3 from AlexStocks/lihao-clang
ForestLH 5c1e24f
fix ci failure
AlexStocks 9d4e024
Merge pull request #4 from AlexStocks/lihao-clang
ForestLH e919de2
fix:build ci error
ForestLH e8d9171
style:The judgment statement should not be an assignment
ForestLH de1594b
style:format codes
ForestLH 6bc870c
Merge pull request #5 from ForestLH/style/clang
ForestLH 3624335
style:format codes
ForestLH cb7238a
Merge pull request #6 from ForestLH/style/clang
ForestLH 735fa02
format codes
AlexStocks b508399
merge upstream unstable
AlexStocks 810f799
Merge branch 'unstable' into lihao-clang
AlexStocks 62d8635
Merge pull request #7 from AlexStocks/lihao-clang
ForestLH 008f567
format codes
AlexStocks 7a2b3bd
Merge pull request #8 from AlexStocks/lihao-clang
ForestLH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
--- | ||
Checks: ' | ||
bugprone-*, | ||
clang-analyzer-*, | ||
google-*, | ||
modernize-*, | ||
performance-*, | ||
portability-*, | ||
readability-*, | ||
-bugprone-easily-swappable-parameters, | ||
-bugprone-implicit-widening-of-multiplication-result, | ||
-bugprone-narrowing-conversions, | ||
-bugprone-reserved-identifier, | ||
-bugprone-signed-char-misuse, | ||
-bugprone-suspicious-include, | ||
-bugprone-unhandled-self-assignment, | ||
-clang-analyzer-cplusplus.NewDelete, | ||
-clang-analyzer-cplusplus.NewDeleteLeaks, | ||
-clang-analyzer-security.insecureAPI.rand, | ||
-clang-diagnostic-implicit-int-float-conversion, | ||
-google-readability-avoid-underscore-in-googletest-name, | ||
-modernize-avoid-c-arrays, | ||
-modernize-use-nodiscard, | ||
-readability-convert-member-functions-to-static, | ||
-readability-identifier-length, | ||
-readability-function-cognitive-complexity, | ||
-readability-magic-numbers, | ||
-readability-make-member-function-const, | ||
-readability-qualified-auto, | ||
-readability-redundant-access-specifiers, | ||
-bugprone-exception-escape, | ||
-modernize-use-trailing-return-type, | ||
-readability-function-size, | ||
-readability-else-after-return, | ||
-bugprone-branch-clone, | ||
-readability-use-anyofallof, | ||
-google-default-arguments, | ||
-clang-analyzer-cplusplus.InnerPointer, | ||
-google-explicit-constructor, | ||
-use_of_tag_name_without_tag, | ||
-clang-analyzer-core.CallAndMessage, | ||
-clang-analyzer-deadcode.DeadStores, | ||
-google-runtime-int, | ||
-clang-diagnostic-unused-command-line-argument, | ||
-clang-diagnostic-ignored-optimization-argument, | ||
-readability-implicit-bool-conversion, | ||
' | ||
# CheckOptions: | ||
# - { key: readability-identifier-naming.ClassCase, value: CamelCase } | ||
# - { key: readability-identifier-naming.EnumCase, value: CamelCase } | ||
# - { key: readability-identifier-naming.FunctionCase, value: CamelCase } | ||
# - { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE } | ||
# - { key: readability-identifier-naming.MemberCase, value: lower_case } | ||
# - { key: readability-identifier-naming.MemberSuffix, value: _ } | ||
# - { key: readability-identifier-naming.NamespaceCase, value: lower_case } | ||
# - { key: readability-identifier-naming.StructCase, value: CamelCase } | ||
# - { key: readability-identifier-naming.UnionCase, value: CamelCase } | ||
# - { key: readability-identifier-naming.VariableCase, value: lower_case } | ||
|
||
WarningsAsErrors: '*' | ||
# HeaderFilterRegex: '(|/src|/src/net|/src/pstd|/src/storage)/include' | ||
# HeaderFilterRegex: '/src/(net|storage|pstd)/include' | ||
AnalyzeTemporaryDtors: true | ||
|
||
#### Disabled checks and why: ##### | ||
# | ||
# -readability-convert-member-functions-to-static, | ||
# This check started going off in the upgrade from clang-tidy-8 to clang-tidy-12. It is not always correct because | ||
# we hide the reference implementation in another repository. | ||
# -clang-analyzer-security.insecureAPI.rand, -clang-analyzer-security.insecureAPI.rand, -bugprone-unhandled-self-assignment, | ||
# -bugprone-implicit-widening-of-multiplication-result | ||
# These have not been investigated yet. | ||
# -bugprone-reserved-identifier, | ||
# Fails due to use of some __SHORT_FILE__ symbol, originating from very old code. | ||
# -bugprone-suspicious-include, | ||
# False positive due to GTest code. | ||
# -bugprone-too-small-loop-variable, | ||
# Complains about uint8_t or uint16_t when the limit on the loop is a container's .size() (size_t). | ||
# We usually do this when we know the maximum size of the container though, so propose leaving disabled. | ||
# -clang-analyzer-cplusplus.NewDelete, | ||
# Seems to generate false positives. Suggest relying on ASAN and valgrind for memory stuff. | ||
# -clang-analyzer-cplusplus.NewDeleteLeaks, | ||
# Seems to generate false positives. Suggest relying on ASAN and valgrind for memory stuff. | ||
# -modernize-use-nodiscard, | ||
# New C++17 feature, slightly polarizing. Would clutter codebase. | ||
# -modernize-avoid-c-arrays, | ||
# Let's not deal with people doing ridiculous things to hack around this. If it bites them, it bites them. | ||
# -bugprone-signed-char-misuse, -clang-diagnostic-implicit-int-float-conversion, -readability-make-member-function-const, | ||
# -readability-qualified-auto, -readability-redundant-access-specifiers | ||
# These were previously disabled for not being available in clang-tidy-8. They are now available on our clang-tidy-12, | ||
# and potentially worth investigating/fixing. | ||
# -bugprone-exception-escape | ||
# Weird. No idea how to resolve. | ||
# -bugprone-branch-clone, | ||
# frequent misidentification | ||
# -google-default-arguments | ||
# Too many virtual functions in pika have default parameters, specifically void Do(std::shared_ptr<Partition> partition = nullptr) | ||
# -clang-analyzer-cplusplus.InnerPointer | ||
# I don't know why this bug in the RocksDB library fails to suppress detection.So I have to disable this check. | ||
#--google-explicit-constructor | ||
# There are so many implicit convert in pika | ||
#--use_of_tag_name_without_tag | ||
# like class member is class , If there is no class tag, an error will be reported | ||
# class A{ B b_; } -> error ; class A{ class B b_; } -> no error ; | ||
#-clang-analyzer-core.CallAndMessage | ||
# pika/src/storage/src/scope_record_lock.h | ||
# Always detect a null pointer and call the TryLock method | ||
# Called C++ object pointer is null [clang-analyzer-core.CallAndMessage,-warnings-as-errors] | ||
# lock_mgr_->UnLock(key); | ||
#-clang-analyzer-deadcode.DeadStores | ||
# error detection in some places | ||
#-google-runtime-int | ||
# todo discussed, because there are so many of `long` and `long long` in pika, so disable for now | ||
#-clang-diagnostic-unused-command-line-argument | ||
# because there are to many compile command error in github ci, but no error in local environment | ||
# See in build folder compile_commands.json | ||
#-clang-diagnostic-ignored-optimization-argument | ||
# The reason disabled this is same as above. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,26 @@ if (${AUTOCONF} MATCHES AUTOCONF-NOTFOUND) | |
message(FATAL_ERROR "not find autoconf on localhost") | ||
endif() | ||
|
||
find_program(CLANG_TIDY_BIN | ||
NAMES clang-tidy clang-tidy-12 | ||
HINTS ${CLANG_SEARCH_PATH}) | ||
if ("${CLANG_TIDY_BIN}" STREQUAL "CLANG_TIDY_BIN-NOTFOUND") | ||
message(WARNING "couldn't find clang-tidy.") | ||
else () | ||
message(STATUS "found clang-tidy at ${CLANG_TIDY_BIN}") | ||
endif () | ||
|
||
find_program(CLANG_APPLY_REPLACEMENTS_BIN | ||
NAMES clang-apply-replacements clang-apply-replacements-12 | ||
HINTS ${CLANG_SEARCH_PATH}) | ||
|
||
if ("${CLANG_APPLY_REPLACEMENTS_BIN}" STREQUAL "CLANG_APPLY_REPLACEMENTS_BIN-NOTFOUND") | ||
message(WARNING "couldn't find clang-apply-replacements.") | ||
else () | ||
message(STATUS "found clang-apply-replacements at ${CLANG_APPLY_REPLACEMENTS_BIN}") | ||
endif () | ||
|
||
|
||
include(protogen.cmake) | ||
include(ExternalProject) | ||
|
||
|
@@ -750,3 +770,20 @@ target_link_libraries(${PROJECT_NAME} | |
${JEMALLOC_LIBRARY}) | ||
|
||
option(USE_SSL "Enable SSL support" OFF) | ||
add_custom_target( | ||
clang-tidy | ||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run_clang_tidy.py | ||
-clang-tidy-binary ${CLANG_TIDY_BIN} | ||
-header-filter='${PROJECT_SOURCE_DIR}(/include|/tools|/src)/.*' | ||
-p ${CMAKE_BINARY_DIR} | ||
-quiet | ||
) | ||
|
||
add_custom_target(clang-tidy-fix | ||
${CMAKE_CURRENT_SOURCE_DIR}/run_clang_tidy.py | ||
-clang-tidy-binary ${CLANG_TIDY_BIN} | ||
-p ${CMAKE_BINARY_DIR} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里header-filter建议在.clang-tidy处理,为了可读性 |
||
-header-filter='${PROJECT_SOURCE_DIR}(/include|/tools|/src)/.*' | ||
-clang-apply-replacements-binary ${CLANG_APPLY_REPLACEMENTS_BIN} | ||
-fix | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
避免添加重复文件,在这里添加个参数 https://clang.llvm.org/extra/clang-tidy/checks/readability/duplicate-include.html