From 8876622b6fcebc21672bc263666b858b7e152b45 Mon Sep 17 00:00:00 2001 From: Gil Date: Thu, 12 Apr 2018 14:54:53 -0700 Subject: Add clang-tidy checks for Firestore (#1078) * Add a .clang-tidy configuration for Firestore C++ * Fix clang-tidy warnings * typedef -> using * const ref + rvalue ref -> pass by value * NULL -> nullptr * remove useless default initializations * remove useless const value-type parameter declarations (definitions can still use them) * use auto instead of repeating types in a cast * Fix typos * Address use of static method through instance warnings * Address use after move warnings --- Firestore/core/test/firebase/firestore/model/document_key_test.cc | 6 +++--- Firestore/core/test/firebase/firestore/model/field_path_test.cc | 8 ++++---- Firestore/core/test/firebase/firestore/model/field_value_test.cc | 2 +- .../core/test/firebase/firestore/model/resource_path_test.cc | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'Firestore/core/test/firebase/firestore/model') diff --git a/Firestore/core/test/firebase/firestore/model/document_key_test.cc b/Firestore/core/test/firebase/firestore/model/document_key_test.cc index 0e0df2d..619ee7f 100644 --- a/Firestore/core/test/firebase/firestore/model/document_key_test.cc +++ b/Firestore/core/test/firebase/firestore/model/document_key_test.cc @@ -46,7 +46,7 @@ TEST(DocumentKey, Constructor_FromPath) { EXPECT_EQ(key_from_path_copy.path(), path); const DocumentKey key_from_moved_path{std::move(path)}; - EXPECT_TRUE(path.empty()); + EXPECT_TRUE(path.empty()); // NOLINT: use after move intended EXPECT_FALSE(key_from_moved_path.path().empty()); EXPECT_EQ(key_from_path_copy.path(), key_from_moved_path.path()); } @@ -62,7 +62,7 @@ TEST(DocumentKey, CopyAndMove) { const DocumentKey moved = std::move(key); EXPECT_EQ(path_string, moved.path().CanonicalString()); - EXPECT_NE(key, moved); + EXPECT_NE(key, moved); // NOLINT: use after move intended EXPECT_TRUE(key.path().empty()); // Reassignment. @@ -74,7 +74,7 @@ TEST(DocumentKey, CopyAndMove) { key = {}; EXPECT_TRUE(key.path().empty()); key = std::move(copied); - EXPECT_NE(copied, key); + EXPECT_NE(copied, key); // NOLINT: use after move intended EXPECT_TRUE(copied.path().empty()); EXPECT_EQ(path_string, key.path().CanonicalString()); } diff --git a/Firestore/core/test/firebase/firestore/model/field_path_test.cc b/Firestore/core/test/firebase/firestore/model/field_path_test.cc index a5ae3b2..a215a96 100644 --- a/Firestore/core/test/firebase/firestore/model/field_path_test.cc +++ b/Firestore/core/test/firebase/firestore/model/field_path_test.cc @@ -47,7 +47,7 @@ TEST(FieldPath, Constructors) { EXPECT_EQ(path_from_list, copied); const FieldPath moved = std::move(copied); EXPECT_EQ(path_from_list, moved); - EXPECT_NE(copied, moved); + EXPECT_NE(copied, moved); // NOLINT: use after move intended EXPECT_EQ(empty_path, copied); } @@ -68,7 +68,7 @@ TEST(FieldPath, PopFirst) { const FieldPath bc{"Eros", "messages"}; const FieldPath c{"messages"}; const FieldPath empty; - const FieldPath abc_dupl{"rooms", "Eros", "messages"}; + const FieldPath abc_dup{"rooms", "Eros", "messages"}; EXPECT_NE(empty, c); EXPECT_NE(c, bc); @@ -77,7 +77,7 @@ TEST(FieldPath, PopFirst) { EXPECT_EQ(bc, abc.PopFirst()); EXPECT_EQ(c, abc.PopFirst(2)); EXPECT_EQ(empty, abc.PopFirst(3)); - EXPECT_EQ(abc_dupl, abc); + EXPECT_EQ(abc_dup, abc); } TEST(FieldPath, PopLast) { @@ -85,7 +85,7 @@ TEST(FieldPath, PopLast) { const FieldPath ab{"rooms", "Eros"}; const FieldPath a{"rooms"}; const FieldPath empty; - const FieldPath abc_dupl{"rooms", "Eros", "messages"}; + const FieldPath abc_dup{"rooms", "Eros", "messages"}; EXPECT_EQ(ab, abc.PopLast()); EXPECT_EQ(a, abc.PopLast().PopLast()); diff --git a/Firestore/core/test/firebase/firestore/model/field_value_test.cc b/Firestore/core/test/firebase/firestore/model/field_value_test.cc index 08db76d..c5645a4 100644 --- a/Firestore/core/test/firebase/firestore/model/field_value_test.cc +++ b/Firestore/core/test/firebase/firestore/model/field_value_test.cc @@ -411,7 +411,7 @@ TEST(FieldValue, Move) { EXPECT_EQ(FieldValue::ReferenceValue(DocumentKey::FromPathString("root/abc"), &database_id), clone); - clone = null_value; + clone = null_value; // NOLINT: use after move intended EXPECT_EQ(FieldValue::NullValue(), clone); FieldValue geo_point_value = FieldValue::GeoPointValue({1, 2}); diff --git a/Firestore/core/test/firebase/firestore/model/resource_path_test.cc b/Firestore/core/test/firebase/firestore/model/resource_path_test.cc index 637e78e..8545884 100644 --- a/Firestore/core/test/firebase/firestore/model/resource_path_test.cc +++ b/Firestore/core/test/firebase/firestore/model/resource_path_test.cc @@ -47,7 +47,7 @@ TEST(ResourcePath, Constructor) { EXPECT_EQ(path_from_list, copied); const ResourcePath moved = std::move(copied); EXPECT_EQ(path_from_list, moved); - EXPECT_NE(copied, moved); + EXPECT_NE(copied, moved); // NOLINT: use after move intended EXPECT_EQ(empty_path, copied); } -- cgit v1.2.3