Skip to content

Make clang-tidy rules more strict #156

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

Merged
merged 3 commits into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 18 additions & 37 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,50 +1,31 @@
Checks: >
bugprone-*,
clang-diagnostic-*,
llvm-include-order,
llvm-namespace-comment,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-bugprone-casting-through-void,
-bugprone-exception-escape,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-narrowing-conversions,
-clang-analyzer-optin.cplusplus.UninitializedObject,
-misc-const-correctness,
-misc-include-cleaner,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-misc-unused-parameters,
-misc-use-anonymous-namespace,
-modernize-avoid-c-arrays,
-modernize-concat-nested-namespaces,
-modernize-pass-by-value,
-modernize-return-braced-init-list,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-magic-numbers,
-readability-named-parameter,
-readability-redundant-declaration,
bugprone-assignment-in-if-condition,
bugprone-forward-declaration-namespace,
bugprone-infinite-loop,
bugprone-integer-division,
bugprone-macro-parentheses,
bugprone-macro-repeated-side-effects,
bugprone-move-forwarding-reference,
bugprone-redundant-branch-condition,
bugprone-reserved-identifier,
bugprone-suspicious-include,
bugprone-suspicious-semicolon,
bugprone-terminating-continue,
bugprone-throw-keyword-missing,
bugprone-unused-raii,
bugprone-unused-return-value,
clang-diagnostic-*,
llvm-include-order,
llvm-namespace-comment,
misc-confusable-identifiers,
misc-definitions-in-headers,
misc-header-include-cycle,
misc-include-cleaner,
misc-misplaced-const,
misc-non-copyable-objects,
misc-redundant-expression,
misc-static-assert,
misc-throw-by-value-catch-by-reference,
misc-unconventional-assign-operator,
misc-unused-alias-decls,
misc-unused-parameters,
misc-unused-using-decls,
misc-use-anonymous-namespace
-readability-named-parameter

WarningsAsErrors: "*"

10 changes: 6 additions & 4 deletions .github/workflows/static-analysis-pr.yml
Original file line number Diff line number Diff line change
@@ -21,15 +21,16 @@ jobs:
id: review
with:
build_dir: build
apt_packages: mpich,libmpich*,mpi*,openmpi-bin,ninja-build,libomp-16-dev,valgrind
apt_packages: mpich,libmpich*,mpi*,openmpi-bin,ninja-build,libomp-18-dev,valgrind
cmake_command: cmake -S . -B build -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache -D USE_FUNC_TESTS=ON -D USE_PERF_TESTS=ON -G Ninja -D USE_SEQ=ON -D USE_MPI=ON -D USE_OMP=ON -D USE_TBB=ON -D USE_STL=ON -D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
config_file: .clang-tidy
exclude: 3rdparty
split_workflow: true
clang_tidy_version: "18"
lgtm_comment_body: ""
env:
CC: clang-16
CXX: clang++-16
CC: clang-18
CXX: clang++-18
- if: steps.review.outputs.total_comments > 0
run: exit 1
clang-tidy-for-gcc-build:
@@ -46,11 +47,12 @@ jobs:
id: review
with:
build_dir: build
apt_packages: mpich,libmpich*,mpi*,openmpi-bin,ninja-build,libomp-16-dev,valgrind
apt_packages: mpich,libmpich*,mpi*,openmpi-bin,ninja-build,libomp-18-dev,valgrind
cmake_command: cmake -S . -B build -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja -D USE_FUNC_TESTS=ON -D USE_PERF_TESTS=ON -D USE_SEQ=ON -D USE_MPI=ON -D USE_OMP=ON -D USE_TBB=ON -D USE_STL=ON -D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
config_file: .clang-tidy
exclude: 3rdparty
split_workflow: true
clang_tidy_version: "18"
lgtm_comment_body: ""
- if: steps.review.outputs.total_comments > 0
run: |
6 changes: 3 additions & 3 deletions 1stsamples/mpi/main.cpp
Original file line number Diff line number Diff line change
@@ -16,9 +16,9 @@ int main(int argc, char** argv) {
MPI_Get_processor_name(processor_name, &len_chars);

MPI_Barrier(MPI_COMM_WORLD);
std::cout << "Processor = " << processor_name << std::endl;
std::cout << "Rank = " << world_rank << std::endl;
std::cout << "Number of processors = " << world_size << std::endl;
std::cout << "Processor = " << processor_name << '\n';
std::cout << "Rank = " << world_rank << '\n';
std::cout << "Number of processors = " << world_size << '\n';

MPI_Finalize();
return 0;
6 changes: 3 additions & 3 deletions 1stsamples/mpi_boost/main.cpp
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@ int main(int argc, char** argv) {
boost::mpi::communicator world;

world.barrier();
std::cout << "Processor = " << boost::mpi::environment::processor_name() << std::endl;
std::cout << "Rank = " << world.rank() << std::endl;
std::cout << "Number of processors = " << world.size() << std::endl;
std::cout << "Processor = " << boost::mpi::environment::processor_name() << '\n';
std::cout << "Rank = " << world.rank() << '\n';
std::cout << "Number of processors = " << world.size() << '\n';

return 0;
}
4 changes: 2 additions & 2 deletions 1stsamples/omp/main.cpp
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@
int main() {
#pragma omp parallel
{
std::cout << "Thread number = " << omp_get_thread_num() << std::endl;
std::cout << "Number of threads = " << omp_get_num_threads() << std::endl;
std::cout << "Thread number = " << omp_get_thread_num() << '\n';
std::cout << "Number of threads = " << omp_get_num_threads() << '\n';
}
return 0;
}
6 changes: 3 additions & 3 deletions 1stsamples/stl/main.cpp
Original file line number Diff line number Diff line change
@@ -3,15 +3,15 @@
#include <thread>
#include <vector>

void task(const std::string& msg) { std::cout << "thread number: " + msg << std::endl; }
static void Task(const std::string& msg) { std::cout << "thread number: " + msg << '\n'; }

int main() {
const auto num_max_threads = std::thread::hardware_concurrency();
std::cout << "Number of threads = " << num_max_threads << std::endl;
std::cout << "Number of threads = " << num_max_threads << '\n';
std::vector<std::thread> thr(num_max_threads);

for (unsigned int i = 0; i < num_max_threads; ++i) {
thr[i] = std::thread(task, std::to_string(i));
thr[i] = std::thread(Task, std::to_string(i));
}

for (unsigned int i = 0; i < num_max_threads; ++i) {
8 changes: 4 additions & 4 deletions 1stsamples/tbb/main.cpp
Original file line number Diff line number Diff line change
@@ -2,17 +2,17 @@

#include <iostream>

int fib_func(int n) {
static int FibFunc(int n) {
if (n < 2) {
return n;
}
int x;
int y;
oneapi::tbb::task_group g;
g.run([&] { x = fib_func(n - 1); });
g.run([&] { y = fib_func(n - 2); });
g.run([&] { x = FibFunc(n - 1); });
g.run([&] { y = FibFunc(n - 2); });
g.wait();
return x + y;
}

int main() { return fib_func(10) - 55; }
int main() { return FibFunc(10) - 55; }
Loading