Skip to content

Commit

Permalink
Addressed some clang-tidy and cppcheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
krivenko committed Aug 25, 2024
1 parent cf7e3b7 commit a92d204
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -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).*$'
2 changes: 2 additions & 0 deletions prog/quantum_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ParticleIndex, ParticleIndex> pair = get_node(IndexInfo);
// cppcheck-suppress variableScope
ParticleIndex d0 = pair.first;
// cppcheck-suppress variableScope
ParticleIndex u0 = pair.second;

// Green's function calculation starts here.
Expand Down
8 changes: 4 additions & 4 deletions src/pomerol/EnsembleAverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<true>((MonomialOperatorPart&)A.getPartFromLeftIndex(Aleft), DM.getPart(Aleft));
Result += computeImpl<true>(const_cast<MonomialOperatorPart&>(A.getPartFromLeftIndex(Aleft)),
DM.getPart(Aleft));
else
Result +=
computeImpl<false>((MonomialOperatorPart&)A.getPartFromLeftIndex(Aleft), DM.getPart(Aleft));
Result += computeImpl<false>(const_cast<MonomialOperatorPart&>(A.getPartFromLeftIndex(Aleft)),
DM.getPart(Aleft));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/pomerol/Susceptibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MonomialOperatorPart&>(A.getPartFromLeftIndex(Aleft)),
const_cast<MonomialOperatorPart&>(B.getPartFromRightIndex(Bright)),
H.getPart(Aright),
H.getPart(Aleft),
DM.getPart(Aright),
Expand Down
2 changes: 1 addition & 1 deletion src/pomerol/TwoParticleGF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MonomialOperatorPart&>(CX4.getPartFromLeftIndex(LeftIndices[3])),
H.getPart(LeftIndices[0]),
H.getPart(LeftIndices[1]),
H.getPart(LeftIndices[2]),
Expand Down
1 change: 1 addition & 0 deletions test/3PSusc1siteTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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}) {
Expand Down
1 change: 1 addition & 0 deletions test/3PSusc3siteTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions test/Anderson2PGFTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ TEST_CASE("Two-particle GF of the Anderson model", "[Anderson2PGF]") {

std::vector<std::tuple<ComplexType, ComplexType, ComplexType>> freqs;

// cppcheck-suppress syntaxError
SECTION("Chi4.computeAll() for arbitrary frequencies") {
Chi4.computeAll(false, freqs, MPI_COMM_WORLD, true);

Expand Down
1 change: 1 addition & 0 deletions test/BroadcastTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions test/GF1siteTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions test/HamiltonianBosonsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions test/HamiltonianTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions test/MPIDispatcherTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> dist(0, 0.1);

Expand Down
1 change: 1 addition & 0 deletions test/SusceptibilityTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions test/Vertex4Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit a92d204

Please sign in to comment.