Skip to content

Commit dff39f3

Browse files
authored
[CodeHealth] Fix clang tidy warnings part 4 (#3501)
1 parent 22715dd commit dff39f3

File tree

13 files changed

+46
-36
lines changed

13 files changed

+46
-36
lines changed

.github/workflows/clang-tidy.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
matrix:
1818
include:
1919
- cmake_options: all-options-abiv1-preview
20-
warning_limit: 86
20+
warning_limit: 62
2121
- cmake_options: all-options-abiv2-preview
22-
warning_limit: 86
22+
warning_limit: 62
2323
steps:
2424
- name: Harden the runner (Audit all outbound calls)
2525
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ Increment the:
3737
[#3496](https://github.com/open-telemetry/opentelemetry-cpp/pull/3496)
3838

3939
* [CodeHealth] Fix clang-tidy warnings part 3
40-
[#3496](https://github.com/open-telemetry/opentelemetry-cpp/pull/3498)
40+
[#3498](https://github.com/open-telemetry/opentelemetry-cpp/pull/3498)
41+
42+
* [CodeHealth] Fix clang-tidy warnings part 4
43+
[#3501](https://github.com/open-telemetry/opentelemetry-cpp/pull/3501)
4144

4245
Important changes:
4346

exporters/otlp/src/otlp_http_exporter_options.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ OtlpHttpExporterOptions::OtlpHttpExporterOptions()
2121
console_debug(false),
2222
timeout(GetOtlpDefaultTracesTimeout()),
2323
http_headers(GetOtlpDefaultTracesHeaders()),
24+
#ifdef ENABLE_ASYNC_EXPORT
25+
max_concurrent_requests{64},
26+
max_requests_per_connection{8},
27+
#endif
2428
ssl_insecure_skip_verify(false),
2529
ssl_ca_cert_path(GetOtlpDefaultTracesSslCertificatePath()),
2630
ssl_ca_cert_string(GetOtlpDefaultTracesSslCertificateString()),
@@ -37,12 +41,7 @@ OtlpHttpExporterOptions::OtlpHttpExporterOptions()
3741
retry_policy_initial_backoff(GetOtlpDefaultTracesRetryInitialBackoff()),
3842
retry_policy_max_backoff(GetOtlpDefaultTracesRetryMaxBackoff()),
3943
retry_policy_backoff_multiplier(GetOtlpDefaultTracesRetryBackoffMultiplier())
40-
{
41-
#ifdef ENABLE_ASYNC_EXPORT
42-
max_concurrent_requests = 64;
43-
max_requests_per_connection = 8;
44-
#endif /* ENABLE_ASYNC_EXPORT */
45-
}
44+
{}
4645

4746
OtlpHttpExporterOptions::~OtlpHttpExporterOptions() {}
4847

exporters/otlp/src/otlp_http_log_record_exporter_options.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ OtlpHttpLogRecordExporterOptions::OtlpHttpLogRecordExporterOptions()
2121
console_debug(false),
2222
timeout(GetOtlpDefaultLogsTimeout()),
2323
http_headers(GetOtlpDefaultLogsHeaders()),
24+
#ifdef ENABLE_ASYNC_EXPORT
25+
max_concurrent_requests{64},
26+
max_requests_per_connection{8},
27+
#endif
2428
ssl_insecure_skip_verify(false),
2529
ssl_ca_cert_path(GetOtlpDefaultLogsSslCertificatePath()),
2630
ssl_ca_cert_string(GetOtlpDefaultLogsSslCertificateString()),
@@ -37,12 +41,7 @@ OtlpHttpLogRecordExporterOptions::OtlpHttpLogRecordExporterOptions()
3741
retry_policy_initial_backoff(GetOtlpDefaultLogsRetryInitialBackoff()),
3842
retry_policy_max_backoff(GetOtlpDefaultLogsRetryMaxBackoff()),
3943
retry_policy_backoff_multiplier(GetOtlpDefaultLogsRetryBackoffMultiplier())
40-
{
41-
#ifdef ENABLE_ASYNC_EXPORT
42-
max_concurrent_requests = 64;
43-
max_requests_per_connection = 8;
44-
#endif
45-
}
44+
{}
4645

4746
OtlpHttpLogRecordExporterOptions::~OtlpHttpLogRecordExporterOptions() {}
4847

exporters/otlp/src/otlp_http_metric_exporter_options.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ OtlpHttpMetricExporterOptions::OtlpHttpMetricExporterOptions()
2323
timeout(GetOtlpDefaultMetricsTimeout()),
2424
http_headers(GetOtlpDefaultMetricsHeaders()),
2525
aggregation_temporality(PreferredAggregationTemporality::kCumulative),
26+
#ifdef ENABLE_ASYNC_EXPORT
27+
max_concurrent_requests{64},
28+
max_requests_per_connection{8},
29+
#endif
2630
ssl_insecure_skip_verify(false),
2731
ssl_ca_cert_path(GetOtlpDefaultMetricsSslCertificatePath()),
2832
ssl_ca_cert_string(GetOtlpDefaultMetricsSslCertificateString()),
@@ -39,12 +43,7 @@ OtlpHttpMetricExporterOptions::OtlpHttpMetricExporterOptions()
3943
retry_policy_initial_backoff(GetOtlpDefaultMetricsRetryInitialBackoff()),
4044
retry_policy_max_backoff(GetOtlpDefaultMetricsRetryMaxBackoff()),
4145
retry_policy_backoff_multiplier(GetOtlpDefaultMetricsRetryBackoffMultiplier())
42-
{
43-
#ifdef ENABLE_ASYNC_EXPORT
44-
max_concurrent_requests = 64;
45-
max_requests_per_connection = 8;
46-
#endif
47-
}
46+
{}
4847

4948
OtlpHttpMetricExporterOptions::~OtlpHttpMetricExporterOptions() {}
5049

ext/src/http/client/curl/http_operation_curl.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ std::chrono::system_clock::time_point HttpOperation::NextRetryTime()
515515
# define HAVE_TLS_VERSION
516516
#endif
517517

518+
// NOLINTNEXTLINE(google-runtime-int)
518519
static long parse_min_ssl_version(const std::string &version)
519520
{
520521
#ifdef HAVE_TLS_VERSION
@@ -532,6 +533,7 @@ static long parse_min_ssl_version(const std::string &version)
532533
return 0;
533534
}
534535

536+
// NOLINTNEXTLINE(google-runtime-int)
535537
static long parse_max_ssl_version(const std::string &version)
536538
{
537539
#ifdef HAVE_TLS_VERSION
@@ -591,6 +593,7 @@ CURLcode HttpOperation::SetCurlPtrOption(CURLoption option, void *value)
591593
return rc;
592594
}
593595

596+
// NOLINTNEXTLINE(google-runtime-int)
594597
CURLcode HttpOperation::SetCurlLongOption(CURLoption option, long value)
595598
{
596599
CURLcode rc;
@@ -877,8 +880,10 @@ CURLcode HttpOperation::Setup()
877880

878881
#ifdef HAVE_TLS_VERSION
879882
/* By default, TLSv1.2 or better is required (if we have TLS). */
883+
// NOLINTNEXTLINE(google-runtime-int)
880884
long min_ssl_version = CURL_SSLVERSION_TLSv1_2;
881885
#else
886+
// NOLINTNEXTLINE(google-runtime-int)
882887
long min_ssl_version = 0;
883888
#endif
884889

@@ -903,6 +908,7 @@ CURLcode HttpOperation::Setup()
903908
* The CURL + openssl library may be more recent than this code,
904909
* and support a version we do not know about.
905910
*/
911+
// NOLINTNEXTLINE(google-runtime-int)
906912
long max_ssl_version = 0;
907913

908914
if (!ssl_options_.ssl_max_tls.empty())
@@ -921,6 +927,7 @@ CURLcode HttpOperation::Setup()
921927
#endif
922928
}
923929

930+
// NOLINTNEXTLINE(google-runtime-int)
924931
long version_range = min_ssl_version | max_ssl_version;
925932
if (version_range != 0)
926933
{
@@ -967,6 +974,7 @@ CURLcode HttpOperation::Setup()
967974
if (ssl_options_.ssl_insecure_skip_verify)
968975
{
969976
/* 6 - DO NOT ENFORCE VERIFICATION, This is not secure. */
977+
// NOLINTNEXTLINE(google-runtime-int)
970978
rc = SetCurlLongOption(CURLOPT_USE_SSL, static_cast<long>(CURLUSESSL_NONE));
971979
if (rc != CURLE_OK)
972980
{
@@ -988,6 +996,7 @@ CURLcode HttpOperation::Setup()
988996
else
989997
{
990998
/* 6 - ENFORCE VERIFICATION */
999+
// NOLINTNEXTLINE(google-runtime-int)
9911000
rc = SetCurlLongOption(CURLOPT_USE_SSL, static_cast<long>(CURLUSESSL_ALL));
9921001
if (rc != CURLE_OK)
9931002
{
@@ -1042,7 +1051,7 @@ CURLcode HttpOperation::Setup()
10421051

10431052
// TODO: control local port to use
10441053
// curl_easy_setopt(curl, CURLOPT_LOCALPORT, dcf_port);
1045-
1054+
// NOLINTNEXTLINE(google-runtime-int)
10461055
rc = SetCurlLongOption(CURLOPT_TIMEOUT_MS, static_cast<long>(http_conn_timeout_.count()));
10471056
if (rc != CURLE_OK)
10481057
{

ext/test/http/curl_http_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "opentelemetry/nostd/function_ref.h"
3636
#include "opentelemetry/nostd/string_view.h"
3737

38-
#define HTTP_PORT 19000
38+
constexpr int HTTP_PORT{19000};
3939

4040
namespace curl = opentelemetry::ext::http::client::curl;
4141
namespace http_client = opentelemetry::ext::http::client;

sdk/include/opentelemetry/sdk/metrics/data/point_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class HistogramPointData
6060
HistogramPointData &operator=(HistogramPointData &&) = default;
6161
HistogramPointData(const HistogramPointData &) = default;
6262
HistogramPointData() = default;
63-
HistogramPointData(std::vector<double> &boundaries) : boundaries_(boundaries) {}
63+
HistogramPointData(const std::vector<double> &boundaries) : boundaries_(boundaries) {}
6464
HistogramPointData &operator=(const HistogramPointData &other) = default;
6565
~HistogramPointData() = default;
6666

sdk/src/metrics/aggregation/base2_exponential_histogram_aggregation.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void Base2ExponentialHistogramAggregation::Aggregate(
131131
int64_t value,
132132
const PointAttributes & /* attributes */) noexcept
133133
{
134-
Aggregate(double(value));
134+
Aggregate(static_cast<double>(value));
135135
}
136136

137137
void Base2ExponentialHistogramAggregation::Aggregate(

sdk/test/common/attribute_utils_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ TEST(AttributeMapTest, EqualTo)
175175
Attributes attributes_different_size = {{"key0", "some value"}};
176176

177177
// check for the case where the number of attributes is the same but all keys are different
178-
Attributes attributes_different_all = {{"a", "b"}, {"c", "d"}, {"e", 4.0}, {"f", uint8_t(5)}};
178+
Attributes attributes_different_all = {
179+
{"a", "b"}, {"c", "d"}, {"e", 4.0}, {"f", static_cast<uint8_t>(5)}};
179180

180181
auto kv_iterable_different_value =
181182
opentelemetry::common::MakeKeyValueIterableView<Attributes>(attributes_different_value);

0 commit comments

Comments
 (0)