From cb1f607054e78f21a3544c6439a80f3fb5038627 Mon Sep 17 00:00:00 2001 From: Timo Koch <timokoch@math.uio.no> Date: Wed, 29 Mar 2023 12:00:15 +0200 Subject: [PATCH] [ci][cppcheck] Make sure cppcheck honors dumux includes --- .gitlab-ci/default.yml | 8 ++-- dumux/common/tag.hh | 1 + .../structuredlatticegridcreator.hh | 2 +- dumux/material/fluidsystems/h2oair.hh | 3 +- dumux/material/fluidsystems/h2on2kinetic.hh | 46 ++++++++----------- 5 files changed, 28 insertions(+), 32 deletions(-) diff --git a/.gitlab-ci/default.yml b/.gitlab-ci/default.yml index 3e8fcf3ecb..db781662b3 100644 --- a/.gitlab-ci/default.yml +++ b/.gitlab-ci/default.yml @@ -51,6 +51,7 @@ black (python): stage: linting script: # only check the python folder for now (Python code related to bindings) + - black --version - black --check --verbose -- python - black --check --verbose -- test/python - black --check --verbose -- bin @@ -92,9 +93,10 @@ codespell: cppcheck: stage: linting script: - - cppcheck -j8 --error-exitcode=1 --inline-suppr -idumux/io/format/fmt/ --enable=missingInclude --project=build-cmake/compile_commands.json --suppress=*:*/dune/* --suppress=*:dumux/io/format/fmt/* - - cppcheck -j8 --error-exitcode=1 --inline-suppr -idumux/io/format/fmt/ --suppress=*:*/dune/* --suppress=*:dumux/io/format/fmt/* test - - cppcheck -j8 --error-exitcode=1 --inline-suppr -idumux/io/format/fmt/ --suppress=*:*/dune/* --suppress=*:dumux/io/format/fmt/* examples + - cppcheck --version + - cppcheck -j8 --error-exitcode=1 --inline-suppr -iformat/fmt/ --enable=missingInclude --project=build-cmake/compile_commands.json --suppress=*:*/dune/* --suppress=*:*/fmt/* --suppress=*:*/xml/* --suppress=*:*/json/* + - cppcheck -j8 --error-exitcode=1 --max-configs=1 --inline-suppr -iformat/fmt/ -I ${CI_PROJECT_DIR} --suppress=*:*/dune/* --suppress=*:*/fmt/* --suppress=*:*/xml/* --suppress=*:*/json/* test + - cppcheck -j8 --error-exitcode=1 --max-configs=1 --inline-suppr -iformat/fmt/ -I ${CI_PROJECT_DIR} --suppress=*:*/dune/* --suppress=*:*/fmt/* --suppress=*:*/xml/* --suppress=*:*/json/* examples needs: - job: configure artifacts: true diff --git a/dumux/common/tag.hh b/dumux/common/tag.hh index d95428a79f..776631a264 100644 --- a/dumux/common/tag.hh +++ b/dumux/common/tag.hh @@ -51,6 +51,7 @@ inline constexpr bool operator!=(Tag<T1>, Tag<T2>) { return !std::is_same_v<T1, T2>; } namespace Detail { +// cppcheck-suppress internalAstError constexpr auto hasName = isValid([](auto&& t) -> decltype(t.name(), void()) {}); } // end namespace Detail diff --git a/dumux/io/grid/porenetwork/structuredlatticegridcreator.hh b/dumux/io/grid/porenetwork/structuredlatticegridcreator.hh index d4aef9f377..e528ca4df9 100644 --- a/dumux/io/grid/porenetwork/structuredlatticegridcreator.hh +++ b/dumux/io/grid/porenetwork/structuredlatticegridcreator.hh @@ -95,7 +95,7 @@ public: init(useAllElements, paramGroup); } - template<class LowDimElementSelector, + template<class LowDimElementSelector, // cppcheck-suppress syntaxError typename std::enable_if_t<Dune::models<Concept::LowDimElementSelector<GlobalPosition>, LowDimElementSelector>(), int> = 0> void init(const LowDimElementSelector& lowDimElementSelector, const std::string& paramGroup = "") diff --git a/dumux/material/fluidsystems/h2oair.hh b/dumux/material/fluidsystems/h2oair.hh index baebf0bb47..2d5eb44952 100644 --- a/dumux/material/fluidsystems/h2oair.hh +++ b/dumux/material/fluidsystems/h2oair.hh @@ -281,7 +281,8 @@ public: if (compIdx == H2OIdx) { const auto t = fluidState.temperature(H2OIdx); - if (!useKelvinVaporPressure) + // cppcheck-suppress internalAstError + if constexpr (!useKelvinVaporPressure) return H2O::vaporPressure(t); else { diff --git a/dumux/material/fluidsystems/h2on2kinetic.hh b/dumux/material/fluidsystems/h2on2kinetic.hh index bf1070f7fe..7133a06857 100644 --- a/dumux/material/fluidsystems/h2on2kinetic.hh +++ b/dumux/material/fluidsystems/h2on2kinetic.hh @@ -69,36 +69,28 @@ public: const Scalar T = fluidState.temperature(phaseIdx); const Scalar p = fluidState.pressure(phaseIdx); - switch (phaseIdx){ + switch (phaseIdx) { case ParentType::liquidPhaseIdx: - switch(compIdx){ - case ParentType::H2OIdx: - return ParentType::H2O::liquidEnthalpy(T, p); - case ParentType::N2Idx: - return ParentType::N2::gasEnthalpy(T, p); // TODO: should be liquid enthalpy - default: - DUNE_THROW(Dune::NotImplemented, - "wrong index"); - break; - }// end switch compIdx - break; + switch(compIdx) { + case ParentType::H2OIdx: + return ParentType::H2O::liquidEnthalpy(T, p); + case ParentType::N2Idx: + return ParentType::N2::gasEnthalpy(T, p); // TODO: should be liquid enthalpy + default: + DUNE_THROW(Dune::NotImplemented, "wrong index"); + } case ParentType::gasPhaseIdx: - switch(compIdx){ - case ParentType::H2OIdx: - return ParentType::H2O::gasEnthalpy(T, p); - case ParentType::N2Idx: - return ParentType::N2::gasEnthalpy(T, p); - default: - DUNE_THROW(Dune::NotImplemented, - "wrong index"); - break; - }// end switch compIdx - break; + switch(compIdx) { + case ParentType::H2OIdx: + return ParentType::H2O::gasEnthalpy(T, p); + case ParentType::N2Idx: + return ParentType::N2::gasEnthalpy(T, p); + default: + DUNE_THROW(Dune::NotImplemented, "wrong index"); + } default: - DUNE_THROW(Dune::NotImplemented, - "wrong index"); - break; - }// end switch phaseIdx + DUNE_THROW(Dune::NotImplemented, "wrong index"); + } } /*! -- GitLab