Commit 3c975307 authored by Jens Petit's avatar Jens Petit
Browse files

clang-tidy readability fixes

parent ae2838a3
Pipeline #171545 passed with stages
in 2 minutes and 11 seconds
...@@ -6,7 +6,7 @@ namespace elsa ...@@ -6,7 +6,7 @@ namespace elsa
{ {
BlockDescriptor::BlockDescriptor(index_t numberOfBlocks, const DataDescriptor& dataDescriptor) BlockDescriptor::BlockDescriptor(index_t numberOfBlocks, const DataDescriptor& dataDescriptor)
: DataDescriptor(dataDescriptor), _blockDescriptors{}, _blockOffsets(numberOfBlocks) : DataDescriptor(dataDescriptor), _blockOffsets(numberOfBlocks)
{ {
// sanity check // sanity check
if (numberOfBlocks <= 0) if (numberOfBlocks <= 0)
...@@ -48,7 +48,7 @@ namespace elsa ...@@ -48,7 +48,7 @@ namespace elsa
BlockDescriptor::BlockDescriptor(const BlockDescriptor& blockDescriptor) BlockDescriptor::BlockDescriptor(const BlockDescriptor& blockDescriptor)
: DataDescriptor(blockDescriptor), : DataDescriptor(blockDescriptor),
_blockDescriptors{},
_blockOffsets{blockDescriptor._blockOffsets} _blockOffsets{blockDescriptor._blockOffsets}
{ {
for (const auto& descriptor : blockDescriptor._blockDescriptors) for (const auto& descriptor : blockDescriptor._blockDescriptors)
...@@ -63,7 +63,7 @@ namespace elsa ...@@ -63,7 +63,7 @@ namespace elsa
return false; return false;
auto otherBlock = dynamic_cast<const BlockDescriptor*>(&other); auto otherBlock = dynamic_cast<const BlockDescriptor*>(&other);
if (!otherBlock) if (otherBlock == nullptr)
return false; return false;
if (_blockDescriptors.size() != otherBlock->_blockDescriptors.size()) if (_blockDescriptors.size() != otherBlock->_blockDescriptors.size())
...@@ -73,10 +73,7 @@ namespace elsa ...@@ -73,10 +73,7 @@ namespace elsa
if (*_blockDescriptors.at(i) != *otherBlock->_blockDescriptors.at(i)) if (*_blockDescriptors.at(i) != *otherBlock->_blockDescriptors.at(i))
return false; return false;
if (_blockOffsets != otherBlock->_blockOffsets) return _blockOffsets == otherBlock->_blockOffsets;
return false;
return true;
} }
} // namespace elsa } // namespace elsa
...@@ -279,7 +279,6 @@ namespace elsa ...@@ -279,7 +279,6 @@ namespace elsa
#pragma omp single #pragma omp single
_dataHandler = _dataHandler->clone(); _dataHandler = _dataHandler->clone();
} }
return;
} }
template <typename data_t> template <typename data_t>
......
...@@ -15,7 +15,7 @@ namespace elsa ...@@ -15,7 +15,7 @@ namespace elsa
class DataContainer; class DataContainer;
// used for testing and defined in test file (declared as friend) // used for testing and defined in test file (declared as friend)
template <typename data_t> template <typename data_t>
int useCount(const DataContainer<data_t>&); int useCount(const DataContainer<data_t>& /*dc*/);
/** /**
* \brief class representing and storing a linearized n-dimensional signal * \brief class representing and storing a linearized n-dimensional signal
......
...@@ -111,10 +111,8 @@ namespace elsa ...@@ -111,10 +111,8 @@ namespace elsa
template <typename data_t> template <typename data_t>
bool Functional<data_t>::isEqual(const Functional<data_t>& other) const bool Functional<data_t>::isEqual(const Functional<data_t>& other) const
{ {
if (*_domainDescriptor != *other._domainDescriptor || *_residual != *other._residual) return !static_cast<bool>(*_domainDescriptor != *other._domainDescriptor
return false; || *_residual != *other._residual);
return true;
} }
// ------------------------------------------ // ------------------------------------------
......
...@@ -46,10 +46,7 @@ namespace elsa ...@@ -46,10 +46,7 @@ namespace elsa
return false; return false;
auto otherL1Norm = dynamic_cast<const L1Norm*>(&other); auto otherL1Norm = dynamic_cast<const L1Norm*>(&other);
if (!otherL1Norm) return static_cast<bool>(otherL1Norm);
return false;
return true;
} }
// ------------------------------------------ // ------------------------------------------
......
...@@ -47,10 +47,7 @@ namespace elsa ...@@ -47,10 +47,7 @@ namespace elsa
return false; return false;
auto otherL2NormPow2 = dynamic_cast<const L2NormPow2*>(&other); auto otherL2NormPow2 = dynamic_cast<const L2NormPow2*>(&other);
if (!otherL2NormPow2) return static_cast<bool>(otherL2NormPow2);
return false;
return true;
} }
// ------------------------------------------ // ------------------------------------------
......
...@@ -46,10 +46,7 @@ namespace elsa ...@@ -46,10 +46,7 @@ namespace elsa
return false; return false;
auto otherLInfNorm = dynamic_cast<const LInfNorm*>(&other); auto otherLInfNorm = dynamic_cast<const LInfNorm*>(&other);
if (!otherLInfNorm) return static_cast<bool>(otherLInfNorm);
return false;
return true;
} }
// ------------------------------------------ // ------------------------------------------
......
...@@ -50,11 +50,8 @@ namespace elsa ...@@ -50,11 +50,8 @@ namespace elsa
template <typename data_t> template <typename data_t>
bool Residual<data_t>::isEqual(const Residual<data_t>& other) const bool Residual<data_t>::isEqual(const Residual<data_t>& other) const
{ {
if (*_domainDescriptor != *other._domainDescriptor return !static_cast<bool>(*_domainDescriptor != *other._domainDescriptor
|| *_rangeDescriptor != *other._rangeDescriptor) || *_rangeDescriptor != *other._rangeDescriptor);
return false;
return true;
} }
// ------------------------------------------ // ------------------------------------------
......
...@@ -135,7 +135,7 @@ namespace elsa ...@@ -135,7 +135,7 @@ namespace elsa
dim.push_back(DataUtils::parse<index_t>(dimIt->second)); dim.push_back(DataUtils::parse<index_t>(dimIt->second));
} }
const std::size_t nDims = dim.size(); const std::size_t nDims = dim.size();
if (!nDims) if (nDims == 0u)
throw std::runtime_error("EDF::parseHeader: dimension information not found"); throw std::runtime_error("EDF::parseHeader: dimension information not found");
// parse the (non-standard) spacing tag // parse the (non-standard) spacing tag
...@@ -201,7 +201,7 @@ namespace elsa ...@@ -201,7 +201,7 @@ namespace elsa
// convert spacing // convert spacing
RealVector_t dimSpacingVec(RealVector_t::Ones(nDims)); RealVector_t dimSpacingVec(RealVector_t::Ones(nDims));
if (spacing.size() > 0) { if (!spacing.empty()) {
if (spacing.size() != nDims) if (spacing.size() != nDims)
throw std::runtime_error("EDF::parseHeader: spacing inconsistency"); throw std::runtime_error("EDF::parseHeader: spacing inconsistency");
for (index_t i = 0; i < nDims; ++i) for (index_t i = 0; i < nDims; ++i)
......
...@@ -76,7 +76,7 @@ namespace elsa ...@@ -76,7 +76,7 @@ namespace elsa
std::getline(metaFile, metaLine); std::getline(metaFile, metaLine);
StringUtils::trim(metaLine); StringUtils::trim(metaLine);
if (!metaLine.length()) if (metaLine.length() == 0u)
continue; continue;
// split the header line into name and value // split the header line into name and value
...@@ -178,7 +178,7 @@ namespace elsa ...@@ -178,7 +178,7 @@ namespace elsa
// convert spacing // convert spacing
RealVector_t dimSpacing(RealVector_t::Ones(nDims)); RealVector_t dimSpacing(RealVector_t::Ones(nDims));
if (dimSpacingVec.size() > 0) { if (!dimSpacingVec.empty()) {
for (index_t i = 0; i < nDims; ++i) for (index_t i = 0; i < nDims; ++i)
dimSpacing[i] = dimSpacingVec[i]; dimSpacing[i] = dimSpacingVec[i];
} }
......
...@@ -10,11 +10,12 @@ namespace elsa ...@@ -10,11 +10,12 @@ namespace elsa
void StringUtils::trim(std::string& str) void StringUtils::trim(std::string& str)
{ {
// trim whitespace from beginning // trim whitespace from beginning
str.erase(str.begin(), str.erase(str.begin(), std::find_if(str.begin(), str.end(),
std::find_if(str.begin(), str.end(), [](int ch) { return !std::isspace(ch); })); [](int ch) { return std::isspace(ch) == 0; }));
// trim whitespace from end // trim whitespace from end
str.erase( str.erase(
std::find_if(str.rbegin(), str.rend(), [](int ch) { return !std::isspace(ch); }).base(), std::find_if(str.rbegin(), str.rend(), [](int ch) { return std::isspace(ch) == 0; })
.base(),
str.end()); str.end());
} }
......
...@@ -38,10 +38,7 @@ namespace elsa ...@@ -38,10 +38,7 @@ namespace elsa
return false; return false;
auto otherIdentity = dynamic_cast<const Identity*>(&other); auto otherIdentity = dynamic_cast<const Identity*>(&other);
if (!otherIdentity) return static_cast<bool>(otherIdentity);
return false;
return true;
} }
// ------------------------------------------ // ------------------------------------------
......
...@@ -198,10 +198,10 @@ SCENARIO("Testing FiniteDifferences in 2D with not all dimensions active") ...@@ -198,10 +198,10 @@ SCENARIO("Testing FiniteDifferences in 2D with not all dimensions active")
WHEN("using forward differences (default)") WHEN("using forward differences (default)")
{ {
BooleanVector_t activeDims(2); BooleanVector_t activeDims(2);
activeDims << 1, 0; activeDims << true, false;
FiniteDifferences fdOp1(dd, activeDims); FiniteDifferences fdOp1(dd, activeDims);
activeDims << 0, 1; activeDims << false, true;
FiniteDifferences fdOp2(dd, activeDims); FiniteDifferences fdOp2(dd, activeDims);
THEN("the results are correct") THEN("the results are correct")
...@@ -223,10 +223,10 @@ SCENARIO("Testing FiniteDifferences in 2D with not all dimensions active") ...@@ -223,10 +223,10 @@ SCENARIO("Testing FiniteDifferences in 2D with not all dimensions active")
WHEN("using backward differences") WHEN("using backward differences")
{ {
BooleanVector_t activeDims(2); BooleanVector_t activeDims(2);
activeDims << 1, 0; activeDims << true, false;
FiniteDifferences fdOp1(dd, activeDims, FiniteDifferences<real_t>::DiffType::BACKWARD); FiniteDifferences fdOp1(dd, activeDims, FiniteDifferences<real_t>::DiffType::BACKWARD);
activeDims << 0, 1; activeDims << false, true;
FiniteDifferences fdOp2(dd, activeDims, FiniteDifferences<real_t>::DiffType::BACKWARD); FiniteDifferences fdOp2(dd, activeDims, FiniteDifferences<real_t>::DiffType::BACKWARD);
THEN("the results are correct") THEN("the results are correct")
...@@ -248,10 +248,10 @@ SCENARIO("Testing FiniteDifferences in 2D with not all dimensions active") ...@@ -248,10 +248,10 @@ SCENARIO("Testing FiniteDifferences in 2D with not all dimensions active")
WHEN("using central differences") WHEN("using central differences")
{ {
BooleanVector_t activeDims(2); BooleanVector_t activeDims(2);
activeDims << 1, 0; activeDims << true, false;
FiniteDifferences fdOp1(dd, activeDims, FiniteDifferences<real_t>::DiffType::CENTRAL); FiniteDifferences fdOp1(dd, activeDims, FiniteDifferences<real_t>::DiffType::CENTRAL);
activeDims << 0, 1; activeDims << false, true;
FiniteDifferences fdOp2(dd, activeDims, FiniteDifferences<real_t>::DiffType::CENTRAL); FiniteDifferences fdOp2(dd, activeDims, FiniteDifferences<real_t>::DiffType::CENTRAL);
THEN("the results are correct") THEN("the results are correct")
......
...@@ -61,10 +61,7 @@ namespace elsa ...@@ -61,10 +61,7 @@ namespace elsa
return false; return false;
auto otherQP = dynamic_cast<const QuadricProblem*>(&other); auto otherQP = dynamic_cast<const QuadricProblem*>(&other);
if (!otherQP) return static_cast<bool>(otherQP);
return false;
return true;
} }
template <typename data_t> template <typename data_t>
......
...@@ -48,10 +48,7 @@ namespace elsa ...@@ -48,10 +48,7 @@ namespace elsa
return false; return false;
auto otherWLS = dynamic_cast<const WLSProblem*>(&other); auto otherWLS = dynamic_cast<const WLSProblem*>(&other);
if (!otherWLS) return static_cast<bool>(otherWLS);
return false;
return true;
} }
// ------------------------------------------ // ------------------------------------------
......
...@@ -28,10 +28,7 @@ namespace elsa ...@@ -28,10 +28,7 @@ namespace elsa
template <typename data_t> template <typename data_t>
bool Solver<data_t>::isEqual(const Solver<data_t>& other) const bool Solver<data_t>::isEqual(const Solver<data_t>& other) const
{ {
if (*_problem != *other._problem) return static_cast<bool>(*_problem == *other._problem);
return false;
return true;
} }
// ------------------------------------------ // ------------------------------------------
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment