Skip to content

Commit

Permalink
Add linters (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuki-cpp authored Dec 23, 2023
1 parent b9c0bf0 commit 8a2e15d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
5 changes: 3 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Checks: '-*,
WarningsAsErrors: '-*,
bugprone-*,
performance-*,
misc-*,
-misc-include-cleaner,
cppcoreguidelines-avoid-non-const-global-variables,
cppcoreguidelines-avoid-goto,
readability-qualified-auto,
Expand All @@ -27,4 +28,4 @@ CheckOptions:
- { key: performance-unnecessary-value-param.AllowedTypes, value: '[Rr]ef(erence)?$;Ptr$;ptr$'}
- { key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 1}



29 changes: 29 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,32 @@ jobs:
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3

LintCheck:
runs-on: ubuntu-22.04
container:
image: ghcr.io/cpp-playground/containers
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
env:
CC: /usr/bin/clang-17
CXX: /usr/bin/clang++-17

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure
run: |
cmake -S . -B build
cp build/compile_commands.json .
- name: Check formatting
run: |
find . \( -name \*.h -o -name \*.hh -o -name \*.hpp -o -name \*.cpp -o -name \*.cc \) -not -path "./build/*" -exec clang-format-17 -style=file -i --dry-run -Werror {} +
- name: Check clang tidy
run: |
find . \( -name \*.h -o -name \*.hh -o -name \*.hpp -o -name \*.cpp -o -name \*.cc \) -not -path "./build/*" -exec clang-tidy-17 {} +
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ include(FetchContent)
FetchContent_Declare(Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG v3.4.0)
FetchContent_MakeAvailable(Catch2)

# Marks Catch2 headers as system so they won't fail when using clang-tidy
get_target_property(CATCH2_IID Catch2 INTERFACE_INCLUDE_DIRECTORIES)
set_target_properties(Catch2 PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${CATCH2_IID}")

add_executable(typelist_utils test/main.cpp test/test_utils.cpp test/test_sort.cpp)
target_include_directories(typelist_utils PRIVATE include)
target_link_libraries(typelist_utils PRIVATE Catch2::Catch2WithMain)
Expand Down
24 changes: 12 additions & 12 deletions include/typelist_utils/traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ concept tuple = tl::traits::is_tuple_v<T>;
*/
template <template <typename, typename> typename P, typename T, typename U>
concept binary_value_predicate = requires {
{
P<T, U>::value
} -> same_as<const bool&>;
};
{
P<T, U>::value
} -> same_as<const bool&>;
};

/**
* @brief Concept checking that a given type can be used as a unary value predicate for
Expand All @@ -85,10 +85,10 @@ concept binary_value_predicate = requires {
*/
template <template <typename> typename P, typename T>
concept unary_value_predicate = requires {
{
P<T>::value
} -> same_as<const bool&>;
};
{
P<T>::value
} -> same_as<const bool&>;
};

/**
* @brief Concept checking that a given type can be used as a binary type predicate for
Expand Down Expand Up @@ -127,9 +127,9 @@ concept unary_type_predicate = requires { typename P<T>::type; };
*/
template <typename T, std::size_t first, std::size_t second>
concept valid_swap_indices = requires {
requires tl::concepts::tuple<T>;
requires first < second;
requires second < std::tuple_size_v<T>;
};
requires tl::concepts::tuple<T>;
requires first < second;
requires second < std::tuple_size_v<T>;
};

} // namespace tl::concepts

0 comments on commit 8a2e15d

Please sign in to comment.