Explorar o código

CI: upgrade clang-tidy

Benoit Blanchon hai 9 meses
pai
achega
411424b74e

+ 5 - 5
.github/workflows/ci.yml

@@ -480,17 +480,17 @@ jobs:
   clang-tidy:
     needs: clang
     name: Clang-Tidy
-    runs-on: ubuntu-22.04
+    runs-on: ubuntu-latest
     steps:
       - name: Install
-        run: sudo apt-get install -y clang-tidy cmake ninja-build
+        run: sudo apt-get install -y clang-tidy libc++-dev libc++abi-dev
       - name: Checkout
         uses: actions/checkout@v4
       - name: Configure
-        run: cmake -G Ninja -DCMAKE_CXX_CLANG_TIDY="clang-tidy-10;--warnings-as-errors=*" -DCMAKE_BUILD_TYPE=Debug .
+        run: cmake -G Ninja -DCMAKE_CXX_CLANG_TIDY="clang-tidy;--warnings-as-errors=*" -DCMAKE_BUILD_TYPE=Debug .
         env:
-          CC: clang-10
-          CXX: clang++-10
+          CC: clang
+          CXX: clang++
       - name: Check
         run: cmake --build . -- -k 0
 

+ 2 - 0
extras/tests/JsonDocument/assignment.cpp

@@ -69,6 +69,8 @@ TEST_CASE("JsonDocument assignment") {
       doc2 = std::move(doc1);
 
       REQUIRE(doc2.as<std::string>() == "{\"hello\":\"world\"}");
+
+      // NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
       REQUIRE(doc1.as<std::string>() == "null");
     }
     REQUIRE(spyingAllocator.log() == AllocatorLog{

+ 2 - 0
extras/tests/JsonDocument/constructor.cpp

@@ -44,6 +44,8 @@ TEST_CASE("JsonDocument constructor") {
       JsonDocument doc2(std::move(doc1));
 
       REQUIRE(doc2.as<std::string>() == "The size of this string is 32!!");
+
+      // NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
       REQUIRE(doc1.as<std::string>() == "null");
     }
     REQUIRE(spyingAllocator.log() == AllocatorLog{

+ 13 - 11
extras/tests/ResourceManager/StringBuilder.cpp

@@ -116,12 +116,12 @@ TEST_CASE("StringBuilder") {
   }
 }
 
-static JsonString saveString(StringBuilder& builder, const char* s) {
+static VariantData saveString(StringBuilder& builder, const char* s) {
   VariantData data;
   builder.startString();
   builder.append(s);
   builder.save(&data);
-  return data.asString();
+  return data;
 }
 
 TEST_CASE("StringBuilder::save() deduplicates strings") {
@@ -134,9 +134,9 @@ TEST_CASE("StringBuilder::save() deduplicates strings") {
     auto s2 = saveString(builder, "world");
     auto s3 = saveString(builder, "hello");
 
-    REQUIRE(s1 == "hello");
-    REQUIRE(s2 == "world");
-    REQUIRE(+s1.c_str() == +s3.c_str());  // same address
+    REQUIRE(s1.asString() == "hello");
+    REQUIRE(s2.asString() == "world");
+    REQUIRE(+s1.asString().c_str() == +s3.asString().c_str());  // same address
 
     REQUIRE(spy.log() ==
             AllocatorLog{
@@ -152,9 +152,10 @@ TEST_CASE("StringBuilder::save() deduplicates strings") {
     auto s1 = saveString(builder, "hello world");
     auto s2 = saveString(builder, "hello");
 
-    REQUIRE(s1 == "hello world");
-    REQUIRE(s2 == "hello");
-    REQUIRE(+s2.c_str() != +s1.c_str());  // different address
+    REQUIRE(s1.asString() == "hello world");
+    REQUIRE(s2.asString() == "hello");
+    REQUIRE(+s2.asString().c_str() !=
+            +s1.asString().c_str());  // different address
 
     REQUIRE(spy.log() ==
             AllocatorLog{
@@ -169,9 +170,10 @@ TEST_CASE("StringBuilder::save() deduplicates strings") {
     auto s1 = saveString(builder, "hello world");
     auto s2 = saveString(builder, "worl");
 
-    REQUIRE(s1 == "hello world");
-    REQUIRE(s2 == "worl");
-    REQUIRE(s2.c_str() != s1.c_str());  // different address
+    REQUIRE(s1.asString() == "hello world");
+    REQUIRE(s2.asString() == "worl");
+    REQUIRE(s2.asString().c_str() !=
+            s1.asString().c_str());  // different address
 
     REQUIRE(spy.log() ==
             AllocatorLog{