From 39915c61b9399bfa507fd9151c1375e499649903 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Wed, 4 Sep 2024 12:08:27 -0400 Subject: [PATCH] Remove cppcheck. clang-tidy performs as many checks and issues fewer false errors. --- .github/workflows/env-files/environment.yaml | 1 - .../workflows/env-files/py310-conda-lock.yml | 58 +------------------ .../workflows/env-files/py311-conda-lock.yml | 58 +------------------ .../workflows/env-files/py312-conda-lock.yml | 58 +------------------ .../workflows/env-files/py39-conda-lock.yml | 58 +------------------ .github/workflows/style_check.yml | 2 - .pre-commit-config.yaml | 24 -------- doc/source/reference/development/howtoadd.rst | 2 +- freud/locality/AABBTree.h | 13 ----- freud/order/Cubatic.cc | 3 - freud/util/ManagedArray.h | 6 -- freud/util/VectorMath.h | 2 - 12 files changed, 5 insertions(+), 280 deletions(-) diff --git a/.github/workflows/env-files/environment.yaml b/.github/workflows/env-files/environment.yaml index 193956c41..ac410db0b 100644 --- a/.github/workflows/env-files/environment.yaml +++ b/.github/workflows/env-files/environment.yaml @@ -4,7 +4,6 @@ channels: dependencies: - python==3.12 - - cppcheck # [linux64] - tbb - tbb-devel - ninja diff --git a/.github/workflows/env-files/py310-conda-lock.yml b/.github/workflows/env-files/py310-conda-lock.yml index 93432226a..b35eaf7fc 100644 --- a/.github/workflows/env-files/py310-conda-lock.yml +++ b/.github/workflows/env-files/py310-conda-lock.yml @@ -15,7 +15,7 @@ metadata: content_hash: osx-arm64: 520f0b64f9ee8b2d1f1d9f2284b6001e8f67f663bf3e08ae9ee97643cc2005c0 osx-64: fae85ff1d3543b89e4f999b1cbbb334c2dcc75042edeb971bad8c6a31c0570e5 - linux-64: 2347cf4e58ed59f84189c3e411de02a7ec9c4108523217c311ac152a9fe846c0 + linux-64: 9e5c60c34d8e970c4dc47b869957c7705139e1a65f3481450c85a355a807f1f4 win-64: 4e5dc225183a7a97c1bb091c7b6106ee9344e5c212babf7662ffdff5ba594962 channels: - url: conda-forge @@ -939,24 +939,6 @@ package: sha256: c3d62e81c96b2e5bc7a8fc0c50bbbff629fea525c450d10766b179f9efe50803 category: main optional: false -- name: cppcheck - version: 2.14.2 - manager: conda - platform: linux-64 - dependencies: - libgcc-ng: '>=12' - libstdcxx-ng: '>=12' - pcre: '>=8.45,<9.0a0' - pygments: '' - python: '>=3.10,<3.11.0a0' - python_abi: 3.10.* - tinyxml2: '>=10.0.0,<11.0a0' - url: https://conda.anaconda.org/conda-forge/linux-64/cppcheck-2.14.2-py310h5d8bd85_0.conda - hash: - md5: f01004c5d6a00feca1871414444b10f6 - sha256: 77a6060241de081ffc5398286a1d3c2fa95438c854e48baf248e4aaecb62fc19 - category: main - optional: false - name: cycler version: 0.12.1 manager: conda @@ -5957,19 +5939,6 @@ package: sha256: 35ad5cab1d9c08cf98576044bf28f75e62f8492afe6d1a89c94bbe93dc8d7258 category: main optional: false -- name: pcre - version: '8.45' - manager: conda - platform: linux-64 - dependencies: - libgcc-ng: '>=9.3.0' - libstdcxx-ng: '>=9.3.0' - url: https://conda.anaconda.org/conda-forge/linux-64/pcre-8.45-h9c3ff4c_0.tar.bz2 - hash: - md5: c05d1820a6d34ff07aaaab7a9b7eddaa - sha256: 8f35c244b1631a4f31fb1d66ab6e1d9bfac0ca9b679deced1112c7225b3ad138 - category: main - optional: false - name: pcre2 version: '10.44' manager: conda @@ -6435,18 +6404,6 @@ package: sha256: 88429d3c889604dc4be9133a82a3e9857e34f76fa2d28f91fadfeb8f030ff09e category: main optional: false -- name: pygments - version: 2.18.0 - manager: conda - platform: linux-64 - dependencies: - python: '>=3.8' - url: https://conda.anaconda.org/conda-forge/noarch/pygments-2.18.0-pyhd8ed1ab_0.conda - hash: - md5: b7f5c092b8f9800150d998a71b76d5a1 - sha256: 78267adf4e76d0d64ea2ffab008c501156c108bb08fecb703816fb63e279780b - category: main - optional: false - name: pyparsing version: 3.1.4 manager: conda @@ -7819,19 +7776,6 @@ package: sha256: 15dcf503b5c5968913e390405a4e05f618dc7a369c951006f802d99a2be9b27f category: main optional: false -- name: tinyxml2 - version: 10.0.0 - manager: conda - platform: linux-64 - dependencies: - libgcc-ng: '>=12' - libstdcxx-ng: '>=12' - url: https://conda.anaconda.org/conda-forge/linux-64/tinyxml2-10.0.0-h59595ed_0.conda - hash: - md5: 5e27e4a780264caed4be372ded70a9e9 - sha256: e89306d01999f629a329ddb2e2ca9b8fbfe7c483d13f9805f0c6891a24a6e9c8 - category: main - optional: false - name: tk version: 8.6.13 manager: conda diff --git a/.github/workflows/env-files/py311-conda-lock.yml b/.github/workflows/env-files/py311-conda-lock.yml index 20440021e..4584e3444 100644 --- a/.github/workflows/env-files/py311-conda-lock.yml +++ b/.github/workflows/env-files/py311-conda-lock.yml @@ -15,7 +15,7 @@ metadata: content_hash: osx-arm64: f5c19f5451988b99abcd7c1543f23acef327293c689689a9eef72104c3cc0543 osx-64: ed55bf7547f1dd3cc5063e9e2dd68c1667aca9fbc0fcce9ca3d903229318b76c - linux-64: b20f4ad3fc43ac74d3e12e36fd704f9a996c7842f743eea75ef9cfe036ecb30a + linux-64: 639fce5e8c286a8d20e8de46d22baa5898be4a9ac377d9ffc9c5cdd16e979c84 win-64: 7c18d2ee9cbb9243a48e7108118a2c7f18c8e07a9c5658b276b84fd2f61221c8 channels: - url: conda-forge @@ -963,24 +963,6 @@ package: sha256: daf43d9605cce61781196422338aec3d2c5e8c7941665c73a6c071c31345fe0e category: main optional: false -- name: cppcheck - version: 2.14.2 - manager: conda - platform: linux-64 - dependencies: - libgcc-ng: '>=12' - libstdcxx-ng: '>=12' - pcre: '>=8.45,<9.0a0' - pygments: '' - python: '>=3.11,<3.12.0a0' - python_abi: 3.11.* - tinyxml2: '>=10.0.0,<11.0a0' - url: https://conda.anaconda.org/conda-forge/linux-64/cppcheck-2.14.2-py311hdd5f75e_0.conda - hash: - md5: f43b7253f2fec6cc3805048aae3c6871 - sha256: 05dcfc29e117e752920436e349fdf3be85c00797da812fe47314ba194f23469d - category: main - optional: false - name: cycler version: 0.12.1 manager: conda @@ -6027,19 +6009,6 @@ package: sha256: 35ad5cab1d9c08cf98576044bf28f75e62f8492afe6d1a89c94bbe93dc8d7258 category: main optional: false -- name: pcre - version: '8.45' - manager: conda - platform: linux-64 - dependencies: - libgcc-ng: '>=9.3.0' - libstdcxx-ng: '>=9.3.0' - url: https://conda.anaconda.org/conda-forge/linux-64/pcre-8.45-h9c3ff4c_0.tar.bz2 - hash: - md5: c05d1820a6d34ff07aaaab7a9b7eddaa - sha256: 8f35c244b1631a4f31fb1d66ab6e1d9bfac0ca9b679deced1112c7225b3ad138 - category: main - optional: false - name: pcre2 version: '10.44' manager: conda @@ -6520,18 +6489,6 @@ package: sha256: 88429d3c889604dc4be9133a82a3e9857e34f76fa2d28f91fadfeb8f030ff09e category: main optional: false -- name: pygments - version: 2.18.0 - manager: conda - platform: linux-64 - dependencies: - python: '>=3.8' - url: https://conda.anaconda.org/conda-forge/noarch/pygments-2.18.0-pyhd8ed1ab_0.conda - hash: - md5: b7f5c092b8f9800150d998a71b76d5a1 - sha256: 78267adf4e76d0d64ea2ffab008c501156c108bb08fecb703816fb63e279780b - category: main - optional: false - name: pyparsing version: 3.1.4 manager: conda @@ -7942,19 +7899,6 @@ package: sha256: 15dcf503b5c5968913e390405a4e05f618dc7a369c951006f802d99a2be9b27f category: main optional: false -- name: tinyxml2 - version: 10.0.0 - manager: conda - platform: linux-64 - dependencies: - libgcc-ng: '>=12' - libstdcxx-ng: '>=12' - url: https://conda.anaconda.org/conda-forge/linux-64/tinyxml2-10.0.0-h59595ed_0.conda - hash: - md5: 5e27e4a780264caed4be372ded70a9e9 - sha256: e89306d01999f629a329ddb2e2ca9b8fbfe7c483d13f9805f0c6891a24a6e9c8 - category: main - optional: false - name: tk version: 8.6.13 manager: conda diff --git a/.github/workflows/env-files/py312-conda-lock.yml b/.github/workflows/env-files/py312-conda-lock.yml index 389c96c93..0b2e2bec1 100644 --- a/.github/workflows/env-files/py312-conda-lock.yml +++ b/.github/workflows/env-files/py312-conda-lock.yml @@ -15,7 +15,7 @@ metadata: content_hash: osx-arm64: 7ff7b8bb4137d39fcb1bdd67dee9baf795a9a8b5aabd875a8bfa3eefebcbbfcf osx-64: ec014e3a87de0d7ca833a6be83ffbd457fd769d95800056d1aa40021437c89d4 - linux-64: ee41871b60ad4a40cd4a5f8077bd7ff5c279d04b3dcc94611d5a45ac066e7180 + linux-64: 6c3842ddc6be7e7a57a0464490d8f63a4634a183ba20fe739174de3071c07e93 win-64: 027938cd527d09121463640d58e9de6e9cb9ad59957554bd6ab62b47ebbe72b5 channels: - url: conda-forge @@ -1188,24 +1188,6 @@ package: sha256: 557d32fd30108c4fd44fba60621e30519c1fcf6a361cfd8bef1f3e3eac51eb99 category: main optional: false -- name: cppcheck - version: 2.14.2 - manager: conda - platform: linux-64 - dependencies: - libgcc-ng: '>=12' - libstdcxx-ng: '>=12' - pcre: '>=8.45,<9.0a0' - pygments: '' - python: '>=3.12,<3.13.0a0' - python_abi: 3.12.* - tinyxml2: '>=10.0.0,<11.0a0' - url: https://conda.anaconda.org/conda-forge/linux-64/cppcheck-2.14.2-py312hc098bc4_0.conda - hash: - md5: 8c400de839fec3a6ff6c0bedf017f4a2 - sha256: 4f100a98fa9e573abd2422096d06d23338265358ae5e39a068c0fb8417d5c3f6 - category: main - optional: false - name: cycler version: 0.12.1 manager: conda @@ -7089,19 +7071,6 @@ package: sha256: 35ad5cab1d9c08cf98576044bf28f75e62f8492afe6d1a89c94bbe93dc8d7258 category: main optional: false -- name: pcre - version: '8.45' - manager: conda - platform: linux-64 - dependencies: - libgcc-ng: '>=9.3.0' - libstdcxx-ng: '>=9.3.0' - url: https://conda.anaconda.org/conda-forge/linux-64/pcre-8.45-h9c3ff4c_0.tar.bz2 - hash: - md5: c05d1820a6d34ff07aaaab7a9b7eddaa - sha256: 8f35c244b1631a4f31fb1d66ab6e1d9bfac0ca9b679deced1112c7225b3ad138 - category: main - optional: false - name: pcre2 version: '10.44' manager: conda @@ -7584,18 +7553,6 @@ package: sha256: 88429d3c889604dc4be9133a82a3e9857e34f76fa2d28f91fadfeb8f030ff09e category: main optional: false -- name: pygments - version: 2.18.0 - manager: conda - platform: linux-64 - dependencies: - python: '>=3.8' - url: https://conda.anaconda.org/conda-forge/noarch/pygments-2.18.0-pyhd8ed1ab_0.conda - hash: - md5: b7f5c092b8f9800150d998a71b76d5a1 - sha256: 78267adf4e76d0d64ea2ffab008c501156c108bb08fecb703816fb63e279780b - category: main - optional: false - name: pyparsing version: 3.1.4 manager: conda @@ -9301,19 +9258,6 @@ package: sha256: 15dcf503b5c5968913e390405a4e05f618dc7a369c951006f802d99a2be9b27f category: main optional: false -- name: tinyxml2 - version: 10.0.0 - manager: conda - platform: linux-64 - dependencies: - libgcc-ng: '>=12' - libstdcxx-ng: '>=12' - url: https://conda.anaconda.org/conda-forge/linux-64/tinyxml2-10.0.0-h59595ed_0.conda - hash: - md5: 5e27e4a780264caed4be372ded70a9e9 - sha256: e89306d01999f629a329ddb2e2ca9b8fbfe7c483d13f9805f0c6891a24a6e9c8 - category: main - optional: false - name: tk version: 8.6.13 manager: conda diff --git a/.github/workflows/env-files/py39-conda-lock.yml b/.github/workflows/env-files/py39-conda-lock.yml index 8170f1759..fcece13ca 100644 --- a/.github/workflows/env-files/py39-conda-lock.yml +++ b/.github/workflows/env-files/py39-conda-lock.yml @@ -15,7 +15,7 @@ metadata: content_hash: osx-arm64: f75d00288ebdb3e643a686787a4aca5381a3d1949478338cffe9c7057f2b57e5 osx-64: c53693a88efc06b41b0e7dd0a332c421203de805acd3b3c98d4b517e496e0a96 - linux-64: 82e3bef2f1e62f5c05c98d21a8cd9eede920245766f6647c611f7f6c124992ca + linux-64: ec03653558093d0d4ba5dc2641ee1e48bbf30067f1e84c9cb0e4cfb0f2af79ec win-64: 90283a287080e2e75a5bc8578813a2ee9523402c8e7490bf9279c63a98771e3c channels: - url: conda-forge @@ -1116,24 +1116,6 @@ package: sha256: ce5f46ee6d260913201d5060ab23ef2e27fbbf4778b0fce50c24a88e7cc2253c category: main optional: false -- name: cppcheck - version: 2.14.2 - manager: conda - platform: linux-64 - dependencies: - libgcc-ng: '>=12' - libstdcxx-ng: '>=12' - pcre: '>=8.45,<9.0a0' - pygments: '' - python: '>=3.9,<3.10.0a0' - python_abi: 3.9.* - tinyxml2: '>=10.0.0,<11.0a0' - url: https://conda.anaconda.org/conda-forge/linux-64/cppcheck-2.14.2-py39h886a56d_0.conda - hash: - md5: 6f0428c78c76416f81f03f3128a51793 - sha256: 7911fb97b1afa15b08b8d61c28d1b36e443756c58235842edb151b32bd862c68 - category: main - optional: false - name: cycler version: 0.12.1 manager: conda @@ -6883,19 +6865,6 @@ package: sha256: 35ad5cab1d9c08cf98576044bf28f75e62f8492afe6d1a89c94bbe93dc8d7258 category: main optional: false -- name: pcre - version: '8.45' - manager: conda - platform: linux-64 - dependencies: - libgcc-ng: '>=9.3.0' - libstdcxx-ng: '>=9.3.0' - url: https://conda.anaconda.org/conda-forge/linux-64/pcre-8.45-h9c3ff4c_0.tar.bz2 - hash: - md5: c05d1820a6d34ff07aaaab7a9b7eddaa - sha256: 8f35c244b1631a4f31fb1d66ab6e1d9bfac0ca9b679deced1112c7225b3ad138 - category: main - optional: false - name: pcre2 version: '10.44' manager: conda @@ -7333,18 +7302,6 @@ package: sha256: 88429d3c889604dc4be9133a82a3e9857e34f76fa2d28f91fadfeb8f030ff09e category: main optional: false -- name: pygments - version: 2.18.0 - manager: conda - platform: linux-64 - dependencies: - python: '>=3.8' - url: https://conda.anaconda.org/conda-forge/noarch/pygments-2.18.0-pyhd8ed1ab_0.conda - hash: - md5: b7f5c092b8f9800150d998a71b76d5a1 - sha256: 78267adf4e76d0d64ea2ffab008c501156c108bb08fecb703816fb63e279780b - category: main - optional: false - name: pyparsing version: 3.1.4 manager: conda @@ -8951,19 +8908,6 @@ package: sha256: 15dcf503b5c5968913e390405a4e05f618dc7a369c951006f802d99a2be9b27f category: main optional: false -- name: tinyxml2 - version: 10.0.0 - manager: conda - platform: linux-64 - dependencies: - libgcc-ng: '>=12' - libstdcxx-ng: '>=12' - url: https://conda.anaconda.org/conda-forge/linux-64/tinyxml2-10.0.0-h59595ed_0.conda - hash: - md5: 5e27e4a780264caed4be372ded70a9e9 - sha256: e89306d01999f629a329ddb2e2ca9b8fbfe7c483d13f9805f0c6891a24a6e9c8 - category: main - optional: false - name: tk version: 8.6.13 manager: conda diff --git a/.github/workflows/style_check.yml b/.github/workflows/style_check.yml index 3829d8030..464978ff8 100644 --- a/.github/workflows/style_check.yml +++ b/.github/workflows/style_check.yml @@ -36,7 +36,5 @@ jobs: cmake -S . -B build -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=True ls build cp build/compile_commands.json . - - name: cppcheck - run: pre-commit run cppcheck --all-files --hook-stage=manual -v - name: clang-tidy run: pre-commit run clang-tidy --all-files --hook-stage=manual -v diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6d947bdf0..9d283a01a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -111,27 +111,3 @@ repos: ) args: - --warnings-as-errors=* - # TODO: remove cppcheck and replace with clang-tidy - - id: cppcheck - stages: [manual] # Requires cppcheck. - # Ignore external files and those taken verbatim from HOOMD. - name: cppcheck - entry: cppcheck - language: system - types: [c++] - # Exclude external files. Also exclude AABB.h because it uses intrinsics - # heavily and these are not considered portable. - exclude: | - (?x)^( - ^freud/locality/AABB\.h| - ^extern/ - ) - args: - - cpp/ - - --enable=warning,style,performance,portability # Ignore unused (could be used by Cython). - - --std=c++14 - - --language=c++ # Force C++ for .h header files. - - --inline-suppr # Enable inline suppresions of warnings. - - --suppress=*:freud/locality/AABB.h - - --suppress=*:extern/* - - --error-exitcode=1 diff --git a/doc/source/reference/development/howtoadd.rst b/doc/source/reference/development/howtoadd.rst index 008ca19da..60605d22c 100644 --- a/doc/source/reference/development/howtoadd.rst +++ b/doc/source/reference/development/howtoadd.rst @@ -49,7 +49,7 @@ Please refer to the `clang-format documentation `__. diff --git a/freud/locality/AABBTree.h b/freud/locality/AABBTree.h index 9aa935305..b5c97b5e9 100644 --- a/freud/locality/AABBTree.h +++ b/freud/locality/AABBTree.h @@ -106,12 +106,7 @@ class AABBTree if (from.m_nodes != nullptr) { // allocate memory - // cppcheck doesn't understand posix_memalign very well and thinks it returns a pointer. - // This problem has either been fixed in newer versions of cppcheck - // or no longer arises on newer machines, but we observe this - // failure on our CI rigs. // NOLINTBEGIN(misc-include-cleaner): clang-tidy identifies the incorrect header - // cppcheck-suppress AssignmentAddressToInteger int const retval = posix_memalign((void**) &m_nodes, 32, m_node_capacity * sizeof(AABBNode)); // NOLINTEND(misc-include-cleaner) if (retval != 0) @@ -146,7 +141,6 @@ class AABBTree if (from.m_nodes != nullptr) { // allocate memory - // cppcheck-suppress AssignmentAddressToInteger int const retval = posix_memalign((void**) &m_nodes, 32, m_node_capacity * sizeof(AABBNode)); if (retval != 0) { @@ -455,10 +449,6 @@ inline unsigned int AABBTree::buildNode(AABB* aabbs, std::vector& unsigned int start_right = len; // if there are only 2 aabbs, put one on each side - // cppcheck knows that NODE_CAPACITY is defined as 16, so it sees this - // check as redundant. However, if we ever defined NODE_CAPACITY to be 1 - // then this check would be meaningful, so it's safer to leave it. - // cppcheck-suppress knownConditionTrueFalse if (len != 2) { // otherwise, we need to split them based on a heuristic. split the longest dimension in half @@ -596,7 +586,6 @@ inline unsigned int AABBTree::allocateNode() } // allocate new memory - // cppcheck-suppress AssignmentAddressToInteger int const retval = posix_memalign((void**) &m_new_nodes, 32, m_new_node_capacity * sizeof(AABBNode)); if (retval != 0) { @@ -606,8 +595,6 @@ inline unsigned int AABBTree::allocateNode() // if we have old memory, copy it over if (m_nodes != nullptr) { - // cppcheck doesn't recognize that posix_memalign allocates memory for m_new_nodes above. - // cppcheck-suppress nullPointer std::memcpy((void*) m_new_nodes, (void*) m_nodes, sizeof(AABBNode) * m_num_nodes); posix_memalign_free(m_nodes); } diff --git a/freud/order/Cubatic.cc b/freud/order/Cubatic.cc index afc906bd0..aeadf4b34 100644 --- a/freud/order/Cubatic.cc +++ b/freud/order/Cubatic.cc @@ -140,9 +140,6 @@ Cubatic::Cubatic(float t_initial, float t_final, float scale, unsigned int n_rep { throw std::invalid_argument("Cubatic requires that t_final must be >= 1e-6."); } - // cppcheck erroneously flags this check as redundant because it follows - // both branches independently. - // cppcheck-suppress knownConditionTrueFalse if ((scale >= 1) || (scale <= 0)) { throw std::invalid_argument("Cubatic requires that scale must be between 0 and 1."); diff --git a/freud/util/ManagedArray.h b/freud/util/ManagedArray.h index f5e112aae..5e195c74d 100644 --- a/freud/util/ManagedArray.h +++ b/freud/util/ManagedArray.h @@ -165,18 +165,12 @@ template class ManagedArray //! Implementation of variadic indexing function. template T& operator()(Ints... indices) { - // cppcheck generates a false positive here on old machines (CI), - // probably due to limited template support on those compilers. - // cppcheck-suppress returnTempReference return (*this)(buildIndex(indices...)); } //! Constant implementation of variadic indexing function. template const T& operator()(Ints... indices) const { - // cppcheck generates a false positive here on old machines (CI), - // probably due to limited template support on those compilers. - // cppcheck-suppress returnTempReference return (*this)(buildIndex(indices...)); } diff --git a/freud/util/VectorMath.h b/freud/util/VectorMath.h index fc336a54a..5dbdfedc0 100644 --- a/freud/util/VectorMath.h +++ b/freud/util/VectorMath.h @@ -34,11 +34,9 @@ template struct vec3 constexpr vec3(const Real& _x, const Real& _y, const Real& _z) : x(_x), y(_y), z(_z) {} //! Implicit cast from vec3 to the current Real - // cppcheck-suppress noExplicitConstructor constexpr vec3(const vec3& a) : x(a.x), y(a.y), z(a.z) {} //! Implicit cast from vec3 to the current Real - // cppcheck-suppress noExplicitConstructor constexpr vec3(const vec3& a) : x(a.x), y(a.y), z(a.z) {} //! Default construct a 0 vector