Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minor style issues uncovered during auditing #6851

Merged
merged 7 commits into from
Oct 28, 2020
5 changes: 2 additions & 3 deletions Firestore/core/src/local/leveldb_migrations.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,6 +33,7 @@
namespace firebase {
namespace firestore {
namespace local {
namespace {

using leveldb::Iterator;
using leveldb::Slice;
Expand All @@ -44,8 +45,6 @@ using nanopb::Message;
using nanopb::StringReader;
using nanopb::Writer;

namespace {

/**
* Schema version for the iOS client.
*
Expand Down
3 changes: 1 addition & 2 deletions Firestore/core/src/local/leveldb_util.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,6 @@
namespace firebase {
namespace firestore {
namespace local {

namespace {

Error ConvertStatusCode(const leveldb::Status& status) {
Expand Down
3 changes: 1 addition & 2 deletions Firestore/core/src/local/local_serializer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,7 +43,6 @@
namespace firebase {
namespace firestore {
namespace local {

namespace {

using core::Target;
Expand Down
3 changes: 1 addition & 2 deletions Firestore/core/src/local/local_store.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Google
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,7 +37,6 @@
namespace firebase {
namespace firestore {
namespace local {

namespace {

using auth::User;
Expand Down
5 changes: 2 additions & 3 deletions Firestore/core/src/local/target_data.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,7 @@
namespace firebase {
namespace firestore {
namespace local {
namespace {

using core::Target;
using model::ListenSequenceNumber;
Expand All @@ -32,8 +33,6 @@ using nanopb::ByteString;

// MARK: - QueryPurpose

namespace {

const char* ToString(QueryPurpose purpose) {
switch (purpose) {
case QueryPurpose::Listen:
Expand Down
3 changes: 1 addition & 2 deletions Firestore/core/src/model/document_key.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +27,6 @@
namespace firebase {
namespace firestore {
namespace model {

namespace {

void AssertValidPath(const ResourcePath& path) {
Expand Down
6 changes: 3 additions & 3 deletions Firestore/core/src/model/field_path.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,11 +28,10 @@
namespace firebase {
namespace firestore {
namespace model {
namespace {

using util::ThrowInvalidArgument;

namespace {

/**
* True if the string could be used as a segment in a field path without
* escaping. Valid identifies follow the regex [a-zA-Z_][a-zA-Z0-9_]*
Expand Down Expand Up @@ -79,6 +78,7 @@ struct JoinEscaped {
out->append(escaped_segment(segment));
}
};

} // namespace

constexpr const char* FieldPath::kDocumentKeyPath;
Expand Down
3 changes: 1 addition & 2 deletions Firestore/core/src/model/field_value.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,7 +41,6 @@
namespace firebase {
namespace firestore {
namespace model {

namespace {

using BaseValue = FieldValue::BaseValue;
Expand Down
3 changes: 1 addition & 2 deletions Firestore/core/src/nanopb/pretty_printing.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Google
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,6 @@
namespace firebase {
namespace firestore {
namespace nanopb {

namespace internal {

std::string Indent(int level, int indent_width) {
Expand Down
15 changes: 7 additions & 8 deletions Firestore/core/src/nanopb/writer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,13 +25,6 @@
namespace firebase {
namespace firestore {
namespace nanopb {

void Writer::Write(const pb_field_t fields[], const void* src_struct) {
if (!pb_encode(&stream_, fields, src_struct)) {
HARD_FAIL(PB_GET_ERROR(&stream_));
}
}

namespace {

constexpr size_t kMinBufferSize = 4;
Expand All @@ -46,6 +39,12 @@ bool AppendToBytesArray(pb_ostream_t* stream,

} // namespace

void Writer::Write(const pb_field_t fields[], const void* src_struct) {
if (!pb_encode(&stream_, fields, src_struct)) {
HARD_FAIL(PB_GET_ERROR(&stream_));
}
}

ByteStringWriter::ByteStringWriter() {
stream_.callback = AppendToBytesArray;
stream_.state = this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
namespace firebase {
namespace firestore {
namespace remote {

namespace {

using util::MakeString;
Expand Down
5 changes: 2 additions & 3 deletions Firestore/core/src/remote/grpc_connection.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,6 +45,7 @@ SUPPRESS_END()
namespace firebase {
namespace firestore {
namespace remote {
namespace {

using auth::Token;
using core::DatabaseInfo;
Expand All @@ -55,8 +56,6 @@ using util::Status;
using util::StatusOr;
using util::StringFormat;

namespace {

const char* const kAuthorizationHeader = "authorization";
const char* const kXGoogApiClientHeader = "x-goog-api-client";
const char* const kGoogleCloudResourcePrefix = "google-cloud-resource-prefix";
Expand Down
24 changes: 12 additions & 12 deletions Firestore/core/src/remote/online_state_tracker.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Google
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,15 +24,19 @@
#include "Firestore/core/src/util/status.h"
#include "Firestore/core/src/util/string_format.h"

namespace firebase {
namespace firestore {
namespace remote {
namespace {

namespace chr = std::chrono;
using firebase::firestore::model::OnlineState;
using firebase::firestore::util::AsyncQueue;
using firebase::firestore::util::DelayedOperation;
using firebase::firestore::util::Status;
using firebase::firestore::util::StringFormat;
using firebase::firestore::util::TimerId;

namespace {
using model::OnlineState;
using util::AsyncQueue;
using util::DelayedOperation;
using util::Status;
using util::StringFormat;
using util::TimerId;

// To deal with transient failures, we allow multiple stream attempts before
// giving up and transitioning from OnlineState Unknown to Offline.
Expand All @@ -48,10 +52,6 @@ const AsyncQueue::Milliseconds kOnlineStateTimeout = chr::seconds(10);

} // namespace

namespace firebase {
namespace firestore {
namespace remote {

void OnlineStateTracker::HandleWatchStreamStart() {
if (watch_stream_failures_ != 0) {
return;
Expand Down
5 changes: 2 additions & 3 deletions Firestore/core/src/remote/stream.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,6 +30,7 @@
namespace firebase {
namespace firestore {
namespace remote {
namespace {

using auth::CredentialsProvider;
using auth::Token;
Expand All @@ -40,8 +41,6 @@ using util::StatusOr;
using util::StringFormat;
using util::TimerId;

namespace {

/**
* Initial backoff time after an error.
* Set to 1s according to https://cloud.google.com/apis/design/errors.
Expand Down
3 changes: 1 addition & 2 deletions Firestore/core/src/remote/watch_change.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Google
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,7 +21,6 @@
namespace firebase {
namespace firestore {
namespace remote {

namespace {

template <typename T>
Expand Down
3 changes: 1 addition & 2 deletions Firestore/core/src/timestamp.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,6 @@
#include "absl/strings/str_cat.h"

namespace firebase {

namespace {

constexpr int32_t kNanosPerSecond = 1000 * 1000 * 1000;
Expand Down
3 changes: 2 additions & 1 deletion Firestore/core/src/util/comparison.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,6 +26,7 @@
namespace firebase {
namespace firestore {
namespace util {

using std::isnan;

/**
Expand Down
1 change: 0 additions & 1 deletion Firestore/core/src/util/executor_std.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
namespace firebase {
namespace firestore {
namespace util {

namespace {

// As a convention, assign the epoch time to all operations scheduled for
Expand Down
3 changes: 1 addition & 2 deletions Firestore/core/src/util/log_stdio.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 Google
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,7 +24,6 @@
namespace firebase {
namespace firestore {
namespace util {

namespace {

LogLevel g_log_level = kLogLevelNotice;
Expand Down
5 changes: 2 additions & 3 deletions Firestore/core/src/util/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
namespace firebase {
namespace firestore {
namespace util {

constexpr size_t Path::npos;

namespace {

#if defined(_WIN32)
Expand Down Expand Up @@ -142,6 +139,8 @@ absl::string_view CanonicalPath(const Path::string_type& path) {

} // namespace

constexpr size_t Path::npos;

Path Path::FromUtf8(absl::string_view utf8_pathname) {
#if defined(_WIN32)
return Path{Utf8ToNative(utf8_pathname)};
Expand Down
Loading