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

clang-tidy readability fixes

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