From 3e49d17f58b9b7cc051925f43b709b020745312c Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 29 May 2025 14:25:57 -0700 Subject: [PATCH] Fix clang tidy for react-native (#51679) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51679 ## Problem I noticed that clang-tidy was crashing in some of our native modules. This diff fixes the crash. And it blocklists all the warnings that got raised when I ran clang tidy for react native. ## Fix This rule would crash clang tidy: ``` cppcoreguidelines-avoid-const-or-ref-data-members ``` I disabled it in the .clang-tidy file via: ``` -clang-analyzer-*, ``` ## Why disable existing warnings? We need to double check which checks make sense to enable for react native github. Until we have that understanding, I don't think we should prompt people to adjust their code. After we have that understanding, it should be really easy to enable the checks: just run the linter on react native, and fix the code. Reviewed By: lunaleaps Differential Revision: D75596329 fbshipit-source-id: 757a8d38f203d7fb4403bbda3703fda7b44923b0 --- .clang-tidy | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000000..0ba77f6c462 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,62 @@ +# The following checks should be kept disabled: +# clang-analyzer-*: Broken/unreliable +# readability-simplify-boolean-expr: Broken +# cppcoreguidelines-*: Only recommented for new code-bases +# cert-err58-cpp: Deemed low-value. See ERR58-CPP for more info. +# performance-unnecessary-value-param: Is not up to date +# +# T225851676: Do a sweep over the remaining checks. Turn them on, +# if they make sense. And fix the code. +--- +InheritParentConfig: true +Checks: ' +-bugprone-exception-escape, +-bugprone-macro-parentheses, +-cert-err58-cpp, +-clang-analyzer-*, +-clang-diagnostic-deprecated-declarations, +-clang-diagnostic-error, +-clang-diagnostic-missing-designated-field-initializers, +-clang-diagnostic-objc-designated-initializers, +-clang-diagnostic-unguarded-availability-new, +-clang-diagnostic-vla-cxx-extension, +-cppcoreguidelines-*, +-google-build-using-namespace, +-lint-command-empty-cdb, +-lint-command-empty-cdb, +-misc-header-include-cycle, +-misc-misplaced-const, +-misc-unused-parameters, +-modernize-avoid-c-arrays, +-modernize-deprecated-headers, +-modernize-loop-convert, +-modernize-make-shared, +-modernize-pass-by-value, +-modernize-raw-string-literal, +-modernize-redundant-void-arg, +-modernize-return-braced-init-list, +-modernize-use-auto, +-modernize-use-designated-initializers, +-modernize-use-emplace, +-modernize-use-equals-default, +-modernize-use-nullptr, +-modernize-use-override, +-modernize-use-using, +-performance-for-range-copy, +-performance-move-const-arg, +-performance-no-int-to-ptr, +-performance-unnecessary-copy-initialization, +-performance-unnecessary-value-param, +-readability-avoid-const-params-in-decls, +-readability-braces-around-statements, +-readability-const-return-type, +-readability-container-size-empty, +-readability-implicit-bool-conversion, +-readability-inconsistent-declaration-parameter-name, +-readability-isolate-declaration, +-readability-named-parameter, +-readability-operators-representation, +-readability-redundant-declaration, +-readability-simplify-boolean-expr, +-readability-static-definition-in-anonymous-namespace, +'