From bade26eccaf25c0c0b854c6b76e0588835ccc686 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Fri, 10 Jul 2020 18:25:13 -0400 Subject: [PATCH 1/7] disable rand error --- .clang-tidy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index 1412b563a..d7dc7996d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: '-*,google-*,clang-analyzer-*,cppcoreguidelines-*,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-bounds-*,openmp-*,performance-*,portability-*,modernize-*,-modernize-use-trailing-*' +Checks: '-*,google-*,clang-analyzer-*,-clang-analyzer-security.insecureAPI.rand,cppcoreguidelines-*,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-bounds-*,openmp-*,performance-*,portability-*,modernize-*,-modernize-use-trailing-*' WarningsAsErrors: '' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false From 229334cce6028ad80e30f269ef2220f508f68f54 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Fri, 10 Jul 2020 18:37:35 -0400 Subject: [PATCH 2/7] treat clang-tidy warnings as errors --- .clang-tidy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index d7dc7996d..610c6b28f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,6 +1,6 @@ --- Checks: '-*,google-*,clang-analyzer-*,-clang-analyzer-security.insecureAPI.rand,cppcoreguidelines-*,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-bounds-*,openmp-*,performance-*,portability-*,modernize-*,-modernize-use-trailing-*' -WarningsAsErrors: '' +WarningsAsErrors: '*' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false FormatStyle: '{ BasedOnStyle: Google, UseTab: Never, IndentWidth: 4, TabWidth: 4, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: true, ColumnLimit: 80, AccessModifierOffset: -3, AlignConsecutiveMacros: true }' From 389d50ea1421b6a15dd0b47476a2bd5dfb392425 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Fri, 10 Jul 2020 19:05:42 -0400 Subject: [PATCH 3/7] disable all insecureAPI errors --- .clang-tidy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index 610c6b28f..95431d6da 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: '-*,google-*,clang-analyzer-*,-clang-analyzer-security.insecureAPI.rand,cppcoreguidelines-*,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-bounds-*,openmp-*,performance-*,portability-*,modernize-*,-modernize-use-trailing-*' +Checks: '-*,google-*,clang-analyzer-*,-clang-analyzer-security.insecureAPI.*,cppcoreguidelines-*,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-bounds-*,openmp-*,performance-*,portability-*,modernize-*,-modernize-use-trailing-*' WarningsAsErrors: '*' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false From 9a5a62cf127444de0372d275f7c8810501784b65 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Fri, 10 Jul 2020 21:47:39 -0400 Subject: [PATCH 4/7] pass multiple files --- .github/workflows/awesome_workflow.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/awesome_workflow.yml b/.github/workflows/awesome_workflow.yml index 2e0792e17..97f705877 100644 --- a/.github/workflows/awesome_workflow.yml +++ b/.github/workflows/awesome_workflow.yml @@ -122,9 +122,11 @@ jobs: if not cpp_files: sys.exit(0) - for cpp_file in cpp_files: - subprocess.run(["clang-tidy-10", "--fix", "-p=build", cpp_file, "--"], + subprocess.run(["clang-tidy-10", "--fix", "-p=build", *cpp_files, "--"], check=True, text=True, stderr=subprocess.STDOUT) + # for cpp_file in cpp_files: + # subprocess.run(["clang-tidy-10", "--fix", "-p=build", cpp_file, "--"], + # check=True, text=True, stderr=subprocess.STDOUT) # print("g++:") # compile_exts = tuple(".c .c++ .cc .cpp .cu .cxx".split()) From 523475b18367d573ae21bd8ae8b45ce8fb565e6b Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Fri, 10 Jul 2020 21:58:22 -0400 Subject: [PATCH 5/7] mark all warnings as errors except those that are fixable by clang-tidy --- .clang-tidy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index 95431d6da..272502837 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,6 +1,6 @@ --- Checks: '-*,google-*,clang-analyzer-*,-clang-analyzer-security.insecureAPI.*,cppcoreguidelines-*,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-bounds-*,openmp-*,performance-*,portability-*,modernize-*,-modernize-use-trailing-*' -WarningsAsErrors: '*' +WarningsAsErrors: '*,-google-readability-*,-google-explicit-constructor,-modernize-*,modernize-avoid-c-arrays,-google-explicit-constructor,-performance-move-const-arg,-performance-noexcept-move-constructor,-cppcoreguidelines-init-variables,-cppcoreguidelines-pro-*' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false FormatStyle: '{ BasedOnStyle: Google, UseTab: Never, IndentWidth: 4, TabWidth: 4, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: true, ColumnLimit: 80, AccessModifierOffset: -3, AlignConsecutiveMacros: true }' From dc6f32297567a9888eeb8ed24d26ded0ce5d1f43 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Fri, 10 Jul 2020 22:00:57 -0400 Subject: [PATCH 6/7] test commit --- numerical_methods/brent_method_extrema.cpp | 5 ++--- numerical_methods/durand_kerner_roots.cpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/numerical_methods/brent_method_extrema.cpp b/numerical_methods/brent_method_extrema.cpp index 654a69451..399be5b38 100644 --- a/numerical_methods/brent_method_extrema.cpp +++ b/numerical_methods/brent_method_extrema.cpp @@ -180,14 +180,13 @@ void test2() { } /** - * @brief Test function to find *maxima* for the function + * @brief Test function to find *minima* for the function * \f$f(x)= \cos x\f$ * in the interval \f$[0,12]\f$ * \n Expected result: \f$\pi\approx 3.14159265358979312\f$ */ void test3() { - // define the function to maximize as a lambda function - // since we are maximixing, we negated the function return value + // define the function to minimize as a lambda function std::function func = [](double x) { return std::cos(x); }; std::cout << "Test 3.... "; diff --git a/numerical_methods/durand_kerner_roots.cpp b/numerical_methods/durand_kerner_roots.cpp index 9bf0619b8..23419d1ed 100644 --- a/numerical_methods/durand_kerner_roots.cpp +++ b/numerical_methods/durand_kerner_roots.cpp @@ -212,7 +212,7 @@ void test1() { std::complex(0., -2.) // known expected roots }; - /* initialize root approximations with random values */ + /* Initialize root approximations with random values */ for (int n = 0; n < roots.size(); n++) { roots[n] = std::complex(std::rand() % 100, std::rand() % 100); roots[n] -= 50.f; From 2ca13dd45a5a99e6677149ad4020c03e0e63d646 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Fri, 10 Jul 2020 22:16:14 -0400 Subject: [PATCH 7/7] Revert "test commit" This reverts commit dc6f32297567a9888eeb8ed24d26ded0ce5d1f43. --- numerical_methods/brent_method_extrema.cpp | 5 +++-- numerical_methods/durand_kerner_roots.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/numerical_methods/brent_method_extrema.cpp b/numerical_methods/brent_method_extrema.cpp index 399be5b38..654a69451 100644 --- a/numerical_methods/brent_method_extrema.cpp +++ b/numerical_methods/brent_method_extrema.cpp @@ -180,13 +180,14 @@ void test2() { } /** - * @brief Test function to find *minima* for the function + * @brief Test function to find *maxima* for the function * \f$f(x)= \cos x\f$ * in the interval \f$[0,12]\f$ * \n Expected result: \f$\pi\approx 3.14159265358979312\f$ */ void test3() { - // define the function to minimize as a lambda function + // define the function to maximize as a lambda function + // since we are maximixing, we negated the function return value std::function func = [](double x) { return std::cos(x); }; std::cout << "Test 3.... "; diff --git a/numerical_methods/durand_kerner_roots.cpp b/numerical_methods/durand_kerner_roots.cpp index 23419d1ed..9bf0619b8 100644 --- a/numerical_methods/durand_kerner_roots.cpp +++ b/numerical_methods/durand_kerner_roots.cpp @@ -212,7 +212,7 @@ void test1() { std::complex(0., -2.) // known expected roots }; - /* Initialize root approximations with random values */ + /* initialize root approximations with random values */ for (int n = 0; n < roots.size(); n++) { roots[n] = std::complex(std::rand() % 100, std::rand() % 100); roots[n] -= 50.f;