Skip to content

Commit d904f1d

Browse files
committed
Fix first set of clang-tidy warnings
1 parent a7ceaf4 commit d904f1d

19 files changed

Lines changed: 64 additions & 65 deletions

File tree

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Checks: >
55
bugprone-*,
66
-bugprone-exception-escape,
77
-bugprone-easily-swappable-parameters,
8+
-bugprone-branch-clone,
89
clang-diagnostic-*,
910
clang-analyzer-*,
1011
concurrency-*,
@@ -17,6 +18,7 @@ Checks: >
1718
-cppcoreguidelines-avoid-c-arrays,
1819
-cppcoreguidelines-avoid-do-while,
1920
-cppcoreguidelines-pro-type-reinterpret-cast,
21+
-cppcoreguidelines-missing-std-forward,
2022
misc-*,
2123
-misc-unused-parameters,
2224
-misc-non-private-member-variables-in-classes,

.github/workflows/clang-tidy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: Run clang-tidy on source files
5555
if: false # Disabled for now
5656
run: |
57-
find tests -name '*.cpp' -print0 | \
57+
find examples -name '*.cpp' -print0 | \
5858
xargs -0 -n1 -P$(nproc) clang-tidy-21 -p build
5959
6060
- name: clang-tidy check passed

include/skyr/core/check_input.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ constexpr static auto is_c0_control_or_space = [](auto byte) {
1616
return std::iscntrl(byte, std::locale::classic()) || std::isspace(byte, std::locale::classic());
1717
};
1818

