From 6c0a8660086c87203136dd91281604dea6354a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 6 Mar 2017 11:18:57 +0100 Subject: [PATCH] #1292 Fixed CppCheck Issues in ProjectDataModel --- .../ProjectDataModel/Flow/RimFlowDiagSolution.cpp | 2 +- .../ProjectDataModel/Flow/RimWellAllocationPlot.cpp | 6 ++---- .../ProjectDataModel/RimCellRangeFilterCollection.cpp | 4 +--- ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp | 3 +-- ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp | 3 +-- ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp | 4 ++-- .../ProjectDataModel/RimMultiSnapshotDefinition.cpp | 2 -- .../Summary/RimSummaryCurveAppearanceCalculator.cpp | 2 +- .../Summary/RimSummaryCurveAppearanceCalculator.h | 2 +- .../ProjectDataModel/Summary/RimSummaryCurveFilter.cpp | 3 --- 10 files changed, 10 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp b/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp index 730c0d2c93..b6a3ae333e 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp @@ -70,7 +70,7 @@ RigFlowDiagResults* RimFlowDiagSolution::flowDiagResults() RimEclipseResultCase* eclCase; this->firstAncestorOrThisOfType(eclCase); - CVF_ASSERT(eclCase && eclCase->reservoirData() && eclCase->reservoirData() ); + CVF_ASSERT(eclCase && eclCase->reservoirData() ); timeStepCount = eclCase->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount(); diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index dbeca32ca9..28b644690c 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -180,8 +180,7 @@ void RimWellAllocationPlot::updateFromWell() if (!m_case) return; - const RigSingleWellResultsData* wellResults = nullptr; - wellResults = m_case->reservoirData()->findWellResult(m_wellName); + const RigSingleWellResultsData* wellResults = m_case->reservoirData()->findWellResult(m_wellName); if (!wellResults) return; @@ -450,8 +449,7 @@ QString RimWellAllocationPlot::wellStatusTextForTimeStep(const QString& wellName if (eclipseResultCase) { - const RigSingleWellResultsData* wellResults = nullptr; - wellResults = eclipseResultCase->reservoirData()->findWellResult(wellName); + const RigSingleWellResultsData* wellResults = eclipseResultCase->reservoirData()->findWellResult(wellName); if (wellResults) { diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp index 7daeccb9e3..d90db14c38 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp @@ -224,9 +224,7 @@ const cvf::StructGridInterface* RimCellRangeFilterCollection::gridByIndex(int gr if (mnGrid) { - RigGridBase* grid = NULL; - - grid = mnGrid->gridByIndex(gridIndex); + RigGridBase* grid = mnGrid->gridByIndex(gridIndex); CVF_ASSERT(grid); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp index ee626840e3..f4d09fbd6b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -118,8 +118,6 @@ void RimEclipseCellColors::changeLegendConfig(QString resultVarNameOfNewLegend) { if (resultVarNameOfNewLegend != RimDefines::ternarySaturationResultName()) { - bool found = false; - QString legendResultVariable; if (this->m_legendConfigPtrField()) @@ -129,6 +127,7 @@ void RimEclipseCellColors::changeLegendConfig(QString resultVarNameOfNewLegend) if (!this->m_legendConfigPtrField() || legendResultVariable != resultVarNameOfNewLegend) { + bool found = false; for (size_t i = 0; i < m_legendConfigData.size(); i++) { if (m_legendConfigData[i]->resultVariableName() == resultVarNameOfNewLegend) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp index daf8892417..5cb59f758a 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp @@ -248,11 +248,10 @@ void RimEclipseInputCase::loadAndSyncronizeInputProperties() size_t inputPropCount = this->m_inputPropertyCollection()->inputProperties.size(); caf::ProgressInfo progInfo(static_cast(filenames.size() * inputPropCount), "Reading Input properties" ); - int progress = 0; for_all(filenames, i) { - progress = static_cast(i*inputPropCount); + int progress = static_cast(i*inputPropCount); // Find all the keywords present on the file progInfo.setProgressDescription(filenames[i]); diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp index bcb8752602..936d5e8d1d 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp @@ -632,7 +632,7 @@ cvf::BoundingBox RimIntersectionBox::currentCellBoundingBox() this->firstAncestorOrThisOfType(rimCase); CVF_ASSERT(rimCase); - + /* RimEclipseView* eclView = nullptr; this->firstAncestorOrThisOfType(eclView); @@ -644,7 +644,7 @@ cvf::BoundingBox RimIntersectionBox::currentCellBoundingBox() if(false)//useAllCells) // For now, only use the active CellsBBox. return rimCase->allCellsBoundingBox(); - else + else */ return rimCase->activeCellsBoundingBox(); } diff --git a/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.cpp b/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.cpp index 5bcc108e65..a01b2d574d 100644 --- a/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.cpp @@ -88,8 +88,6 @@ QList RimMultiSnapshotDefinition::calculateValueOptions( { QList options; - RimProject* proj = RiaApplication::instance()->project(); - if (fieldNeedingOptions == &view) { options.push_back(caf::PdmOptionItemInfo("None", nullptr)); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp index 32d51e4131..746b1a0c22 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp @@ -343,7 +343,7 @@ int RimSummaryCurveAppearanceCalculator::cycledLineThickness(int index) static const int thicknesses[] ={ 1, 3, 5 }; if (index < 0) return 1; - return (thicknesses[(index) % 3]); + return (thicknesses[(index) % thicknessCount]); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h index 356023938c..ff291b095a 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h @@ -31,7 +31,7 @@ class RifEclipseSummaryAddress; class RimSummaryCurveAppearanceCalculator { public: - RimSummaryCurveAppearanceCalculator(const std::set >& curveDefinitions); + explicit RimSummaryCurveAppearanceCalculator(const std::set >& curveDefinitions); enum CurveAppearanceType { NONE, diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveFilter.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveFilter.cpp index 00eae82c10..83b1d4e540 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveFilter.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveFilter.cpp @@ -513,9 +513,6 @@ void RimSummaryCurveFilter::createSetOfCasesAndResultAdresses( //-------------------------------------------------------------------------------------------------- void RimSummaryCurveFilter::createCurvesFromCurveDefinitions(const std::set >& curveDefinitions) { - int colorIndex = 2; - int lineStyleIdx = -1; - RimSummaryCase* prevCase = nullptr; RimPlotCurve::LineStyleEnum lineStyle = RimPlotCurve::STYLE_SOLID; RimSummaryCurveAppearanceCalculator curveLookCalc(curveDefinitions);