Skip to content

Commit

Permalink
Update clang-tidy to 16 and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rmisev committed Jul 11, 2024
1 parent a28a854 commit a8289d4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Checks: '*,
-altera-unroll-loops,
-bugprone-easily-swappable-parameters,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-pro-bounds-constant-array-index,
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ on:
jobs:
build:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- name: clang-tidy-15 C++17
cxx_compiler: clang++-15
- name: clang-tidy-16 C++17
cxx_compiler: clang++-16
cxx_standard: 17
cmake_options: "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"

Expand All @@ -31,4 +31,4 @@ jobs:
- name: cmake
run: cmake -S . -B build -DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DCMAKE_CXX_STANDARD=${{ matrix.cxx_standard }} ${{ matrix.cmake_options }}
- name: static analysis
run: clang-tidy-15 -p build src/*.*
run: clang-tidy-16 -p build src/*.*
4 changes: 2 additions & 2 deletions include/upa/url.h
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ class url_serializer : public host_output {
url::PartType first_pt, std::size_t len0);

protected:
url& url_;
url& url_; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
// last serialized URL's part
url::PartType last_pt_;
};
Expand Down Expand Up @@ -2440,7 +2440,7 @@ inline void url_serializer::shorten_path() {
}

#if 0 // UNUSED
static inline std::size_t count_leading_path_slashes(const char* first, const char* last) {
inline std::size_t count_leading_path_slashes(const char* first, const char* last) {
return std::distance(first,
std::find_if_not(first, last, [](char c){ return c == '/'; }));
}
Expand Down
8 changes: 4 additions & 4 deletions include/upa/url_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class url_host {
host_.type_ = ht;
}
private:
url_host& host_;
url_host& host_; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
};

// members
Expand Down Expand Up @@ -202,7 +202,7 @@ inline validation_errc host_parser::parse_host(const CharT* first, const CharT*
// if there is a possibility to normalize them.
if (!(*ptr >= 0x3C && *ptr <= 0x3E && ptr + 1 < last && static_cast<UCharT>(ptr[1]) >= 0x80))
// 7. If asciiDomain contains a forbidden domain code point, domain-invalid-code-point
// validation error, return failure.
// validation error, return failure.
return validation_errc::domain_invalid_code_point;
}

Expand Down Expand Up @@ -262,7 +262,7 @@ inline validation_errc host_parser::parse_host(const CharT* first, const CharT*
return res;
if (detail::contains_forbidden_domain_char(buff_ascii.data(), buff_ascii.data() + buff_ascii.size())) {
// 7. If asciiDomain contains a forbidden domain code point, domain-invalid-code-point
// validation error, return failure.
// validation error, return failure.
return validation_errc::domain_invalid_code_point;
}

Expand All @@ -283,7 +283,7 @@ inline validation_errc host_parser::parse_host(const CharT* first, const CharT*
template <typename CharT>
inline validation_errc host_parser::parse_opaque_host(const CharT* first, const CharT* last, host_output& dest) {
// 1. If input contains a forbidden host code point, host-invalid-code-point
// validation error, return failure.
// validation error, return failure.
if (detail::contains_forbidden_host_char(first, last))
return validation_errc::host_invalid_code_point;

Expand Down
6 changes: 5 additions & 1 deletion src/url_ip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ void ipv4_serialize(uint32_t ipv4, std::string& output) {
// IPv6 serializer
// https://url.spec.whatwg.org/#concept-ipv6-serializer

static std::size_t longest_zero_sequence(
namespace {

std::size_t longest_zero_sequence(
const uint16_t* first, const uint16_t* last,
const uint16_t*& compress)
{
Expand All @@ -43,6 +45,8 @@ static std::size_t longest_zero_sequence(
return last_count;
}

} // namespace

void ipv6_serialize(const uint16_t(&address)[8], std::string& output) {
const uint16_t *first = std::begin(address);
const uint16_t *last = std::end(address);
Expand Down

0 comments on commit a8289d4

Please sign in to comment.