Add readability-simplify-boolean-expr

* Add readability-simplify-boolean-expr
* Fixes based on review
This commit is contained in:
Magne Sjaastad
2023-06-26 13:12:41 +02:00
committed by GitHub
parent 34d83efaed
commit 59ca0b943c
116 changed files with 179 additions and 635 deletions

View File

@@ -458,8 +458,8 @@ void RimPlotDataFilterItem::updateMaxMinAndDefaultValues( bool forceDefault )
&m_upperLimit );
}
if ( forceDefault || !( m_min >= m_lowerLimit && m_min <= m_upperLimit ) ) m_min = m_lowerLimit;
if ( forceDefault || !( m_max >= m_lowerLimit && m_max <= m_upperLimit ) ) m_max = m_upperLimit;
if ( forceDefault || m_min < m_lowerLimit || m_min > m_upperLimit ) m_min = m_lowerLimit;
if ( forceDefault || m_max < m_lowerLimit || m_max > m_upperLimit ) m_max = m_upperLimit;
m_min.uiCapability()->setUiName( QString( "Min (%1)" ).arg( m_lowerLimit ) );
m_max.uiCapability()->setUiName( QString( "Max (%1)" ).arg( m_upperLimit ) );

View File

@@ -59,9 +59,7 @@ bool RimCellFilterInterval::isIncluded( size_t val ) const
size_t tmp = val - m_minIncludeVal;
if ( m_valid && ( tmp % m_step == 0 ) ) return true;
return false;
return m_valid && ( tmp % m_step == 0 );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -134,12 +134,7 @@ void RimEclipsePropertyFilter::rangeValues( double* lower, double* upper ) const
//--------------------------------------------------------------------------------------------------
bool RimEclipsePropertyFilter::isCategorySelectionActive() const
{
if ( m_resultDefinition->hasCategoryResult() && m_useCategorySelection )
{
return true;
}
return false;
return m_resultDefinition->hasCategoryResult() && m_useCategorySelection;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -213,12 +213,7 @@ void RimGeoMechPropertyFilter::updateActiveState()
//--------------------------------------------------------------------------------------------------
bool RimGeoMechPropertyFilter::isActiveAndHasResult()
{
if ( this->isActive() && this->resultDefinition->hasResult() )
{
return true;
}
return false;
return this->isActive() && this->resultDefinition->hasResult();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -603,12 +603,7 @@ std::vector<double>
//--------------------------------------------------------------------------------------------------
bool RimStimPlanFractureTemplate::hasConductivity() const
{
if ( m_stimPlanFractureDefinitionData.notNull() && !m_stimPlanFractureDefinitionData->conductivityResultNames().isEmpty() )
{
return true;
}
return false;
return m_stimPlanFractureDefinitionData.notNull() && !m_stimPlanFractureDefinitionData->conductivityResultNames().isEmpty();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -268,12 +268,7 @@ void RimWellFlowRateCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedF
bool RimWellFlowRateCurve::isUsingConnectionNumberDepthType() const
{
auto wellLogPlot = firstAncestorOrThisOfType<RimWellLogPlot>();
if ( wellLogPlot && wellLogPlot->depthType() == RiaDefines::DepthTypeEnum::CONNECTION_NUMBER )
{
return true;
}
return false;
return wellLogPlot && wellLogPlot->depthType() == RiaDefines::DepthTypeEnum::CONNECTION_NUMBER;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -531,7 +531,7 @@ std::vector<double> RimGeoMechContourMapProjection::gridCellValues( RigFemResult
for ( size_t globalCellIdx = 0; globalCellIdx < static_cast<size_t>( m_femPart->elementCount() ); ++globalCellIdx )
{
RigElementType elmType = m_femPart->elementType( globalCellIdx );
if ( !( elmType == HEX8 || elmType == HEX8P ) ) continue;
if ( elmType != HEX8 && elmType != HEX8P ) continue;
if ( resAddr.resultPosType == RIG_ELEMENT )
{

View File

@@ -1104,15 +1104,11 @@ bool RimGridCrossPlotDataSet::groupingByCategoryResult() const
//--------------------------------------------------------------------------------------------------
bool RimGridCrossPlotDataSet::groupingEnabled() const
{
if ( m_grouping != NO_GROUPING )
{
if ( m_grouping == GROUP_BY_RESULT && !m_groupingProperty->eclipseResultAddress().isValid() )
{
return false;
}
return true;
}
return false;
if ( m_grouping == NO_GROUPING ) return false;
if ( m_grouping == GROUP_BY_RESULT && !m_groupingProperty->eclipseResultAddress().isValid() ) return false;
return true;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -207,14 +207,7 @@ RimTernaryLegendConfig* RimIntersectionResultDefinition::ternaryLegendConfig() c
//--------------------------------------------------------------------------------------------------
bool RimIntersectionResultDefinition::isEclipseResultDefinition()
{
if ( dynamic_cast<RimEclipseCase*>( m_case() ) )
{
return true;
}
else
{
return false;
}
return dynamic_cast<RimEclipseCase*>( m_case() ) != nullptr;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -1125,12 +1125,7 @@ void Rim3dView::addMeasurementToModel( cvf::ModelBasicList* measureModel )
bool Rim3dView::isMasterView() const
{
RimViewLinker* viewLinker = this->assosiatedViewLinker();
if ( viewLinker && this == viewLinker->masterView() )
{
return true;
}
return false;
return viewLinker && this == viewLinker->masterView();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -635,12 +635,8 @@ bool RimContourMapProjection::geometryNeedsUpdating() const
//--------------------------------------------------------------------------------------------------
bool RimContourMapProjection::resultRangeIsValid() const
{
if ( m_minResultAllTimeSteps == std::numeric_limits<double>::infinity() ||
m_maxResultAllTimeSteps == -std::numeric_limits<double>::infinity() )
{
return false;
}
return true;
return m_minResultAllTimeSteps != std::numeric_limits<double>::infinity() &&
m_maxResultAllTimeSteps != -std::numeric_limits<double>::infinity();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -1137,14 +1137,7 @@ bool RimEclipseResultDefinition::hasStaticResult() const
const RigCaseCellResultsData* gridCellResults = this->currentGridCellResults();
RigEclipseResultAddress gridScalarResultIndex = this->eclipseResultAddress();
if ( hasResult() && gridCellResults->timeStepCount( gridScalarResultIndex ) == 1 )
{
return true;
}
else
{
return false;
}
return hasResult() && gridCellResults->timeStepCount( gridScalarResultIndex ) == 1;
}
//--------------------------------------------------------------------------------------------------
@@ -1465,13 +1458,8 @@ bool RimEclipseResultDefinition::hasCategoryResult() const
//--------------------------------------------------------------------------------------------------
bool RimEclipseResultDefinition::isFlowDiagOrInjectionFlooding() const
{
if ( this->m_resultType() == RiaDefines::ResultCatType::FLOW_DIAGNOSTICS ||
this->m_resultType() == RiaDefines::ResultCatType::INJECTION_FLOODING )
{
return true;
}
return false;
return this->m_resultType() == RiaDefines::ResultCatType::FLOW_DIAGNOSTICS ||
this->m_resultType() == RiaDefines::ResultCatType::INJECTION_FLOODING;
}
//--------------------------------------------------------------------------------------------------
@@ -1903,10 +1891,5 @@ bool RimEclipseResultDefinition::addPerCellFaceOptionsForVariableUiField() const
RimEclipsePropertyFilter* propFilter = firstAncestorOrThisOfType<RimEclipsePropertyFilter>();
RimCellEdgeColors* cellEdge = firstAncestorOrThisOfType<RimCellEdgeColors>();
if ( propFilter || curve || cellEdge )
{
return false;
}
return true;
return !( propFilter || curve || cellEdge );
}

View File

@@ -672,27 +672,27 @@ void RimEclipseStatisticsCase::updateSelectionListVisibilities()
isLocked ); // ||
// !caseGroup()->mainCase()->reservoirData()->results(RiaDefines::FRACTURE_MODEL)->resultCount()
m_selectedDynamicProperties.uiCapability()->setUiHidden( isLocked || !( m_porosityModel() == RiaDefines::PorosityModelType::MATRIX_MODEL &&
m_resultType() == RiaDefines::ResultCatType::DYNAMIC_NATIVE ) );
m_selectedStaticProperties.uiCapability()->setUiHidden( isLocked || !( m_porosityModel() == RiaDefines::PorosityModelType::MATRIX_MODEL &&
m_resultType() == RiaDefines::ResultCatType::STATIC_NATIVE ) );
m_selectedGeneratedProperties.uiCapability()->setUiHidden( isLocked || !( m_porosityModel() == RiaDefines::PorosityModelType::MATRIX_MODEL &&
m_resultType() == RiaDefines::ResultCatType::GENERATED ) );
m_selectedInputProperties.uiCapability()->setUiHidden( isLocked || !( m_porosityModel() == RiaDefines::PorosityModelType::MATRIX_MODEL &&
m_resultType() == RiaDefines::ResultCatType::INPUT_PROPERTY ) );
m_selectedDynamicProperties.uiCapability()->setUiHidden( isLocked || m_porosityModel() != RiaDefines::PorosityModelType::MATRIX_MODEL ||
m_resultType() != RiaDefines::ResultCatType::DYNAMIC_NATIVE );
m_selectedStaticProperties.uiCapability()->setUiHidden( isLocked || m_porosityModel() != RiaDefines::PorosityModelType::MATRIX_MODEL ||
m_resultType() != RiaDefines::ResultCatType::STATIC_NATIVE );
m_selectedGeneratedProperties.uiCapability()->setUiHidden( isLocked || m_porosityModel() != RiaDefines::PorosityModelType::MATRIX_MODEL ||
m_resultType() != RiaDefines::ResultCatType::GENERATED );
m_selectedInputProperties.uiCapability()->setUiHidden( isLocked || m_porosityModel() != RiaDefines::PorosityModelType::MATRIX_MODEL ||
m_resultType() != RiaDefines::ResultCatType::INPUT_PROPERTY );
m_selectedFractureDynamicProperties.uiCapability()->setUiHidden( isLocked ||
!( m_porosityModel() == RiaDefines::PorosityModelType::FRACTURE_MODEL &&
m_resultType() == RiaDefines::ResultCatType::DYNAMIC_NATIVE ) );
m_porosityModel() != RiaDefines::PorosityModelType::FRACTURE_MODEL ||
m_resultType() != RiaDefines::ResultCatType::DYNAMIC_NATIVE );
m_selectedFractureStaticProperties.uiCapability()->setUiHidden( isLocked ||
!( m_porosityModel() == RiaDefines::PorosityModelType::FRACTURE_MODEL &&
m_resultType() == RiaDefines::ResultCatType::STATIC_NATIVE ) );
m_selectedFractureGeneratedProperties.uiCapability()->setUiHidden(
isLocked ||
!( m_porosityModel() == RiaDefines::PorosityModelType::FRACTURE_MODEL && m_resultType() == RiaDefines::ResultCatType::GENERATED ) );
m_porosityModel() != RiaDefines::PorosityModelType::FRACTURE_MODEL ||
m_resultType() != RiaDefines::ResultCatType::STATIC_NATIVE );
m_selectedFractureGeneratedProperties.uiCapability()->setUiHidden( isLocked ||
m_porosityModel() != RiaDefines::PorosityModelType::FRACTURE_MODEL ||
m_resultType() != RiaDefines::ResultCatType::GENERATED );
m_selectedFractureInputProperties.uiCapability()->setUiHidden( isLocked ||
!( m_porosityModel() == RiaDefines::PorosityModelType::FRACTURE_MODEL &&
m_resultType() == RiaDefines::ResultCatType::INPUT_PROPERTY ) );
m_porosityModel() != RiaDefines::PorosityModelType::FRACTURE_MODEL ||
m_resultType() != RiaDefines::ResultCatType::INPUT_PROPERTY );
}
//--------------------------------------------------------------------------------------------------
@@ -713,15 +713,8 @@ void RimEclipseStatisticsCase::updatePercentileUiVisibility()
//--------------------------------------------------------------------------------------------------
bool RimEclipseStatisticsCase::hasComputedStatistics() const
{
if ( eclipseCaseData() && ( eclipseCaseData()->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->existingResults().size() ||
eclipseCaseData()->results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->existingResults().size() ) )
{
return true;
}
else
{
return false;
}
return eclipseCaseData() && ( !eclipseCaseData()->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->existingResults().empty() ||
!eclipseCaseData()->results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->existingResults().empty() );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -577,10 +577,7 @@ void RimPlotCurve::checkAndApplyDefaultFillColor()
//--------------------------------------------------------------------------------------------------
bool RimPlotCurve::isCrossPlotCurve() const
{
auto crossPlot = firstAncestorOrThisOfType<RimSummaryCrossPlot>();
if ( crossPlot ) return true;
return false;
return firstAncestorOrThisOfType<RimSummaryCrossPlot>() != nullptr;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -697,7 +697,7 @@ void RimRegularLegendConfig::defineEditorAttribute( const caf::PdmFieldHandle* f
//--------------------------------------------------------------------------------------------------
void RimRegularLegendConfig::updateFieldVisibility()
{
bool showRangeItems = m_mappingMode == MappingType::CATEGORY_INTEGER ? false : true;
bool showRangeItems = m_mappingMode != MappingType::CATEGORY_INTEGER;
m_numLevels.uiCapability()->setUiHidden( !showRangeItems );
m_precision.uiCapability()->setUiHidden( !showRangeItems );

View File

@@ -266,14 +266,7 @@ void RimSimWellInViewCollection::setShowWellCellsState( bool enable )
//--------------------------------------------------------------------------------------------------
bool RimSimWellInViewCollection::showWellCells()
{
if ( m_showWellCells().isFalse() )
{
return false;
}
else
{
return true;
}
return !m_showWellCells().isFalse();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -1133,10 +1133,5 @@ bool RimViewController::askUserToRestoreOriginalCellFilterCollection( const QStr
msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No );
int ret = msgBox.exec();
if ( ret == QMessageBox::Yes )
{
return false;
}
return true;
return ret != QMessageBox::Yes;
}

View File

@@ -176,10 +176,5 @@ bool RimViewManipulator::isBoundingBoxesOverlappingOrClose( const cvf::BoundingB
}
double centerDist = ( sourceBB.center() - destBB.center() ).length();
if ( centerDist < largestExtent * 5 )
{
return true;
}
return false;
return centerDist < largestExtent * 5;
}

View File

@@ -185,12 +185,7 @@ void RimViewWindow::revokeMdiWindowStatus()
//--------------------------------------------------------------------------------------------------
bool RimViewWindow::isMdiWindow() const
{
if ( m_windowController() )
{
return true;
}
return false;
return m_windowController() != nullptr;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -378,11 +378,7 @@ void RimWbsParameters::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
//--------------------------------------------------------------------------------------------------
bool RimWbsParameters::hasLasFileWithChannel( const QString& channel ) const
{
if ( m_wellPath && !RimWellLogFile::findMdAndChannelValuesForWellPath( m_wellPath, channel ).empty() )
{
return true;
}
return false;
return m_wellPath && !RimWellLogFile::findMdAndChannelValuesForWellPath( m_wellPath, channel ).empty();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -651,8 +651,8 @@ void RimEnsembleCurveFilter::updateMaxMinAndDefaultValues( bool forceDefault )
if ( RiaCurveDataTools::isValidValue( eParam.minValue, false ) ) m_lowerLimit = eParam.minValue;
if ( RiaCurveDataTools::isValidValue( eParam.maxValue, false ) ) m_upperLimit = eParam.maxValue;
if ( forceDefault || !( m_minValue >= m_lowerLimit && m_minValue <= m_upperLimit ) ) m_minValue = m_lowerLimit;
if ( forceDefault || !( m_maxValue >= m_lowerLimit && m_maxValue <= m_upperLimit ) ) m_maxValue = m_upperLimit;
if ( forceDefault || m_minValue < m_lowerLimit || m_minValue > m_upperLimit ) m_minValue = m_lowerLimit;
if ( forceDefault || m_maxValue < m_lowerLimit || m_maxValue > m_upperLimit ) m_maxValue = m_upperLimit;
m_minValue.uiCapability()->setUiName( QString( "Min (%1)" ).arg( m_lowerLimit ) );
m_maxValue.uiCapability()->setUiName( QString( "Max (%1)" ).arg( m_upperLimit ) );
@@ -675,8 +675,8 @@ void RimEnsembleCurveFilter::updateMaxMinAndDefaultValues( bool forceDefault )
m_lowerLimit = minObjValue;
m_upperLimit = maxObjValue;
if ( forceDefault || !( m_minValue >= m_lowerLimit && m_minValue <= m_upperLimit ) ) m_minValue = m_lowerLimit;
if ( forceDefault || !( m_maxValue >= m_lowerLimit && m_maxValue <= m_upperLimit ) ) m_maxValue = m_upperLimit;
if ( forceDefault || m_minValue < m_lowerLimit || m_minValue > m_upperLimit ) m_minValue = m_lowerLimit;
if ( forceDefault || m_maxValue < m_lowerLimit || m_maxValue > m_upperLimit ) m_maxValue = m_upperLimit;
m_minValue.uiCapability()->setUiName( QString( "Min (%1)" ).arg( m_lowerLimit ) );
m_maxValue.uiCapability()->setUiName( QString( "Max (%1)" ).arg( m_upperLimit ) );
@@ -691,8 +691,8 @@ void RimEnsembleCurveFilter::updateMaxMinAndDefaultValues( bool forceDefault )
m_lowerLimit = minMaxValues.first;
m_upperLimit = minMaxValues.second;
if ( forceDefault || !( m_minValue >= m_lowerLimit && m_minValue <= m_upperLimit ) ) m_minValue = m_lowerLimit;
if ( forceDefault || !( m_maxValue >= m_lowerLimit && m_maxValue <= m_upperLimit ) ) m_maxValue = m_upperLimit;
if ( forceDefault || m_minValue < m_lowerLimit || m_minValue > m_upperLimit ) m_minValue = m_lowerLimit;
if ( forceDefault || m_maxValue < m_lowerLimit || m_maxValue > m_upperLimit ) m_maxValue = m_upperLimit;
m_minValue.uiCapability()->setUiName( QString( "Min (%1)" ).arg( m_lowerLimit ) );
m_maxValue.uiCapability()->setUiName( QString( "Max (%1)" ).arg( m_upperLimit ) );

View File

@@ -57,9 +57,7 @@ bool RimMultiSummaryPlotNameHelper::isPlotDisplayingSingleVectorName() const
if ( nameHelper->isPlotDisplayingSingleVectorName() ) plotCountWithSingleQuantity++;
}
if ( plotCountWithSingleQuantity == 1 ) return true;
return false;
return plotCountWithSingleQuantity == 1;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -423,13 +423,8 @@ bool RimSummaryAddressCollection::isEnsemble() const
//--------------------------------------------------------------------------------------------------
bool RimSummaryAddressCollection::isFolder() const
{
if ( contentType() == CollectionContentType::WELL_FOLDER || contentType() == CollectionContentType::GROUP_FOLDER ||
contentType() == CollectionContentType::REGION_FOLDER )
{
return true;
}
return false;
return contentType() == CollectionContentType::WELL_FOLDER || contentType() == CollectionContentType::GROUP_FOLDER ||
contentType() == CollectionContentType::REGION_FOLDER;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -56,12 +56,7 @@ void caf::AppEnum<RimSummaryCurveAppearanceCalculator::CurveAppearanceType>::set
//--------------------------------------------------------------------------------------------------
bool isExcplicitHandled( char secondChar )
{
if ( secondChar == 'W' || secondChar == 'O' || secondChar == 'G' || secondChar == 'V' )
{
return true;
}
return false;
return secondChar == 'W' || secondChar == 'O' || secondChar == 'G' || secondChar == 'V';
}
//--------------------------------------------------------------------------------------------------

View File

@@ -187,7 +187,5 @@ bool RimFileSurface::loadDataFromFile()
m_vertices = surface.first;
m_tringleIndices = surface.second;
if ( m_vertices.empty() || m_tringleIndices.empty() ) return false;
return true;
return !( m_vertices.empty() || m_tringleIndices.empty() );
}

View File

@@ -445,7 +445,7 @@ void RimWellLogCurveCommonDataSource::analyseCurvesAndTracks( const std::vector<
}
if ( m_uniqueBranchDetection.size() == 1u )
{
setBranchDetectionToApply( *m_uniqueBranchDetection.begin() == true ? caf::Tristate::State::True : caf::Tristate::State::False );
setBranchDetectionToApply( *m_uniqueBranchDetection.begin() ? caf::Tristate::State::True : caf::Tristate::State::False );
}
if ( m_uniqueWellNames.size() == 1u )
{
@@ -460,7 +460,7 @@ void RimWellLogCurveCommonDataSource::analyseCurvesAndTracks( const std::vector<
if ( m_uniqueWbsSmoothing.size() == 1u )
{
setWbsSmoothingToApply( *m_uniqueWbsSmoothing.begin() == true ? caf::Tristate::State::True : caf::Tristate::State::False );
setWbsSmoothingToApply( *m_uniqueWbsSmoothing.begin() ? caf::Tristate::State::True : caf::Tristate::State::False );
}
if ( m_uniqueWbsSmoothingThreshold.size() == 1u )

View File

@@ -1337,12 +1337,7 @@ bool RimWellLogExtractionCurve::branchDetection() const
bool RimWellLogExtractionCurve::isEclipseCurve() const
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( m_case.value() );
if ( eclipseCase )
{
return true;
}
return false;
return eclipseCase != nullptr;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -2878,9 +2878,9 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
{
if ( m_formationWellPathForSourceWellPath == nullptr ) return;
if ( !( plot->depthType() == RiaDefines::DepthTypeEnum::MEASURED_DEPTH ||
plot->depthType() == RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH ||
plot->depthType() == RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB ) )
if ( plot->depthType() != RiaDefines::DepthTypeEnum::MEASURED_DEPTH &&
plot->depthType() != RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH &&
plot->depthType() != RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB )
{
return;
}

View File

@@ -993,12 +993,7 @@ bool RimWellPath::reloadWellPathFormationsFile( QString* errorMessage, RifWellPa
//--------------------------------------------------------------------------------------------------
bool RimWellPath::hasFormations() const
{
if ( m_wellPathFormations.isNull() )
{
return false;
}
return true;
return !m_wellPathFormations.isNull();
}
//--------------------------------------------------------------------------------------------------