Commit f6a9f041 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

WIP: clang-tidy: resolve bool expression simpliciation lints

These conversions do not necessarily improve readability. They are
converted in this commit so that the lint is free to find new instances.

Conversion of functions of the form:

     bool check() {
          if (cond1) {
               return false;
          }
          if (cond2) {
               return false;
          }
          return true;
     }

are not necessarily better as:

     bool check() {
          return !cond1 && !cond2;
     }

since there may be other checks to add in the future or existing checks
might have more context around them. This usually occurs in validation
or dirty check functions.
parent 84270ce9
......@@ -84,7 +84,6 @@ readability-*,\
-readability-qualified-auto,\
-readability-redundant-declaration,\
-readability-redundant-preprocessor,\
-readability-simplify-boolean-expr,\
-readability-uppercase-literal-suffix,\
-readability-use-anyofallof,\
"
......
......@@ -298,17 +298,10 @@ bool vtkChartLegend::Hit(const vtkContextMouseEvent& mouse)
{
return false;
}
if (this->DragEnabled && mouse.GetPos().GetX() > this->Rect.GetX() &&
return this->DragEnabled && mouse.GetPos().GetX() > this->Rect.GetX() &&
mouse.GetPos().GetX() < this->Rect.GetX() + this->Rect.GetWidth() &&
mouse.GetPos().GetY() > this->Rect.GetY() &&
mouse.GetPos().GetY() < this->Rect.GetY() + this->Rect.GetHeight())
{
return true;
}
else
{
return false;
}
mouse.GetPos().GetY() < this->Rect.GetY() + this->Rect.GetHeight();
}
//------------------------------------------------------------------------------
......
......@@ -2107,15 +2107,8 @@ bool vtkChartXY::MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse)
this->LocatePointInPlots(mouse, vtkCommand::SelectionChangedEvent);
this->InvokeEvent(vtkCommand::SelectionChangedEvent);
}
if (mouse.GetButton() != this->ActionsClick.Notify() &&
mouse.GetButton() != this->ActionsClick.Select())
{
return false;
}
else
{
return true;
}
return mouse.GetButton() == this->ActionsClick.Notify() ||
mouse.GetButton() == this->ActionsClick.Select();
}
if (mouse.GetButton() == this->Actions.Select() ||
......
......@@ -1146,11 +1146,7 @@ bool vtkChartXYZ::Hit(const vtkContextMouseEvent& vtkNotUsed(mouse))
//------------------------------------------------------------------------------
bool vtkChartXYZ::MouseButtonPressEvent(const vtkContextMouseEvent& mouse)
{
if (mouse.GetButton() == vtkContextMouseEvent::LEFT_BUTTON)
{
return true;
}
return false;
return mouse.GetButton() == vtkContextMouseEvent::LEFT_BUTTON;
}
//------------------------------------------------------------------------------
......
......@@ -66,16 +66,9 @@ class vtkPlotArea::vtkTableCache
static bool inRange(
const vtkVector2f& point, const vtkVector2f& tol, const vtkVector2f& current)
{
if (current.GetX() > point.GetX() - tol.GetX() &&
return current.GetX() > point.GetX() - tol.GetX() &&
current.GetX() < point.GetX() + tol.GetX() && current.GetY() > point.GetY() - tol.GetY() &&
current.GetY() < point.GetY() + tol.GetY())
{
return true;
}
else
{
return false;
}
current.GetY() < point.GetY() + tol.GetY();
}
};
......
......@@ -63,11 +63,7 @@ static bool TestTemplate2Macro()
return false;
}
in = 2;
if (!RunTemplate2Macro2(NIn, &in, NOut, &out) || out != 2)
{
return false;
}
return true;
return RunTemplate2Macro2(NIn, &in, NOut, &out) && out == 2;
}
int TestTemplateMacro(int, char*[])
......
......@@ -223,14 +223,10 @@ bool vtkAMRBox::HasPoint(const vtkAMRBox& box, const double origin[3], const dou
//------------------------------------------------------------------------------
bool vtkAMRBox::operator==(const vtkAMRBox& other) const
{
if ((this->Empty() && other.Empty()) ||
return (this->Empty() && other.Empty()) ||
(this->LoCorner[0] == other.LoCorner[0] && this->LoCorner[1] == other.LoCorner[1] &&
this->LoCorner[2] == other.LoCorner[2] && this->HiCorner[0] == other.HiCorner[0] &&
this->HiCorner[1] == other.HiCorner[1] && this->HiCorner[2] == other.HiCorner[2]))
{
return true;
}
return false;
this->HiCorner[1] == other.HiCorner[1] && this->HiCorner[2] == other.HiCorner[2]);
}
//------------------------------------------------------------------------------
......
......@@ -42,11 +42,7 @@ void vtkInformationIntegerRequestKey::CopyDefaultInformation(
bool vtkInformationIntegerRequestKey::NeedToExecute(
vtkInformation* pipelineInfo, vtkInformation* dobjInfo)
{
if (!dobjInfo->Has(this->DataKey) || dobjInfo->Get(this->DataKey) != pipelineInfo->Get(this))
{
return true;
}
return false;
return !dobjInfo->Has(this->DataKey) || dobjInfo->Get(this->DataKey) != pipelineInfo->Get(this);
}
//------------------------------------------------------------------------------
......
......@@ -59,11 +59,7 @@ bool TestStructured(int type)
cutter->SetGenerateTriangles(1);
cutter->Update();
output = vtkPolyData::SafeDownCast(cutter->GetOutputDataObject(0));
if (output->GetNumberOfCells() != 7 || output->CheckAttributes())
{
return false;
}
return true;
return output->GetNumberOfCells() == 7 && !output->CheckAttributes();
}
bool TestUnstructured()
......@@ -98,11 +94,7 @@ bool TestUnstructured()
cutter->SetGenerateTriangles(1);
cutter->Update();
output = vtkPolyData::SafeDownCast(cutter->GetOutputDataObject(0));
if (output->GetNumberOfCells() != 10)
{
return false;
}
return true;
return output->GetNumberOfCells() == 10;
}
int TestCutter(int, char*[])
......
......@@ -602,11 +602,7 @@ bool vtkClipConvexPolyData::HasDegeneracies(vtkPlane* plane)
totalNumNewVertices += numNewVertices;
}
if (totalNumNewVertices < 6)
{
return true;
}
return false;
return totalNumNewVertices < 6;
}
//------------------------------------------------------------------------------
......
......@@ -37,11 +37,7 @@ float vtkGraphWeightEuclideanDistanceFilter::ComputeWeight(
bool vtkGraphWeightEuclideanDistanceFilter::CheckRequirements(vtkGraph* const graph) const
{
vtkPoints* points = graph->GetPoints();
if (!points)
{
return false;
}
return true;
return points != nullptr;
}
//------------------------------------------------------------------------------
......
......@@ -169,17 +169,10 @@ public:
// needs to refer to the state of the edge.
bool GeneratePrimitives(unsigned char* ePtr[4])
{
if (*ePtr[0] >= vtkExtractSurfaceAlgorithm::Invalid ||
*ePtr[1] >= vtkExtractSurfaceAlgorithm::Invalid ||
*ePtr[2] >= vtkExtractSurfaceAlgorithm::Invalid ||
*ePtr[3] >= vtkExtractSurfaceAlgorithm::Invalid)
{
return false;
}
else
{
return true;
}
return *ePtr[0] < vtkExtractSurfaceAlgorithm::Invalid &&
*ePtr[1] < vtkExtractSurfaceAlgorithm::Invalid &&
*ePtr[2] < vtkExtractSurfaceAlgorithm::Invalid &&
*ePtr[3] < vtkExtractSurfaceAlgorithm::Invalid;
}
// Return the number of contouring primitives for a particular edge case number.
......
......@@ -1189,13 +1189,7 @@ void vtkCGNSMetaData::Broadcast(vtkMultiProcessController* controller, int rank)
bool ReadBase(vtkCGNSReader* reader, const BaseInformation& baseInfo)
{
auto baseSelection = reader->GetBaseSelection();
if (!baseSelection->ArrayIsEnabled(baseInfo.name))
{
// base has not been enabled.
return false;
}
return true;
return baseSelection->ArrayIsEnabled(baseInfo.name) != 0;
}
//------------------------------------------------------------------------------
......@@ -1216,25 +1210,14 @@ bool ReadGridForZone(
// check if the zone's family is enabled.
auto familySelection = reader->GetFamilySelection();
if (familySelection->ArrayExists(zoneInfo.family.c_str()) &&
!familySelection->ArrayIsEnabled(zoneInfo.family.c_str()))
{
return false;
}
return true;
return familySelection->ArrayExists(zoneInfo.family.c_str()) == 0 ||
familySelection->ArrayIsEnabled(zoneInfo.family.c_str()) != 0;
}
//------------------------------------------------------------------------------
bool ReadPatchesForBase(vtkCGNSReader* reader, const BaseInformation&)
{
if (!reader->GetLoadBndPatch())
{
// patches have been globally disabled.
return false;
}
return true;
return reader->GetLoadBndPatch();
}
//------------------------------------------------------------------------------
......@@ -1243,12 +1226,7 @@ bool ReadPatch(vtkCGNSReader* reader, const BaseInformation&, const ZoneInformat
{
auto familySelection = reader->GetFamilySelection();
if (!patchFamilyname.empty() && !familySelection->ArrayIsEnabled(patchFamilyname.c_str()))
{
return false;
}
return true;
return patchFamilyname.empty() || familySelection->ArrayIsEnabled(patchFamilyname.c_str());
}
} // end of namespace
......@@ -348,12 +348,8 @@ int vtkNIFTIImageReader::CheckNIFTIVersion(const nifti_1_header* hdr)
//------------------------------------------------------------------------------
bool vtkNIFTIImageReader::CheckAnalyzeHeader(const nifti_1_header* hdr)
{
if (hdr->sizeof_hdr == 348 || // Analyze 7.5 header size
hdr->sizeof_hdr == 1543569408) // byte-swapped 348
{
return true;
}
return false;
return hdr->sizeof_hdr == 348 || // Analyze 7.5 header size
hdr->sizeof_hdr == 1543569408; // byte-swapped 348
}
//------------------------------------------------------------------------------
......
......@@ -129,13 +129,8 @@ bool verify(vtkUnstructuredGrid* grid)
std::cerr << "Missing information object!\n";
return false;
}
if (!stringEqual("Ghost level information", array->GetComponentName(0)) ||
!stringEqual("N/A", info->Get(vtkDataArray::UNITS_LABEL())))
{
return false;
}
return true;
return stringEqual("Ghost level information", array->GetComponentName(0)) &&
stringEqual("N/A", info->Get(vtkDataArray::UNITS_LABEL()));
}
} // end anon namespace
......
......@@ -229,16 +229,11 @@ bool vtkOpenGLPointGaussianMapperHelper::GetNeedToRebuildShaders(
// property modified (representation interpolation and lighting)
// input modified
// light complexity changed
if (cellBO.Program == nullptr || cellBO.ShaderSourceTime < this->GetMTime() ||
return cellBO.Program == nullptr || cellBO.ShaderSourceTime < this->GetMTime() ||
cellBO.ShaderSourceTime < actor->GetMTime() ||
cellBO.ShaderSourceTime < this->CurrentInput->GetMTime() ||
cellBO.ShaderSourceTime < this->SelectionStateChanged ||
cellBO.ShaderSourceTime < renderPassMTime)
{
return true;
}
return false;
cellBO.ShaderSourceTime < renderPassMTime;
}
//------------------------------------------------------------------------------
......@@ -477,17 +472,13 @@ void vtkOpenGLPointGaussianMapperHelperSizes(vtkFloatArray* scales, PointDataTyp
bool vtkOpenGLPointGaussianMapperHelper::GetNeedToRebuildBufferObjects(
vtkRenderer* vtkNotUsed(ren), vtkActor* act)
{
if (this->VBOBuildTime < this->GetMTime() || this->VBOBuildTime < act->GetMTime() ||
return this->VBOBuildTime < this->GetMTime() || this->VBOBuildTime < act->GetMTime() ||
this->VBOBuildTime < this->CurrentInput->GetMTime() ||
this->VBOBuildTime < this->Owner->GetMTime() ||
(this->Owner->GetScalarOpacityFunction() &&
this->VBOBuildTime < this->Owner->GetScalarOpacityFunction()->GetMTime()) ||
(this->Owner->GetScaleFunction() &&
this->VBOBuildTime < this->Owner->GetScaleFunction()->GetMTime()))
{
return true;
}
return false;
this->VBOBuildTime < this->Owner->GetScaleFunction()->GetMTime());
}
//------------------------------------------------------------------------------
......
......@@ -420,13 +420,9 @@ bool vtkOpenGLPolyDataMapper::DrawingEdges(vtkRenderer*, vtkActor* actor)
return false;
}
if (actor->GetProperty()->GetEdgeVisibility() &&
return actor->GetProperty()->GetEdgeVisibility() &&
this->GetOpenGLMode(
actor->GetProperty()->GetRepresentation(), this->LastBoundBO->PrimitiveType) == GL_TRIANGLES)
{
return true;
}
return false;
actor->GetProperty()->GetRepresentation(), this->LastBoundBO->PrimitiveType) == GL_TRIANGLES;
}
//-----------------------------------------------------------------------------
......
......@@ -134,15 +134,10 @@ bool vtkOpenGLPolyDataMapper2D::GetNeedToRebuildShaders(
// property modified (representation interpolation and lighting)
// input modified
// light complexity changed
if (cellBO.Program == nullptr || cellBO.ShaderSourceTime < this->GetMTime() ||
return cellBO.Program == nullptr || cellBO.ShaderSourceTime < this->GetMTime() ||
cellBO.ShaderSourceTime < actor->GetMTime() ||
cellBO.ShaderSourceTime < this->GetInput()->GetMTime() ||
cellBO.ShaderSourceTime < this->PickStateChanged)
{
return true;
}
return false;
cellBO.ShaderSourceTime < this->PickStateChanged;
}
//------------------------------------------------------------------------------
......
......@@ -802,11 +802,7 @@ int vtkOpenGLRenderWindow::GetPixelData(
// does the current read buffer require resolving for reading pixels
bool vtkOpenGLRenderWindow::GetBufferNeedsResolving()
{
if (this->RenderFramebuffer->GetMultiSamples())
{
return true;
}
return false;
return this->RenderFramebuffer->GetMultiSamples();
}
//------------------------------------------------------------------------------
......
......@@ -68,12 +68,8 @@ bool vtkOpenGLVolumeTransferFunction2D::NeedsUpdate(vtkObject* func,
{
return false;
}
if (func->GetMTime() > this->BuildTime || this->TextureObject->GetMTime() > this->BuildTime ||
!this->TextureObject->GetHandle())
{
return true;
}
return false;
return func->GetMTime() > this->BuildTime || this->TextureObject->GetMTime() > this->BuildTime ||
!this->TextureObject->GetHandle();
}
//------------------------------------------------------------------------------
......
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