Skip to content

Commit

Permalink
Mention min clang format version and format all cpp and hpp files wit…
Browse files Browse the repository at this point in the history
…h clang-format version 9.0 (#1208)

* Add info about clang-format version

* updates for cpp and hpp format

* special cases
  • Loading branch information
vhvb1989 authored Dec 18, 2020
1 parent 6a317e8 commit 8aac909
Show file tree
Hide file tree
Showing 42 changed files with 192 additions and 210 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ CMake version 3.13 or higher is required to build these libraries. Download and
#### Third Party Dependencies
- curl
- libxml2
- clang-format (min version 9)

Vcpkg can be used to install the Azure SDK for CPP dependencies into a specific folder on the system instead of globally installing them.
Follow [vcpkg install guide](https://github.com/microsoft/vcpkg#getting-started) to get vcpkg and install the following dependencies:
Expand Down
8 changes: 4 additions & 4 deletions sdk/core/azure-core/inc/azure/core/http/http.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,10 @@ namespace Azure { namespace Core { namespace Http {
*/
explicit Request(HttpMethod httpMethod, Url url, bool downloadViaStream)
: Request(
httpMethod,
std::move(url),
NullBodyStream::GetNullBodyStream(),
downloadViaStream)
httpMethod,
std::move(url),
NullBodyStream::GetNullBodyStream(),
downloadViaStream)
{
}

Expand Down
4 changes: 3 additions & 1 deletion sdk/core/azure-core/inc/azure/core/nullable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ namespace Azure { namespace Core {
* @param initialValue A non-absent value to initialize with.
*/
constexpr Nullable(T initialValue) noexcept(std::is_nothrow_move_constructible<T>::value)
: m_value(std::move(initialValue)), m_hasValue(true) {}
: m_value(std::move(initialValue)), m_hasValue(true)
{
}

/// Copy constructor.
Nullable(const Nullable& other) noexcept(std::is_nothrow_copy_constructible<T>::value)
Expand Down
23 changes: 7 additions & 16 deletions sdk/core/azure-core/inc/azure/core/response.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,44 +57,35 @@ namespace Azure { namespace Core {
*
* @return `true` If a value is contained, `false` if value is absent.
*/
bool HasValue() const noexcept {
return this->m_value.HasValue();
}
bool HasValue() const noexcept { return this->m_value.HasValue(); }

/**
* @brief Get a pointer to a value of a specific type.
*/
const T* operator->() const {
const T* operator->() const
{
return &this->m_value.GetValue(); // GetValue ensures there is a contained value
}

/**
* @brief Get a pointer to a value of a specific type.
*/
T* operator->() {
return &this->m_value.GetValue();
}
T* operator->() { return &this->m_value.GetValue(); }

/**
* @brief Get value of a specific type.
*/
T& operator*() {
return this->m_value.GetValue();
}
T& operator*() { return this->m_value.GetValue(); }

/**
* @brief Get value of a specific type.
*/
const T& operator*() const {
return this->m_value.GetValue();
}
const T& operator*() const { return this->m_value.GetValue(); }

/**
* @brief Get an rvalue reference to the value of a specific type.
*/
T&& ExtractValue() {
return std::move(this->m_value).GetValue();
}
T&& ExtractValue() { return std::move(this->m_value).GetValue(); }

/**
* @brief Get a smart pointer rvalue reference to the value of a specific type.
Expand Down
1 change: 0 additions & 1 deletion sdk/core/azure-core/inc/azure/core/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ namespace Azure { namespace Core {
#undef AZURE_CORE_VERSION_MINOR
#undef AZURE_CORE_VERSION_PATCH
#undef AZURE_CORE_VERSION_PRERELEASE

18 changes: 6 additions & 12 deletions sdk/core/azure-core/src/http/curl/curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,11 @@ CURLcode CurlConnection::SendBuffer(

switch (sendResult)
{
case CURLE_OK:
{
case CURLE_OK: {
sentBytesTotal += sentBytesPerRequest;
break;
}
case CURLE_AGAIN:
{
case CURLE_AGAIN: {
// start polling operation with 1 min timeout
auto pollUntilSocketIsReady = pollSocketUntilEventOrTimeout(
context, m_curlSocket, PollSocketDirection::Write, 60000L);
Expand All @@ -364,8 +362,7 @@ CURLcode CurlConnection::SendBuffer(
// Ready to continue download.
break;
}
default:
{
default: {
return sendResult;
}
}
Expand Down Expand Up @@ -721,8 +718,7 @@ int64_t CurlConnection::ReadFromSocket(Context const& context, uint8_t* buffer,

switch (readResult)
{
case CURLE_AGAIN:
{
case CURLE_AGAIN: {
// start polling operation
auto pollUntilSocketIsReady = pollSocketUntilEventOrTimeout(
context, m_curlSocket, PollSocketDirection::Read, 60000L);
Expand All @@ -739,12 +735,10 @@ int64_t CurlConnection::ReadFromSocket(Context const& context, uint8_t* buffer,
// Ready to continue download.
break;
}
case CURLE_OK:
{
case CURLE_OK: {
break;
}
default:
{
default: {
// Error reading from socket
throw TransportException(
"Error while reading from network socket. CURLE code: " + std::to_string(readResult)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void printStream(Context const& context, std::unique_ptr<Http::RawResponse> resp
}

cout << static_cast<typename std::underlying_type<Http::HttpStatusCode>::type>(
response->GetStatusCode())
response->GetStatusCode())
<< endl;
cout << response->GetReasonPhrase() << endl;
cout << "headers:" << endl;
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure-core/test/ut/logging.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT

#include <gtest/gtest.h>
#include <azure/core/http/pipeline.hpp>
#include <azure/core/internal/log.hpp>
#include <azure/core/logging/logging.hpp>
#include <gtest/gtest.h>

#include <utility>
#include <vector>
Expand Down
17 changes: 7 additions & 10 deletions sdk/core/azure-core/test/ut/nullable.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT

#include <gtest/gtest.h>
#include <azure/core/nullable.hpp>
#include <gtest/gtest.h>
#include <string>
#include <vector>

Expand Down Expand Up @@ -123,36 +123,35 @@ TEST(Nullable, Swap)

TEST(Nullable, CopyConstruction)
{
//Empty
// Empty
Nullable<int> val1;
Nullable<int> val2(val1);
EXPECT_FALSE(val1);
EXPECT_FALSE(val2);

//Non-Empty
// Non-Empty
Nullable<int> val3(12345);
Nullable<int> val4(val3);
EXPECT_TRUE(val3);
EXPECT_TRUE(val4);
EXPECT_TRUE(val3.GetValue() == 12345);
EXPECT_TRUE(val4.GetValue() == 12345);

//Literal
// Literal
Nullable<int> val5 = 54321;
EXPECT_TRUE(val5);
EXPECT_TRUE(val5.GetValue() == 54321);

//Value
// Value
const int i = 1;
Nullable<int> val6(i);
EXPECT_TRUE(val6);
EXPECT_TRUE(val6.GetValue() == 1);

}

TEST(Nullable, Disengage)
{
Nullable<int> val1(12345);
Nullable<int> val1(12345);
val1.Reset();
EXPECT_FALSE(val1);
}
Expand All @@ -170,7 +169,5 @@ TEST(Nullable, ValueOr)
EXPECT_FALSE(val2);
EXPECT_TRUE(val2.ValueOr(678910) == 678910);
// Ensure val2 is still disengaged after call to ValueOr
EXPECT_FALSE(val2);

EXPECT_FALSE(val2);
}

6 changes: 3 additions & 3 deletions sdk/core/azure-core/test/ut/operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TEST(Operation, Poll)
EXPECT_FALSE(operation.IsDone());
EXPECT_FALSE(operation.HasValue());

while(!operation.IsDone())
while (!operation.IsDone())
{
EXPECT_FALSE(operation.HasValue());
EXPECT_THROW(operation.Value(), std::runtime_error);
Expand All @@ -45,12 +45,12 @@ TEST(Operation, PollUntilDone)
EXPECT_FALSE(operation.IsDone());
EXPECT_FALSE(operation.HasValue());
EXPECT_THROW(operation.Value(), std::runtime_error);

auto start = std::chrono::high_resolution_clock::now();
auto response = operation.PollUntilDone(500ms);
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> elapsed = end - start;
//StringOperation test code is implemented to poll 2 times
// StringOperation test code is implemented to poll 2 times
EXPECT_TRUE(elapsed >= 1s);

EXPECT_TRUE(operation.IsDone());
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure-core/test/ut/pipeline.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT

#include <gtest/gtest.h>
#include <azure/core/http/pipeline.hpp>
#include <azure/core/http/policy.hpp>
#include <gtest/gtest.h>

#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure-core/test/ut/policy.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT

#include <gtest/gtest.h>
#include <azure/core/http/pipeline.hpp>
#include <azure/core/http/policy.hpp>
#include <gtest/gtest.h>

#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure-core/test/ut/simplified_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*
*/

#include <gtest/gtest.h>
#include <azure/core.hpp>
#include <gtest/gtest.h>

#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure-core/test/ut/telemetry_policy.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT

#include <gtest/gtest.h>
#include <azure/core/http/pipeline.hpp>
#include <azure/core/http/policy.hpp>
#include <gtest/gtest.h>

using namespace Azure::Core;
using namespace Azure::Core::Http;
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure-core/test/ut/transport_adapter_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*
*/

#include <gtest/gtest.h>
#include <azure/core/http/body_stream.hpp>
#include <azure/core/http/http.hpp>
#include <azure/core/http/pipeline.hpp>
#include <gtest/gtest.h>

#include <memory>
#include <vector>
Expand Down
10 changes: 5 additions & 5 deletions sdk/core/azure-core/test/ut/uuid.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT

#include <gtest/gtest.h>
#include <azure/core/uuid.hpp>
#include <string>
#include <gtest/gtest.h>
#include <set>
#include <string>

using namespace Azure::Core;

Expand All @@ -14,14 +14,14 @@ TEST(Uuid, Basic)
EXPECT_TRUE(uuid.GetUuidString().length() == 36);
}

TEST(Uuid, Randomness)
{
TEST(Uuid, Randomness)
{
const int size = 100000;
std::set<std::string> uuids;
for (int i = 0; i < size; i++)
{
auto ret = uuids.insert(Uuid::CreateUuid().GetUuidString());
//If the value already exists in the set then the insert will fail
// If the value already exists in the set then the insert will fail
// ret.second == false means the insert failed.
EXPECT_TRUE(ret.second);
}
Expand Down
1 change: 0 additions & 1 deletion sdk/identity/azure-identity/inc/azure/identity/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ namespace Azure { namespace Identity {
#undef AZURE_IDENTITY_VERSION_MINOR
#undef AZURE_IDENTITY_VERSION_PATCH
#undef AZURE_IDENTITY_VERSION_PRERELEASE

Loading

0 comments on commit 8aac909

Please sign in to comment.