19-
constexpr inline auto remove_leading_c0_control_or_space(std::string_view input, bool* validation_error) {
19+
constexpr auto remove_leading_c0_control_or_space(std::string_view input, bool* validation_error) {
2020
auto first = std::cbegin(input), last = std::cend(input);
2121
auto it = std::find_if_not(first, last, is_c0_control_or_space);
2222
*validation_error |= (it != first);
2323
input.remove_prefix(std::distance(first, it));
2424
return input;
2525
}
2626

27-
constexpr inline auto remove_trailing_c0_control_or_space(std::string_view input, bool* validation_error) {
27+
constexpr auto remove_trailing_c0_control_or_space(std::string_view input, bool* validation_error) {
2828
auto first = std::crbegin(input), last = std::crend(input);
2929
auto it = std::find_if_not(first, last, is_c0_control_or_space);
3030
*validation_error |= (it != first);

include/skyr/core/schemes.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
namespace skyr {
1414
/// \param scheme
1515
/// \returns
16-
constexpr inline auto is_special(std::string_view scheme) noexcept -> bool {
16+
constexpr auto is_special(std::string_view scheme) noexcept -> bool {
1717
return (scheme == "file") || (scheme == "ftp") || (scheme == "http") || (scheme == "https") || (scheme == "ws") ||
1818
(scheme == "wss");
1919
}
2020

2121
/// \param scheme
2222
/// \returns
23-
constexpr inline auto default_port(std::string_view scheme) noexcept -> std::optional<std::uint16_t> {
23+
constexpr auto default_port(std::string_view scheme) noexcept -> std::optional<std::uint16_t> {
2424
if (scheme == "ftp") {
2525
return 21;
2626
} else if ((scheme == "http") || (scheme == "ws")) {

include/skyr/core/url_parser_context.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ using namespace std::string_literals;
2828
using namespace std::string_view_literals;
2929

3030
namespace details {
31-
constexpr inline auto contains(std::string_view view, char element) noexcept {
31+
constexpr auto contains(std::string_view view, char element) noexcept {
3232
auto first = std::cbegin(view), last = std::cend(view);
3333
return last != std::find(first, last, element);
3434
}
@@ -56,7 +56,7 @@ inline auto is_url_code_point(char byte) noexcept {
5656
return std::isalnum(byte, std::locale::classic()) || contains("!$&'()*+,-./:;=?@_~"sv, byte);
5757
}
5858

59-
constexpr inline auto is_windows_drive_letter(std::string_view segment) noexcept {
59+
constexpr auto is_windows_drive_letter(std::string_view segment) noexcept {
6060
if (segment.size() < 2) {
6161
return false;
6262
}
@@ -74,11 +74,11 @@ constexpr inline auto is_windows_drive_letter(std::string_view segment) noexcept
7474
return result;
7575
}
7676

77-
constexpr inline auto is_single_dot_path_segment(std::string_view segment) noexcept {
77+
constexpr auto is_single_dot_path_segment(std::string_view segment) noexcept {
7878
return (segment == ".") || (segment == "%2e") || (segment == "%2E");
7979
}
8080

81-
constexpr inline auto is_double_dot_path_segment(std::string_view segment) noexcept {
81+
constexpr auto is_double_dot_path_segment(std::string_view segment) noexcept {
8282
return (segment == "..") || (segment == "%2e.") || (segment == ".%2e") || (segment == "%2e%2e") ||
8383
(segment == "%2E.") || (segment == ".%2E") || (segment == "%2E%2E") || (segment == "%2E%2e") ||
8484
(segment == "%2e%2E");

include/skyr/domain/domain.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
#include <skyr/unicode/ranges/views/u8_view.hpp>
2222

2323
namespace skyr {
24-
constexpr inline auto validate_label(std::u32string_view label, [[maybe_unused]] bool use_std3_ascii_rules,
25-
bool check_hyphens, [[maybe_unused]] bool check_bidi,
26-
[[maybe_unused]] bool check_joiners, bool transitional_processing)
27-
-> std::expected<void, domain_errc> {
24+
constexpr auto validate_label(std::u32string_view label, [[maybe_unused]] bool use_std3_ascii_rules, bool check_hyphens,
25+
[[maybe_unused]] bool check_bidi, [[maybe_unused]] bool check_joiners,
26+
bool transitional_processing) -> std::expected<void, domain_errc> {
2827
/// https://www.unicode.org/reports/tr46/#Validity_Criteria;
2928

3029
if (check_hyphens) {

include/skyr/domain/punycode.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ constexpr auto initial_n = 0x80ul;
3030
constexpr auto delimiter = 0x2dul;
3131
} // namespace constants
3232

33-
constexpr inline auto adapt(uint32_t delta, uint32_t numpoints, bool firsttime) -> std::uint32_t {
33+
constexpr auto adapt(uint32_t delta, uint32_t numpoints, bool firsttime) -> std::uint32_t {
3434
using namespace constants;
3535

3636
delta = firsttime ? delta / damp : delta >> 1ul;
@@ -154,7 +154,7 @@ inline auto punycode_encode(std::u32string_view input, std::string* output) -> s
154154
/// \param output The output UTF-32 string to store the decoded result
155155
/// \returns The decoded UTF-8 domain, or an error
156156
template <class StringView>
157-
constexpr inline auto punycode_decode(StringView input, std::u32string* output) -> std::expected<void, domain_errc> {
157+
constexpr auto punycode_decode(StringView input, std::u32string* output) -> std::expected<void, domain_errc> {
158158
using namespace punycode::constants;
159159

160160
// decode_digit(cp) returns the numeric value of a basic code

include/skyr/network/ipv4_address.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ class ipv4_address {
8181

8282
namespace details {
8383
/// Computes 256^exp efficiently using bit shifts (256 = 2^8, so 256^n = 2^(8n))
84-
constexpr inline auto pow256(unsigned int exp) noexcept -> std::uint64_t {
84+
constexpr auto pow256(unsigned int exp) noexcept -> std::uint64_t {
8585
return 1ULL << (exp * 8);
8686
}
8787

88-
constexpr inline auto parse_ipv4_number(std::string_view input, bool* validation_error)
88+
constexpr auto parse_ipv4_number(std::string_view input, bool* validation_error)
8989
-> std::expected<std::uint64_t, ipv4_address_errc> {
9090
auto base = 10;
9191

@@ -116,7 +116,7 @@ constexpr inline auto parse_ipv4_number(std::string_view input, bool* validation
116116
/// \param input An input string
117117
/// \param validation_error Optional pointer to a bool that will be set if a validation error occurs
118118
/// \returns An `ipv4_address` object or an error
119-
constexpr inline auto parse_ipv4_address(std::string_view input, bool* validation_error)
119+
constexpr auto parse_ipv4_address(std::string_view input, bool* validation_error)
120120
-> std::expected<ipv4_address, ipv4_address_errc> {
121121
using namespace std::string_view_literals;
122122

include/skyr/network/ipv6_address.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class ipv6_address {
145145

146146
namespace details {
147147
template <class intT, class charT>
148-
constexpr inline auto hex_to_dec(charT byte) noexcept {
148+
constexpr auto hex_to_dec(charT byte) noexcept {
149149
assert(std::isxdigit(byte, std::locale::classic()));
150150

151151
if (std::isdigit(byte, std::locale::classic())) {
@@ -160,7 +160,7 @@ constexpr inline auto hex_to_dec(charT byte) noexcept {
160160
/// \param input An input string
161161
/// \param validation_error Optional pointer to a bool that will be set if a validation error occurs
162162
/// \returns An `ipv6_address` object or an error
163-
constexpr inline auto parse_ipv6_address(std::string_view input, bool* validation_error)
163+
constexpr auto parse_ipv6_address(std::string_view input, bool* validation_error)
164164
-> std::expected<ipv6_address, ipv6_address_errc> {
165165
using namespace std::string_view_literals;
166166

include/skyr/percent_encoding/percent_decode_range.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
namespace skyr {
1818
namespace percent_encoding {
1919
namespace details {
20-
constexpr inline auto alnum_to_hex(char value) noexcept -> std::expected<std::byte, percent_encode_errc> {
20+
constexpr auto alnum_to_hex(char value) noexcept -> std::expected<std::byte, percent_encode_errc> {
2121
if ((value >= '0') && (value <= '9')) {
2222
return static_cast<std::byte>(value - '0');
2323
}

0 commit comments

Comments
 (0)