Skip to content

Commit 4f88990

Browse files
authored
Fixed Issues from clang-tidy (#13)
* Fixed static analysis checks in the CI * Ignoring trailing return type warning * Fixed multi-line CI * Ignoring the "fuchsia-overloaded-operator" * Header guard follows the llvm style * Added [[maybe_unused]] for the main * Ignoring pointer arithmetic warning in a specific case * Remove EOL * Removed EOL
1 parent ee953f4 commit 4f88990

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ jobs:
1414
- uses: actions/checkout@v3
1515

1616
- name: g++
17-
run: g++ --version && g++ main.cpp -I include -std=c++17 -O2 -Wall -Wextra -pedantic -Wshadow -Werror
17+
run: |
18+
g++ --version && \
19+
g++ main.cpp -I include -std=c++17 -O2 -Wall -Wextra -pedantic -Wshadow -Werror
1820
1921
- name: clang++
20-
run: clang++ --version && clang++ main.cpp -I include -std=c++17 -O2 -Wall -Wextra -pedantic -Wshadow -Werror
22+
run: |
23+
clang++ --version && \
24+
clang++ main.cpp -I include -std=c++17 -O2 -Wall -Wextra -pedantic -Wshadow -Werror
2125
2226
static_analysis:
2327
runs-on: ubuntu-latest
@@ -26,7 +30,9 @@ jobs:
2630
- uses: actions/checkout@v3
2731

2832
- name: clang-tidy
29-
run: clang-tidy --version && clang-tidy -warnings-as-errors -checks="*" main.cpp -- -I include -std=c++17
33+
run: |
34+
clang-tidy --version && \
35+
clang-tidy include/constexpr_hash_map/constexpr_hash_map.hpp main.cpp --checks="*,-llvmlibc-*,-modernize-use-trailing-return-type" --warnings-as-errors="*" -- -I include -std=c++17
3036
3137
documentation:
3238
runs-on: ubuntu-latest

include/constexpr_hash_map/constexpr_hash_map.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef BURDA_CONSTEXPR_HASH_MAP_HPP
2-
#define BURDA_CONSTEXPR_HASH_MAP_HPP
1+
#ifndef CONSTEXPR_HASH_MAP_CONSTEXPR_HASH_MAP_HPP
2+
#define CONSTEXPR_HASH_MAP_CONSTEXPR_HASH_MAP_HPP
33

44
#include <array>
55
#include <cstddef>
@@ -71,6 +71,7 @@ class hash_map
7171
/// Doesn't perform any bounds checking, behaviour is undefined if the key doesn't exist
7272
/// @param key key to be searched for
7373
/// @return reference to constant to a value associated with the key
74+
// NOLINTNEXTLINE(fuchsia-overloaded-operator)
7475
[[nodiscard]] constexpr const V& operator[](const K& key) const noexcept
7576
{
7677
return find(key)->second;
@@ -162,6 +163,7 @@ class hash_map
162163
/// @private specific implementation for "const char*" equality is needed; uses recursion
163164
[[nodiscard]] constexpr bool equal(const char* lhs, const char* rhs) const noexcept
164165
{
166+
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
165167
return *lhs == *rhs && (*lhs == '\0' || equal(lhs + 1, rhs + 1));
166168
}
167169

@@ -170,4 +172,4 @@ class hash_map
170172
};
171173
} // namespace burda::ct
172174

173-
#endif // BURDA_CONSTEXPR_HASH_MAP_HPP
175+
#endif // CONSTEXPR_HASH_MAP_CONSTEXPR_HASH_MAP_HPP

main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int example_advanced() noexcept
4949
return it->second.size();
5050
}
5151

52-
int main(const int, const char**)
52+
int main([[maybe_unused]] const int argc, [[maybe_unused]] const char** argv)
5353
{
5454
return example_simple() + example_advanced();
55-
}
55+
}

0 commit comments

Comments
 (0)