Skip to content

Commit 9368909

Browse files
authored
Added a code format python script to drive clang-format (#377)
Wrote the script in python for versatility. Script will eventually be used by: - Github Actions to detect if formatting changes need to be made before merging to master, - Git hooks on all of our hosted platforms (Linux, Mac, Windows) where as shell scripts, bat files would have been a messy combination - Engineers who want to quickly format their sources. The files the script checks are determine by command line arguments. Options include: - Git Diff with master to determine which files have been altered. - A Directory, and optionally recursively travers its subdirectories. - A list of files. PR includes a formatted file for your reviewing pleasure.
1 parent 0ebb993 commit 9368909

File tree

3 files changed

+272
-17
lines changed

3 files changed

+272
-17
lines changed

.clang-format

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
BasedOnStyle: Google
2+
Standard: Cpp11
3+
ColumnLimit: 80
4+
BinPackParameters: false
5+
AllowAllParametersOfDeclarationOnNextLine: true
6+
SpacesInContainerLiterals: true
7+
DerivePointerAlignment: false
8+
PointerAlignment: Left
9+
AllowShortFunctionsOnASingleLine: None
10+
IncludeBlocks: Preserve

auth/integration_test/src/integration_test.cc

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,15 @@ class FirebaseAuthTest : public FirebaseTest {
102102
void DeleteUser();
103103

104104
// Passthrough method to the base class's WaitForCompletion.
105-
bool WaitForCompletion(firebase::Future<std::string> future, const char* fn,
105+
bool WaitForCompletion(firebase::Future<std::string> future,
106+
const char* fn,
106107
int expected_error = firebase::auth::kAuthErrorNone) {
107108
return FirebaseTest::WaitForCompletion(future, fn, expected_error);
108109
}
109110

110111
// Passthrough method to the base class's WaitForCompletion.
111-
bool WaitForCompletion(firebase::Future<void> future, const char* fn,
112+
bool WaitForCompletion(firebase::Future<void> future,
113+
const char* fn,
112114
int expected_error = firebase::auth::kAuthErrorNone) {
113115
return FirebaseTest::WaitForCompletion(future, fn, expected_error);
114116
}
@@ -125,7 +127,8 @@ class FirebaseAuthTest : public FirebaseTest {
125127
// Custom WaitForCompletion that checks if User and Provider ID matches
126128
// afterwards.
127129
bool WaitForCompletion(firebase::Future<firebase::auth::SignInResult> future,
128-
const char* fn, const std::string& provider_id);
130+
const char* fn,
131+
const std::string& provider_id);
129132

130133
bool initialized_;
131134
firebase::auth::Auth* auth_;
@@ -198,7 +201,8 @@ void FirebaseAuthTest::Terminate() {
198201
}
199202

200203
bool FirebaseAuthTest::WaitForCompletion(
201-
firebase::Future<firebase::auth::User*> future, const char* fn,
204+
firebase::Future<firebase::auth::User*> future,
205+
const char* fn,
202206
int expected_error) {
203207
bool succeeded = FirebaseTest::WaitForCompletion(future, fn, expected_error);
204208

@@ -216,7 +220,8 @@ bool FirebaseAuthTest::WaitForCompletion(
216220
}
217221

218222
bool FirebaseAuthTest::WaitForCompletion(
219-
firebase::Future<firebase::auth::SignInResult> future, const char* fn,
223+
firebase::Future<firebase::auth::SignInResult> future,
224+
const char* fn,
220225
int expected_error) {
221226
bool succeeded = FirebaseTest::WaitForCompletion(future, fn, expected_error);
222227

@@ -235,7 +240,8 @@ bool FirebaseAuthTest::WaitForCompletion(
235240
}
236241

237242
bool FirebaseAuthTest::WaitForCompletion(
238-
firebase::Future<firebase::auth::SignInResult> future, const char* fn,
243+
firebase::Future<firebase::auth::SignInResult> future,
244+
const char* fn,
239245
const std::string& provider_id) {
240246
bool succeeded = FirebaseTest::WaitForCompletion(future, fn);
241247
if (succeeded) {
@@ -320,7 +326,9 @@ class TestAuthStateListener : public firebase::auth::AuthStateListener {
320326
auth_states_.push_back(provider);
321327
}
322328
}
323-
const std::vector<std::string>& auth_states() { return auth_states_; }
329+
const std::vector<std::string>& auth_states() {
330+
return auth_states_;
331+
}
324332

325333
private:
326334
std::vector<std::string> auth_states_;
@@ -350,7 +358,9 @@ class TestIdTokenListener : public firebase::auth::IdTokenListener {
350358
}
351359
}
352360

353-
const std::vector<std::string>& token_states() { return token_states_; }
361+
const std::vector<std::string>& token_states() {
362+
return token_states_;
363+
}
354364

355365
private:
356366
std::vector<std::string> token_states_;
@@ -395,7 +405,8 @@ TEST_F(FirebaseAuthTest, TestTokensAndAuthStateListeners) {
395405

396406
static std::string GenerateEmailAddress() {
397407
char time_string[22];
398-
snprintf(time_string, 22, "%d", app_framework::GetCurrentTimeInMicroseconds());
408+
snprintf(time_string, 22, "%d",
409+
app_framework::GetCurrentTimeInMicroseconds());
399410
std::string email = "random_user_";
400411
email.append(time_string);
401412
email.append("@gmail.com");
@@ -718,7 +729,7 @@ TEST_F(FirebaseAuthTest, TestWithCustomEmailAndPassword) {
718729
EXPECT_NE(auth_->current_user(), nullptr);
719730
}
720731

721-
#if ! defined(__linux__)
732+
#if !defined(__linux__)
722733
// Test is disabled on linux due to the need to unlock the keystore.
723734
TEST_F(FirebaseAuthTest, TestAuthPersistenceWithAnonymousSignin) {
724735
WaitForCompletion(auth_->SignInAnonymously(), "SignInAnonymously");
@@ -734,7 +745,7 @@ TEST_F(FirebaseAuthTest, TestAuthPersistenceWithAnonymousSignin) {
734745
}
735746
#endif // ! defined(__linux__)
736747

737-
#if ! defined(__linux__)
748+
#if !defined(__linux__)
738749
// Test is disabled on linux due to the need to unlock the keychain.
739750
TEST_F(FirebaseAuthTest, TestAuthPersistenceWithEmailSignin) {
740751
std::string email = GenerateEmailAddress();
@@ -775,14 +786,14 @@ TEST_F(FirebaseAuthTest, TestAuthPersistenceWithEmailSignin) {
775786
}
776787
#endif // ! defined(__linux__)
777788

778-
779789
class PhoneListener : public firebase::auth::PhoneAuthProvider::Listener {
780790
public:
781791
PhoneListener()
782792
: on_verification_complete_count_(0),
783793
on_verification_failed_count_(0),
784794
on_code_sent_count_(0),
785-
on_code_auto_retrieval_time_out_count_(0) {}
795+
on_code_auto_retrieval_time_out_count_(0) {
796+
}
786797

787798
void OnVerificationCompleted(firebase::auth::Credential credential) override {
788799
LogDebug("PhoneListener: successful automatic verification.");
@@ -812,7 +823,9 @@ class PhoneListener : public firebase::auth::PhoneAuthProvider::Listener {
812823
on_code_auto_retrieval_time_out_count_++;
813824
}
814825

815-
const std::string& verification_id() const { return verification_id_; }
826+
const std::string& verification_id() const {
827+
return verification_id_;
828+
}
816829
const firebase::auth::PhoneAuthProvider::ForceResendingToken&
817830
force_resending_token() const {
818831
return force_resending_token_;
@@ -823,7 +836,9 @@ class PhoneListener : public firebase::auth::PhoneAuthProvider::Listener {
823836
int on_verification_failed_count() const {
824837
return on_verification_failed_count_;
825838
}
826-
int on_code_sent_count() const { return on_code_sent_count_; }
839+
int on_code_sent_count() const {
840+
return on_code_sent_count_;
841+
}
827842
int on_code_auto_retrieval_time_out_count() const {
828843
return on_code_auto_retrieval_time_out_count_;
829844
}
@@ -840,7 +855,9 @@ class PhoneListener : public firebase::auth::PhoneAuthProvider::Listener {
840855
on_code_auto_retrieval_time_out_count() == 0;
841856
}
842857

843-
firebase::auth::Credential credential() { return credential_; }
858+
firebase::auth::Credential credential() {
859+
return credential_;
860+
}
844861

845862
private:
846863
std::string verification_id_;
@@ -867,7 +884,8 @@ TEST_F(FirebaseAuthTest, TestPhoneAuth) {
867884
LogDebug("Calling VerifyPhoneNumber.");
868885
// Randomly choose one of the phone numbers to avoid collisions.
869886
const int random_phone_number =
870-
app_framework::GetCurrentTimeInMicroseconds() % kPhoneAuthTestNumPhoneNumbers;
887+
app_framework::GetCurrentTimeInMicroseconds() %
888+
kPhoneAuthTestNumPhoneNumbers;
871889
phone_provider.VerifyPhoneNumber(
872890
kPhoneAuthTestPhoneNumbers[random_phone_number], kPhoneAuthTimeoutMs,
873891
nullptr, &listener);

0 commit comments

Comments
 (0)