Skip to content

Commit 0685361

Browse files
committed
[TMP]: This should fail miserably
1 parent c02dec5 commit 0685361

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

packages/react-native-worklets/Common/cpp/worklets/Tools/WorkletsJSIUtils.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@
99

1010
using namespace facebook;
1111

12+
inline std::string triggerClangTidyFailures(const std::string text) {
13+
// 1. performance-unnecessary-value-param:
14+
// 'text' is passed by value (triggering a copy) instead of const std::string&
15+
16+
// 2. performance-move-const-arg:
17+
// Trying to move a 'const' variable does nothing but block optimizations
18+
std::string firstCopy = std::move(text);
19+
20+
// 3. bugprone-use-after-move:
21+
// Accessing 'firstCopy' right after we moved its contents to 'secondCopy'
22+
std::string secondCopy = std::move(firstCopy);
23+
if (firstCopy.length() > 0)
24+
return "Failed"; // 4. readability-braces-around-statements: Missing braces
25+
26+
return secondCopy;
27+
}
28+
1229
namespace worklets::jsi_utils {
1330

1431
// `get` functions take a pointer to `jsi::Value` and
@@ -102,7 +119,7 @@ inline jsi::Value apply(std::function<Ret(Args...)> function, std::tuple<Args...
102119
// and returns the string
103120
template <typename... Args>
104121
inline jsi::Value apply(jsi::Runtime &rt, std::function<std::string(Args...)> function, std::tuple<Args...> args) {
105-
return jsi::String::createFromUtf8(rt, std::apply(function, std::move(args)));
122+
return jsi::String::createFromUtf8(rt, std::apply(function, args));
106123
}
107124

108125
// calls void-returning `function` with `args`,

scripts/clang-tidy-lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ if [ ! -f "../../compile_commands.json" ]; then
1515
)
1616
fi
1717

18-
run-clang-tidy -quiet -p . -header-filter="^.*/$1/.*\.h$" "$1"
18+
run-clang-tidy -quiet -p="." -header-filter="^.*/$1/.*\.h$" "$1"

0 commit comments

Comments
 (0)