[CODE HEALTH] fix clang-tidy cppcoreguidelines-pro-type-const-cast warnings - #4482
[CODE HEALTH] fix clang-tidy cppcoreguidelines-pro-type-const-cast warnings#4482Anish701 wants to merge 7 commits into
Conversation
Signed-off-by: Anish701 <anish2sinha@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4482 +/- ##
==========================================
- Coverage 83.12% 83.11% -0.00%
==========================================
Files 519 519
Lines 20256 20254 -2
==========================================
- Hits 16835 16832 -3
- Misses 3421 3422 +1
🚀 New features to boost your workflow:
|
Signed-off-by: Anish701 <anish2sinha@gmail.com>
|
Thanks for the cleanup patch.
I don't think this is the proper fix, and it is a breaking change to the API: what if an existing application invokes opentelemetry with a const pointer today ? Please avoid changing this area, in favor of #4499 which is a different fix. |
| #if LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(7, 77, 0) | ||
| const char *data = ssl_options_.ssl_ca_cert_string.c_str(); | ||
| size_t data_len = ssl_options_.ssl_ca_cert_string.length(); | ||
| std::vector<char> blob_data(ssl_options_.ssl_ca_cert_string.begin(), |
There was a problem hiding this comment.
CURL is not changing the blob data given to it.
Making a mutable copy is not necessary, and causes overhead.
There was a problem hiding this comment.
Ok I silenced the lint warnings as you suggested using
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
marcalff
left a comment
There was a problem hiding this comment.
Thanks for the patch.
Please revert changes related to metrics instruments, to be fixed separately.
Please revert changes related to CURL blob parameters, and silence the warning instead.
Everything else looks ok.
Signed-off-by: Anish701 <anish2sinha@gmail.com>
@marcalff Thanks for reviewing! I reverted the metrics related changes. I also reverted the changes to the CURL blob params and silenced the warnings with Please let me know if any other changes are needed. Thanks! |
Fixes #4477
Changes
Resolves all
cppcoreguidelines-pro-type-const-castwarnings by eliminatingconst_castusage through proper typing .examples/http: Accept const T& in HttpTextMapCarrier constructor, removing the need to const_cast request headers.ext/http/client/curl: Change SetCurlPtrOption to accept const void*, and silenceconst_castwarning for string data.ext/test/w3c_tracecontext_http_test_server: Copy headers by value instead of const_casting a reference.sdk/common/circular_buffer.h: Make PeekImpl() a const method, eliminating the const_cast<CircularBuffer*>(this) in Peek().CHANGELOG.mdupdated for non-trivial changes - N/A this is a trivial code health change