aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/core/src/firebase/firestore/model
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2018-04-12 14:54:53 -0700
committerGravatar GitHub <noreply@github.com>2018-04-12 14:54:53 -0700
commit8876622b6fcebc21672bc263666b858b7e152b45 (patch)
tree053fe00a20207099c11c1464df25565a5f5cc3c6 /Firestore/core/src/firebase/firestore/model
parent1397e4ae72ea3b8d16a9b44ed1235caca47b3d9e (diff)
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
Diffstat (limited to 'Firestore/core/src/firebase/firestore/model')
-rw-r--r--Firestore/core/src/firebase/firestore/model/database_id.h3
-rw-r--r--Firestore/core/src/firebase/firestore/model/document.cc2
-rw-r--r--Firestore/core/src/firebase/firestore/model/field_mask.h4
-rw-r--r--Firestore/core/src/firebase/firestore/model/field_value.cc5
-rw-r--r--Firestore/core/src/firebase/firestore/model/field_value.h2
5 files changed, 7 insertions, 9 deletions
diff --git a/Firestore/core/src/firebase/firestore/model/database_id.h b/Firestore/core/src/firebase/firestore/model/database_id.h
index e1feca9..0c0e0ec 100644
--- a/Firestore/core/src/firebase/firestore/model/database_id.h
+++ b/Firestore/core/src/firebase/firestore/model/database_id.h
@@ -44,8 +44,7 @@ class DatabaseId {
* @param project_id The project for the database.
* @param database_id The database in the project to use.
*/
- DatabaseId(const absl::string_view project_id,
- const absl::string_view database_id);
+ DatabaseId(absl::string_view project_id, absl::string_view database_id);
const std::string& project_id() const {
return project_id_;
diff --git a/Firestore/core/src/firebase/firestore/model/document.cc b/Firestore/core/src/firebase/firestore/model/document.cc
index 16548cd..ae59d15 100644
--- a/Firestore/core/src/firebase/firestore/model/document.cc
+++ b/Firestore/core/src/firebase/firestore/model/document.cc
@@ -39,7 +39,7 @@ bool Document::Equals(const MaybeDocument& other) const {
if (other.type() != Type::Document) {
return false;
}
- const Document& other_doc = static_cast<const Document&>(other);
+ auto& other_doc = static_cast<const Document&>(other);
return MaybeDocument::Equals(other) &&
has_local_mutations_ == other_doc.has_local_mutations_ &&
data_ == other_doc.data_;
diff --git a/Firestore/core/src/firebase/firestore/model/field_mask.h b/Firestore/core/src/firebase/firestore/model/field_mask.h
index a9f509a..b895ab3 100644
--- a/Firestore/core/src/firebase/firestore/model/field_mask.h
+++ b/Firestore/core/src/firebase/firestore/model/field_mask.h
@@ -44,9 +44,7 @@ class FieldMask {
FieldMask(std::initializer_list<FieldPath> list) : fields_{list} {
}
- explicit FieldMask(const std::vector<FieldPath>& fields) : fields_{fields} {
- }
- explicit FieldMask(std::vector<FieldPath>&& fields)
+ explicit FieldMask(std::vector<FieldPath> fields)
: fields_{std::move(fields)} {
}
diff --git a/Firestore/core/src/firebase/firestore/model/field_value.cc b/Firestore/core/src/firebase/firestore/model/field_value.cc
index 1a40331..b0519f7 100644
--- a/Firestore/core/src/firebase/firestore/model/field_value.cc
+++ b/Firestore/core/src/firebase/firestore/model/field_value.cc
@@ -38,7 +38,7 @@ namespace {
/**
* This deviates from the other platforms that define TypeOrder. Since
* we already define Type for union types, we use it together with this
- * function to achive the equivalent order of types i.e.
+ * function to achieve the equivalent order of types i.e.
* i) if two types are comparable, then they are of equal order;
* ii) otherwise, their order is the same as the order of their Type.
*/
@@ -148,7 +148,8 @@ FieldValue& FieldValue::operator=(FieldValue&& value) {
return *this;
default:
// We just copy over POD union types.
- return *this = value;
+ *this = value;
+ return *this;
}
}
diff --git a/Firestore/core/src/firebase/firestore/model/field_value.h b/Firestore/core/src/firebase/firestore/model/field_value.h
index c70e332..3c5af9c 100644
--- a/Firestore/core/src/firebase/firestore/model/field_value.h
+++ b/Firestore/core/src/firebase/firestore/model/field_value.h
@@ -163,7 +163,7 @@ class FieldValue {
/**
* Switch to the specified type, if different from the current type.
*/
- void SwitchTo(const Type type);
+ void SwitchTo(Type type);
Type tag_ = Type::Null;
union {