Skip to content

Commit 868a14f

Browse files
authored
Minor code cleanups 2 (#6171)
* Minor code cleanups * Clang-format * Adjust line coverage target --------- Co-authored-by: Anton Kolesnyk <[email protected]>
1 parent ee75d1d commit 868a14f

File tree

20 files changed

+29
-40
lines changed

20 files changed

+29
-40
lines changed

sdk/attestation/azure-security-attestation/src/attestation_administration_client.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,6 @@ void AttestationAdministrationClient::RetrieveResponseValidationCollateral(
542542
m_endpoint, HttpMethod::Get, {"certs"}, nullptr);
543543
auto response = AttestationCommonRequest::SendRequest(*m_pipeline, request, context);
544544
auto jsonWebKeySet(JsonWebKeySetSerializer::Deserialize(response));
545-
TokenValidationCertificateResult returnValue;
546545
std::vector<AttestationSigner> newValue;
547546
for (const auto& jwk : jsonWebKeySet.Keys)
548547
{

sdk/attestation/azure-security-attestation/src/attestation_client.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ void AttestationClient::RetrieveResponseValidationCollateral(Azure::Core::Contex
261261
auto response
262262
= AttestationCommonRequest::SendRequest(*m_pipeline, request, tracingContext.Context);
263263
auto jsonWebKeySet(JsonWebKeySetSerializer::Deserialize(response));
264-
TokenValidationCertificateResult returnValue;
265264
std::vector<AttestationSigner> newValue;
266265
for (const auto& jwk : jsonWebKeySet.Keys)
267266
{

sdk/attestation/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extends:
2929
Location: WestUS
3030
CtestRegex: azure-security-attestation.*
3131
LiveTestCtestRegex: azure-security-attestation.*
32-
LineCoverageTarget: 70
32+
LineCoverageTarget: 69.9834
3333
BranchCoverageTarget: 34
3434
Artifacts:
3535
- Name: azure-security-attestation

sdk/core/azure-core/inc/azure/core/azure_assert.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
/** @brief Azure specific assert macro.*/
5151
#define AZURE_ASSERT(exp) assert((exp))
5252
/** @brief Azure specific assert macro with message.*/
53-
#define AZURE_ASSERT_MSG(exp, msg) assert(((void)msg, (exp)))
53+
#define AZURE_ASSERT_MSG(exp, msg) assert(((void)(msg), (exp)))
5454

5555
#endif
5656

sdk/core/azure-core/inc/azure/core/exception.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ namespace Azure { namespace Core {
176176
* @brief Destructs `%RequestFailedException`.
177177
*
178178
*/
179-
~RequestFailedException() = default;
179+
~RequestFailedException() override = default;
180180

181181
private:
182182
static std::string GetRawResponseField(

sdk/core/azure-core/inc/azure/core/http/http.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ namespace Azure { namespace Core { namespace Http {
327327
* @brief A value indicating whether the returned raw response for this request will be buffered
328328
* within a memory buffer or if it will be returned as a body stream instead.
329329
*/
330-
bool ShouldBufferResponse() { return this->m_shouldBufferResponse; }
330+
bool ShouldBufferResponse() const { return this->m_shouldBufferResponse; }
331331

332332
/**
333333
* @brief Get URL.

sdk/core/azure-core/inc/azure/core/internal/http/pipeline.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace Azure { namespace Core { namespace Http { namespace _internal {
4646
explicit HttpPipeline(
4747
const std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>>& policies)
4848
{
49-
if (policies.size() == 0)
49+
if (policies.empty())
5050
{
5151
throw std::invalid_argument("policies cannot be empty");
5252
}
@@ -190,7 +190,7 @@ namespace Azure { namespace Core { namespace Http { namespace _internal {
190190
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>>&& policies)
191191
: m_policies(std::move(policies))
192192
{
193-
if (m_policies.size() == 0)
193+
if (m_policies.empty())
194194
{
195195
throw std::invalid_argument("policies cannot be empty");
196196
}

sdk/core/azure-core/inc/azure/core/internal/tracing/service_tracing.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "azure/core/internal/extendable_enumeration.hpp"
77
#include "azure/core/internal/tracing/tracing_impl.hpp"
88

9+
#include <utility>
10+
911
#pragma once
1012

1113
/**
@@ -31,7 +33,7 @@ namespace Azure { namespace Core { namespace Tracing { namespace _internal {
3133

3234
friend class TracingContextFactory;
3335
ServiceSpan() = default;
34-
explicit ServiceSpan(std::shared_ptr<Span> span) : m_span(span) {}
36+
explicit ServiceSpan(std::shared_ptr<Span> span) : m_span(std::move(span)) {}
3537

3638
ServiceSpan(const ServiceSpan&) = delete;
3739
ServiceSpan& operator=(ServiceSpan const&) = delete;
@@ -41,7 +43,7 @@ namespace Azure { namespace Core { namespace Tracing { namespace _internal {
4143
public:
4244
ServiceSpan(ServiceSpan&& that) = default;
4345

44-
~ServiceSpan()
46+
~ServiceSpan() override
4547
{
4648
if (m_span)
4749
{

sdk/core/azure-core/inc/azure/core/io/body_stream.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ namespace Azure { namespace Core { namespace IO {
227227
AZURE_ASSERT(fileHandle && offset >= 0 && length >= 0);
228228
}
229229

230-
RandomAccessFileBodyStream() : m_filehandle(NULL), m_baseOffset(0), m_length(0), m_offset(0)
230+
RandomAccessFileBodyStream()
231+
: m_filehandle(nullptr), m_baseOffset(0), m_length(0), m_offset(0)
231232
{
232233
}
233234
#endif
@@ -275,7 +276,7 @@ namespace Azure { namespace Core { namespace IO {
275276
* @brief Closes the file and cleans up any resources.
276277
*
277278
*/
278-
~FileBodyStream();
279+
~FileBodyStream() override;
279280

280281
/** @brief Rewind seeks the current stream to the start of the file. */
281282
void Rewind() override;

sdk/core/azure-core/inc/azure/core/nullable.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace Azure {
1818
namespace _detail {
1919
struct NontrivialEmptyType final
2020
{
21-
constexpr NontrivialEmptyType() noexcept {}
21+
constexpr NontrivialEmptyType() noexcept = default;
2222
};
2323
} // namespace _detail
2424

sdk/core/azure-core/inc/azure/core/url.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ namespace Azure { namespace Core {
8888
* @brief Constructs a new, empty URL object.
8989
*
9090
*/
91-
Url() {}
91+
Url() = default;
9292

9393
/**
9494
* @brief Constructs a URL from a URL-encoded string.

sdk/core/azure-core/src/base64.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
namespace {
1010

11-
static char const Base64EncodeArray[65]
11+
char const Base64EncodeArray[65]
1212
= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
13-
static char const EncodingPad = '=';
14-
static int8_t const Base64DecodeArray[256] = {
13+
char const EncodingPad = '=';
14+
int8_t const Base64DecodeArray[256] = {
1515
-1,
1616
-1,
1717
-1,
@@ -271,7 +271,7 @@ static int8_t const Base64DecodeArray[256] = {
271271
-1,
272272
};
273273

274-
static int32_t Base64Encode(const uint8_t* threeBytes)
274+
int32_t Base64Encode(const uint8_t* threeBytes)
275275
{
276276
int32_t i = (threeBytes[0] << 16) | (threeBytes[1] << 8) | threeBytes[2];
277277

@@ -283,7 +283,7 @@ static int32_t Base64Encode(const uint8_t* threeBytes)
283283
return i0 | (i1 << 8) | (i2 << 16) | (i3 << 24);
284284
}
285285

286-
static int32_t Base64EncodeAndPadOne(const uint8_t* twoBytes)
286+
int32_t Base64EncodeAndPadOne(const uint8_t* twoBytes)
287287
{
288288
int32_t i = twoBytes[0] << 16 | (twoBytes[1] << 8);
289289

@@ -294,7 +294,7 @@ static int32_t Base64EncodeAndPadOne(const uint8_t* twoBytes)
294294
return i0 | (i1 << 8) | (i2 << 16) | (EncodingPad << 24);
295295
}
296296

297-
static int32_t Base64EncodeAndPadTwo(const uint8_t* oneByte)
297+
int32_t Base64EncodeAndPadTwo(const uint8_t* oneByte)
298298
{
299299
int32_t i = oneByte[0] << 8;
300300

@@ -304,7 +304,7 @@ static int32_t Base64EncodeAndPadTwo(const uint8_t* oneByte)
304304
return i0 | (i1 << 8) | (EncodingPad << 16) | (EncodingPad << 24);
305305
}
306306

307-
static void Base64WriteIntAsFourBytes(char* destination, int32_t value)
307+
void Base64WriteIntAsFourBytes(char* destination, int32_t value)
308308
{
309309
destination[3] = static_cast<uint8_t>((value >> 24) & 0xFF);
310310
destination[2] = static_cast<uint8_t>((value >> 16) & 0xFF);
@@ -344,7 +344,7 @@ std::string Base64Encode(uint8_t const* const data, size_t length)
344344
return encodedResult;
345345
}
346346

347-
static int32_t Base64Decode(const char* encodedBytes)
347+
int32_t Base64Decode(const char* encodedBytes)
348348
{
349349
int32_t i0 = encodedBytes[0];
350350
int32_t i1 = encodedBytes[1];
@@ -367,7 +367,7 @@ static int32_t Base64Decode(const char* encodedBytes)
367367
return i0;
368368
}
369369

370-
static void Base64WriteThreeLowOrderBytes(std::vector<uint8_t>::iterator destination, int64_t value)
370+
void Base64WriteThreeLowOrderBytes(std::vector<uint8_t>::iterator destination, int64_t value)
371371
{
372372
destination[0] = static_cast<uint8_t>(value >> 16);
373373
destination[1] = static_cast<uint8_t>(value >> 8);

sdk/core/azure-core/src/cryptography/md5.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Md5BCrypt final : public Azure::Core::Cryptography::Hash {
9797
size_t m_hashLength = 0;
9898
std::string m_buffer;
9999

100-
void OnAppend(const uint8_t* data, size_t length)
100+
void OnAppend(const uint8_t* data, size_t length) override
101101
{
102102
if (!BCRYPT_SUCCESS(
103103
m_status = BCryptHashData(
@@ -110,7 +110,7 @@ class Md5BCrypt final : public Azure::Core::Cryptography::Hash {
110110
}
111111
}
112112

113-
std::vector<uint8_t> OnFinal(const uint8_t* data, size_t length)
113+
std::vector<uint8_t> OnFinal(const uint8_t* data, size_t length) override
114114
{
115115
OnAppend(data, length);
116116

@@ -148,7 +148,7 @@ class Md5BCrypt final : public Azure::Core::Cryptography::Hash {
148148
}
149149
}
150150

151-
~Md5BCrypt()
151+
~Md5BCrypt() override
152152
{
153153
if (m_hashHandle)
154154
{
@@ -209,7 +209,7 @@ Azure::Core::Cryptography::Md5Hash::Md5Hash() : m_implementation(std::make_uniqu
209209
#endif
210210

211211
namespace Azure { namespace Core { namespace Cryptography {
212-
Md5Hash::~Md5Hash() {}
212+
Md5Hash::~Md5Hash() = default;
213213

214214
void Md5Hash::OnAppend(const uint8_t* data, size_t length)
215215
{

sdk/core/azure-core/src/environment_log_level_listener.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ EnvironmentLogLevelListener::GetLogListener()
148148
}
149149

150150
namespace {
151-
static bool g_initialized;
151+
bool g_initialized = false;
152152
} // namespace
153153

154154
bool EnvironmentLogLevelListener::IsInitialized() { return g_initialized; }

sdk/core/azure-core/src/http/request_activity_policy.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
// Licensed under the MIT License.
33

44
#include "azure/core/http/policies/policy.hpp"
5-
#include "azure/core/internal/diagnostics/log.hpp"
65
#include "azure/core/internal/http/http_sanitizer.hpp"
76
#include "azure/core/internal/tracing/service_tracing.hpp"
87

98
#include <algorithm>
10-
#include <cstdlib>
11-
#include <limits>
129
#include <sstream>
1310
#include <thread>
1411

sdk/core/azure-core/src/http/user_agent.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
* @brief Contains the user agent string generator implementation.
77
*/
88

9-
#include "azure/core/context.hpp"
109
#include "azure/core/http/http.hpp"
11-
#include "azure/core/http/policies/policy.hpp"
1210
#include "azure/core/internal/strings.hpp"
13-
#include "azure/core/internal/tracing/service_tracing.hpp"
1411
#include "azure/core/platform.hpp"
1512

1613
#include <sstream>

sdk/core/azure-core/src/logger.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
#include "azure/core/internal/diagnostics/log.hpp"
77
#include "private/environment_log_level_listener.hpp"
88

9-
#include <iostream>
109
#include <mutex>
1110
#include <shared_mutex>
12-
#include <sstream>
1311

1412
using namespace Azure::Core::Diagnostics;
1513
using namespace Azure::Core::Diagnostics::_internal;

sdk/core/azure-core/src/tracing/tracing.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License.
33

44
#include "azure/core/context.hpp"
5-
#include "azure/core/http/policies/policy.hpp"
65
#include "azure/core/internal/tracing/service_tracing.hpp"
76
#include "azure/core/internal/tracing/tracing_impl.hpp"
87

@@ -42,7 +41,6 @@ namespace Azure { namespace Core { namespace Tracing { namespace _internal {
4241
std::string const& methodName,
4342
Azure::Core::Context const& context) const
4443
{
45-
Azure::Core::Context contextToUse = context;
4644
CreateSpanOptions createOptions;
4745

4846
createOptions.Kind = SpanKind::Internal;

sdk/core/azure-core/src/uuid.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "azure/core/platform.hpp"
88

99
#include <cassert>
10-
#include <cstdio>
1110
#include <cstring>
1211
#include <random>
1312
#include <stdexcept>

sdk/identity/azure-identity/src/client_assertion_credential.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include "private/client_assertion_credential_impl.hpp"
77
#include "private/identity_log.hpp"
8-
#include "private/package_version.hpp"
98
#include "private/tenant_id_resolver.hpp"
109

1110
#include <azure/core/internal/json/json.hpp>

0 commit comments

Comments
 (0)