Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add readability-else-after-return check #638

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
#
# SPDX-License-Identifier: MIT
---
Checks: '-*,bugprone-branch-clone,bugprone-reserved-identifier,hicpp-avoid-c-arrays,misc-const-correctness,modernize-use-nullptr,readability-avoid-const-params-in-decls'
Checks: '-*,bugprone-branch-clone,bugprone-reserved-identifier,hicpp-avoid-c-arrays,misc-const-correctness,modernize-use-nullptr,readability-avoid-const-params-in-decls,readability-else-after-return'
WarningsAsErrors: '*'
4 changes: 3 additions & 1 deletion include/ddc/kernels/splines/spline_boundary_conditions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ constexpr int n_boundary_equations(ddc::BoundCond const bc, std::size_t const de
{
if (bc == ddc::BoundCond::PERIODIC || bc == ddc::BoundCond::GREVILLE) {
return 0;
} else if (bc == ddc::BoundCond::HERMITE) {
}

if (bc == ddc::BoundCond::HERMITE) {
return degree / 2;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,17 @@ class SplinesLinearProblem2x2Blocks : public SplinesLinearProblem<ExecSpace>
std::size_t const nq = m_top_left_block->size();
if (i < nq && j < nq) {
return m_top_left_block->get_element(i, j);
} else if (i >= nq && j >= nq) {
}

if (i >= nq && j >= nq) {
return m_bottom_right_block->get_element(i - nq, j - nq);
} else if (j >= nq) {
}

if (j >= nq) {
return m_top_right_block.h_view(i, j - nq);
} else {
return m_bottom_left_block.h_view(i - nq, j);
}

return m_bottom_left_block.h_view(i - nq, j);
}

void set_element(std::size_t const i, std::size_t const j, double const aij) override
Expand Down
4 changes: 2 additions & 2 deletions include/ddc/kernels/splines/splines_linear_problem_band.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ class SplinesLinearProblemBand : public SplinesLinearProblem<ExecSpace>
static_cast<std::ptrdiff_t>(j) - static_cast<std::ptrdiff_t>(m_ku))
&& i < std::min(size(), j + m_kl + 1)) {
return m_q.h_view(band_storage_row_index(i, j), j);
} else {
return 0.0;
}

return 0.0;
}

void set_element(std::size_t const i, std::size_t const j, double const aij) override
Expand Down
12 changes: 8 additions & 4 deletions include/ddc/kernels/splines/splines_linear_problem_maker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@ class SplinesLinearProblemMaker
{
if (kl == ku && kl == 1 && pds) {
return std::make_unique<SplinesLinearProblemPDSTridiag<ExecSpace>>(n);
} else if (kl == ku && pds) {
}

if (kl == ku && pds) {
return std::make_unique<SplinesLinearProblemPDSBand<ExecSpace>>(n, kl);
} else if (2 * kl + ku + 1 >= n) {
}

if (2 * kl + ku + 1 >= n) {
return std::make_unique<SplinesLinearProblemDense<ExecSpace>>(n);
} else {
return std::make_unique<SplinesLinearProblemBand<ExecSpace>>(n, kl, ku);
}

return std::make_unique<SplinesLinearProblemBand<ExecSpace>>(n, kl, ku);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ class SplinesLinearProblemPDSBand : public SplinesLinearProblem<ExecSpace>
if (i > j) {
std::swap(i, j);
}

if (j - i < m_q.extent(0)) {
return m_q.h_view(j - i, i);
} else {
return 0.0;
}

return 0.0;
}

void set_element(std::size_t i, std::size_t j, double const aij) override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ class SplinesLinearProblemPDSTridiag : public SplinesLinearProblem<ExecSpace>
if (i > j) {
std::swap(i, j);
}

if (j - i < 2) {
return m_q.h_view(j - i, i);
} else {
return 0.0;
}

return 0.0;
}

void set_element(std::size_t i, std::size_t j, double const aij) override
Expand Down
Loading