diff --git a/.clang-tidy b/.clang-tidy index 851fded8..b05284ef 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,2 +1,2 @@ -Checks: '-*,modernize-*,performance-*,cppcoreguidelines-*,-modernize-use-trailing-return-type,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-type-cstyle-cast,-cppcoreguidelines-pro-bounds-array-to-pointer-decay' +Checks: '-*,modernize-*,performance-*,cppcoreguidelines-*,-modernize-use-trailing-return-type,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-type-cstyle-cast,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-type-const-cast' HeaderFilterRegex: '^(pomerol|mpi_dispatcher).*$' diff --git a/prog/quantum_model.cpp b/prog/quantum_model.cpp index 0f15d16a..67c2585b 100644 --- a/prog/quantum_model.cpp +++ b/prog/quantum_model.cpp @@ -120,7 +120,9 @@ void quantum_model::compute() { rho.compute(); // Evaluate thermal weights with respect to ground energy, i.e exp(-beta(e-e_0))/Z. std::pair pair = get_node(IndexInfo); + // cppcheck-suppress variableScope ParticleIndex d0 = pair.first; + // cppcheck-suppress variableScope ParticleIndex u0 = pair.second; // Green's function calculation starts here. diff --git a/src/pomerol/EnsembleAverage.cpp b/src/pomerol/EnsembleAverage.cpp index a5835146..0aacb723 100644 --- a/src/pomerol/EnsembleAverage.cpp +++ b/src/pomerol/EnsembleAverage.cpp @@ -41,11 +41,11 @@ void EnsembleAverage::compute() { // check if retained blocks are included. If not, do not push. if(DM.isRetained(Aleft)) { if(A.isComplex()) - Result += - computeImpl((MonomialOperatorPart&)A.getPartFromLeftIndex(Aleft), DM.getPart(Aleft)); + Result += computeImpl(const_cast(A.getPartFromLeftIndex(Aleft)), + DM.getPart(Aleft)); else - Result += - computeImpl((MonomialOperatorPart&)A.getPartFromLeftIndex(Aleft), DM.getPart(Aleft)); + Result += computeImpl(const_cast(A.getPartFromLeftIndex(Aleft)), + DM.getPart(Aleft)); } } } diff --git a/src/pomerol/Susceptibility.cpp b/src/pomerol/Susceptibility.cpp index 5922af38..5bcfed50 100644 --- a/src/pomerol/Susceptibility.cpp +++ b/src/pomerol/Susceptibility.cpp @@ -61,8 +61,8 @@ void Susceptibility::prepare() { if(Aleft == Bright && Aright == Bleft) { // check if retained blocks are included. If not, do not push. if(DM.isRetained(Aleft) || DM.isRetained(Aright)) - parts.emplace_back((MonomialOperatorPart&)A.getPartFromLeftIndex(Aleft), - (MonomialOperatorPart&)B.getPartFromRightIndex(Bright), + parts.emplace_back(const_cast(A.getPartFromLeftIndex(Aleft)), + const_cast(B.getPartFromRightIndex(Bright)), H.getPart(Aright), H.getPart(Aleft), DM.getPart(Aright), diff --git a/src/pomerol/TwoParticleGF.cpp b/src/pomerol/TwoParticleGF.cpp index 5828bf8e..f1dc399f 100644 --- a/src/pomerol/TwoParticleGF.cpp +++ b/src/pomerol/TwoParticleGF.cpp @@ -96,7 +96,7 @@ void TwoParticleGF::prepare() { parts.emplace_back(OperatorPartAtPosition(p, 0, LeftIndices[0]), OperatorPartAtPosition(p, 1, LeftIndices[1]), OperatorPartAtPosition(p, 2, LeftIndices[2]), - (MonomialOperatorPart&)CX4.getPartFromLeftIndex(LeftIndices[3]), + const_cast(CX4.getPartFromLeftIndex(LeftIndices[3])), H.getPart(LeftIndices[0]), H.getPart(LeftIndices[1]), H.getPart(LeftIndices[2]), diff --git a/test/3PSusc1siteTest.cpp b/test/3PSusc1siteTest.cpp index c288ad9e..5aaa6ed2 100644 --- a/test/3PSusc1siteTest.cpp +++ b/test/3PSusc1siteTest.cpp @@ -98,6 +98,7 @@ TEST_CASE("3-point susceptibilities of a single Hubbard atom", "[ThreePointSusce auto omega = [beta](int n) { return M_PI * (2 * n + 1) / beta; }; g_aux g(beta, U, mu, h_field); + // cppcheck-suppress syntaxError SECTION("Particle-particle channel") { for(auto index1 : {up_index, dn_index}) { for(auto index2 : {up_index, dn_index}) { diff --git a/test/3PSusc3siteTest.cpp b/test/3PSusc3siteTest.cpp index b062e339..a7d501df 100644 --- a/test/3PSusc3siteTest.cpp +++ b/test/3PSusc3siteTest.cpp @@ -67,6 +67,7 @@ TEST_CASE("3-point susceptibilities of a small Hubbard cluster", "[ThreePointSus ParticleIndex C_up_index = IndexInfo.getIndex("C", 0, up); ParticleIndex C_dn_index = IndexInfo.getIndex("C", 0, down); + // cppcheck-suppress syntaxError SECTION("Particle-particle channel") { ThreePointSusceptibility chi3pp(Channel::PP, S, diff --git a/test/Anderson2PGFTest.cpp b/test/Anderson2PGFTest.cpp index 32a333b7..3b644ff4 100644 --- a/test/Anderson2PGFTest.cpp +++ b/test/Anderson2PGFTest.cpp @@ -107,6 +107,7 @@ TEST_CASE("Two-particle GF of the Anderson model", "[Anderson2PGF]") { std::vector> freqs; + // cppcheck-suppress syntaxError SECTION("Chi4.computeAll() for arbitrary frequencies") { Chi4.computeAll(false, freqs, MPI_COMM_WORLD, true); diff --git a/test/BroadcastTest.cpp b/test/BroadcastTest.cpp index 14ce15ba..9744f450 100644 --- a/test/BroadcastTest.cpp +++ b/test/BroadcastTest.cpp @@ -53,6 +53,7 @@ TEST_CASE("broadcast() methods of various objects", "[broadcast]") { TwoParticleGFPart::ResonantTerm tr_ref(ComplexType(4.0, 3.0), ComplexType(5.0, 6.0), -0.1, 0.2, 0.3, true); tr_ref.Weight = 100; + // cppcheck-suppress syntaxError SECTION("TwoParticleGFPart::NonResonantTerm::mpi_datatype()") { TwoParticleGFPart::NonResonantTerm tnr(0, 0, 0, 0, false); if(rank == 0) diff --git a/test/GF1siteTest.cpp b/test/GF1siteTest.cpp index 4210acba..71cb4285 100644 --- a/test/GF1siteTest.cpp +++ b/test/GF1siteTest.cpp @@ -101,6 +101,7 @@ TEST_CASE("Green's function of a Hubbard atom", "[GF1site]") { REQUIRE_THAT(result, IsCloseTo(ref, 1e-14)); } + // cppcheck-suppress syntaxError SECTION("GFContainer") { GFContainer G(IndexInfo, S, H, rho, Operators); diff --git a/test/HamiltonianBosonsTest.cpp b/test/HamiltonianBosonsTest.cpp index ddad757c..2b344086 100644 --- a/test/HamiltonianBosonsTest.cpp +++ b/test/HamiltonianBosonsTest.cpp @@ -69,6 +69,7 @@ TEST_CASE("Hamiltonian of an isolated Hubbard-Holstein atom", "[HubbardHolstein] auto IndexInfo = MakeIndexClassification(HExpr); INFO("Indices\n" << IndexInfo); + // cppcheck-suppress syntaxError SECTION("bits_per_boson") { auto HS = MakeHilbertSpace(IndexInfo, HExpr, bits_per_boson); HS.compute(); diff --git a/test/HamiltonianTest.cpp b/test/HamiltonianTest.cpp index b25bb4d4..1399aaa3 100644 --- a/test/HamiltonianTest.cpp +++ b/test/HamiltonianTest.cpp @@ -54,6 +54,7 @@ TEST_CASE("Simple Hamiltonian test", "[hamiltonian]") { H.compute(MPI_COMM_WORLD); INFO(H.getPart(BlockNumber(4))); + // cppcheck-suppress syntaxError SECTION("Ground state energy") { RealType E_ref = -2.8860009; RealType E = H.getGroundEnergy(); diff --git a/test/MPIDispatcherTest.cpp b/test/MPIDispatcherTest.cpp index 9892595b..3e36fdc2 100644 --- a/test/MPIDispatcherTest.cpp +++ b/test/MPIDispatcherTest.cpp @@ -39,6 +39,7 @@ TEST_CASE("Test mpi_dispatcher", "[mpi_dispatcher]") { int comm_rank = pMPI::rank(MPI_COMM_WORLD); int const root = 0; + // cppcheck-suppress syntaxError SECTION("With MPIMaster") { std::uniform_real_distribution dist(0, 0.1); diff --git a/test/SusceptibilityTest.cpp b/test/SusceptibilityTest.cpp index eec54980..710e431e 100644 --- a/test/SusceptibilityTest.cpp +++ b/test/SusceptibilityTest.cpp @@ -83,6 +83,7 @@ TEST_CASE("Susceptibilities of a single Hubbard atom", "[Susceptibility]") { RealType wd = weights_ref[2]; RealType w2 = weights_ref[3]; + // cppcheck-suppress syntaxError SECTION("Ensemble averages") { EnsembleAverage s_plus_aver(s_plus, rho); s_plus_aver.compute(); diff --git a/test/Vertex4Test.cpp b/test/Vertex4Test.cpp index e9a1c708..8c8e2750 100644 --- a/test/Vertex4Test.cpp +++ b/test/Vertex4Test.cpp @@ -118,6 +118,7 @@ TEST_CASE("Two-particle vertex of a single Hubbard atom", "[Vertex4]") { ParticleIndex up_index = IndexInfo.getIndex("A", 0, up); ParticleIndex down_index = IndexInfo.getIndex("A", 0, down); + // cppcheck-suppress syntaxError SECTION("\\chi_{\\up\\up\\up\\up} and \\Gamma_{\\up\\up\\up\\up}") { GreensFunction const& GF = G(up_index, up_index); TwoParticleGF const& Chi_uuuu = Chi(IndexCombination4(up_index, up_index, up_index, up_index));