-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EXPORTER] fix clang-tidy warnings in UrlParser #3146
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for opentelemetry-cpp-api-docs canceled.
|
UrlParser(std::string url) : url_(url), success_(true) | ||
UrlParser(std::string url) : url_(std::move(url)), success_(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter 'url' is passed by value and only copied once; consider moving it to avoid unnecessary copies
https://clang.llvm.org/extra/clang-tidy/checks/performance/unnecessary-value-param.html
scheme_ = std::string(url_.begin() + cpos, url_.begin() + pos); | ||
scheme_ = std::string(url_.begin() + static_cast<std::string::difference_type>(cpos), | ||
url_.begin() + static_cast<std::string::difference_type>(pos)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one and similar issues:
Narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'difference_type' (aka 'long') is implementation-defined
https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.html
cpos = pos + 3; | ||
} | ||
|
||
// credentials | ||
size_t pos1 = url_.find_first_of("@", cpos); | ||
size_t pos2 = url_.find_first_of("/", cpos); | ||
size_t pos1 = url_.find_first_of('@', cpos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'find_first_of' called with a string literal consisting of a single character; consider using the more effective overload accepting a character
https://clang.llvm.org/extra/clang-tidy/checks/performance/faster-string-find.html
long value = strtol(hex, &endptr, 16); | ||
int value = static_cast<int>(std::strtol(hex, &endptr, 16)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The google-runtime-int
rule suggests replacing 'long' with 'int64', which seems overkill. Because two hexadecimal characters give a value in the [0; 255] range, downcasting to int
is safe.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3146 +/- ##
==========================================
+ Coverage 87.12% 87.83% +0.72%
==========================================
Files 200 195 -5
Lines 6109 6154 +45
==========================================
+ Hits 5322 5405 +83
+ Misses 787 749 -38
|
Changes
This PR fixes issues found by
clang-tidy
in UrlParser.Please provide a brief description of the changes here.
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes