|
9 | 9 |
|
10 | 10 | using namespace facebook; |
11 | 11 |
|
| 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 | + |
12 | 29 | namespace worklets::jsi_utils { |
13 | 30 |
|
14 | 31 | // `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... |
102 | 119 | // and returns the string |
103 | 120 | template <typename... Args> |
104 | 121 | 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)); |
106 | 123 | } |
107 | 124 |
|
108 | 125 | // calls void-returning `function` with `args`, |
|
0 commit comments