Skip to content

Commit

Permalink
Fixes by clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Sep 2, 2024
1 parent 4a2e730 commit fc2106e
Show file tree
Hide file tree
Showing 33 changed files with 115 additions and 85 deletions.
4 changes: 2 additions & 2 deletions ApplicationLibCode/Application/Tools/RiaFilePathTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void addToPathTree( PathNode* node, QStringList pathComponents, const QString& f
}
}

node->children.push_back( std::unique_ptr<PathNode>( new PathNode( pathComponent, node ) ) );
node->children.push_back( std::make_unique<PathNode>( pathComponent, node ) );
addToPathTree( node->children.back().get(), pathComponents, fileName );
}
else
Expand Down Expand Up @@ -335,7 +335,7 @@ std::map<QString, QStringList> RiaFilePathTools::keyPathComponentsForEachFilePat
allComponents[fileName] = pathComponentsForFile;
}

auto topNode = std::unique_ptr<PathNode>( new PathNode( "", nullptr ) );
auto topNode = std::make_unique<PathNode>( "", nullptr );

for ( auto keyComponentsPair : allComponents )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ QFilePtr RicExportSelectedWellPathsFeature::openFileForExport( const QString& fo
//--------------------------------------------------------------------------------------------------
QTextStreamPtr RicExportSelectedWellPathsFeature::createOutputFileStream( QFile& file )
{
auto stream = QTextStreamPtr( new QTextStream( &file ) );
auto stream = std::make_shared<QTextStream>( &file );
stream->setRealNumberNotation( QTextStream::FixedNotation );
stream->setRealNumberPrecision( 2 );
return stream;
Expand Down
4 changes: 3 additions & 1 deletion ApplicationLibCode/Commands/RicGridCalculatorDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include "RicGridCalculatorDialog.h"

#include <memory>

#include "RicCalculatorWidgetCreator.h"
#include "RicGridCalculatorUi.h"

Expand Down Expand Up @@ -75,7 +77,7 @@ QWidget* RicGridCalculatorDialog::getCalculatorWidget()
{
if ( !m_calcEditor )
{
m_calcEditor = std::unique_ptr<RicCalculatorWidgetCreator>( new RicCalculatorWidgetCreator( std::make_unique<RicGridCalculatorUi>() ) );
m_calcEditor = std::make_unique<RicCalculatorWidgetCreator>( std::make_unique<RicGridCalculatorUi>() );
}

return m_calcEditor->getOrCreateWidget( this );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include "RicSummaryCurveCalculatorDialog.h"

#include <memory>

#include "RicCalculatorWidgetCreator.h"
#include "RicSummaryCurveCalculatorUi.h"

Expand Down Expand Up @@ -75,8 +77,7 @@ QWidget* RicSummaryCurveCalculatorDialog::getCalculatorWidget()
{
if ( !m_summaryCalcEditor )
{
m_summaryCalcEditor =
std::unique_ptr<RicCalculatorWidgetCreator>( new RicCalculatorWidgetCreator( std::make_unique<RicSummaryCurveCalculatorUi>() ) );
m_summaryCalcEditor = std::make_unique<RicCalculatorWidgetCreator>( std::make_unique<RicSummaryCurveCalculatorUi>() );
}

return m_summaryCalcEditor->getOrCreateWidget( this );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <QFrame>
#include <QSplitter>
#include <QTreeView>
#include <memory>

//--------------------------------------------------------------------------------------------------
///
Expand All @@ -46,7 +47,7 @@ RicSummaryPlotEditorWidgetCreator::RicSummaryPlotEditorWidgetCreator( QWidget* p
{
m_parentWidget = parent;

m_summaryCurveCreator.reset( new RicSummaryPlotEditorUi() );
m_summaryCurveCreator = std::make_unique<RicSummaryPlotEditorUi>();

setPdmObject( m_summaryCurveCreator.get() );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
#include <QStringList>

#include <functional>
#include <memory>

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifCaseRealizationReader::RifCaseRealizationReader( const QString& fileName )
{
m_parameters = std::shared_ptr<RigCaseRealizationParameters>( new RigCaseRealizationParameters() );
m_parameters = std::make_shared<RigCaseRealizationParameters>();
m_fileName = fileName;
}

Expand Down
3 changes: 2 additions & 1 deletion ApplicationLibCode/FileInterface/RifColumnBasedUserData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <QDateTime>
#include <QFile>
#include <QTextStream>
#include <memory>

//--------------------------------------------------------------------------------------------------
///
Expand All @@ -56,7 +57,7 @@ bool RifColumnBasedUserData::parse( const QString& data, QString* errorText )
m_mapFromAddressToTimeStepIndex.clear();
m_mapFromAddressToResultIndex.clear();

m_parser = std::unique_ptr<RifColumnBasedUserDataParser>( new RifColumnBasedUserDataParser( data, errorText ) );
m_parser = std::make_unique<RifColumnBasedUserDataParser>( data, errorText );
if ( !m_parser )
{
RiaLogging::error( QString( "Failed to parse file" ) );
Expand Down
3 changes: 2 additions & 1 deletion ApplicationLibCode/FileInterface/RifCsvUserData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <QDateTime>
#include <QFile>
#include <QTextStream>
#include <memory>

//--------------------------------------------------------------------------------------------------
///
Expand All @@ -54,7 +55,7 @@ bool RifCsvUserData::parse( const QString& fileName, const RifAsciiDataParseOpti
m_allResultAddresses.clear();
m_mapFromAddressToResultIndex.clear();

m_parser = std::unique_ptr<RifCsvUserDataFileParser>( new RifCsvUserDataFileParser( fileName, errorText ) );
m_parser = std::make_unique<RifCsvUserDataFileParser>( fileName, errorText );
if ( !m_parser->parse( parseOptions ) )
{
RiaLogging::error( QString( "Failed to parse file" ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <QFile>
#include <QStringList>
#include <QTextStream>
#include <memory>

//--------------------------------------------------------------------------------------------------
///
Expand All @@ -54,7 +55,7 @@ bool RifKeywordVectorUserData::parse( const QString& data, const QString& custom
m_allResultAddresses.clear();
m_timeSteps.clear();

m_parser = std::unique_ptr<RifKeywordVectorParser>( new RifKeywordVectorParser( data ) );
m_parser = std::make_unique<RifKeywordVectorParser>( data );
if ( !m_parser )
{
RiaLogging::error( QString( "Failed to parse file" ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <QDateTime>
#include <QFile>
#include <QTextStream>
#include <memory>

//--------------------------------------------------------------------------------------------------
///
Expand Down Expand Up @@ -68,7 +69,7 @@ bool RifRevealCsvSectionSummaryReader::parse( const QString&
parseOptions.timeSeriesColumnName = "Date";
parseOptions.defaultCategory = defaultCategory;

m_parser = std::unique_ptr<RifCsvUserDataPastedTextParser>( new RifCsvUserDataPastedTextParser( text, errorText ) );
m_parser = std::make_unique<RifCsvUserDataPastedTextParser>( text, errorText );
std::map<QString, std::pair<QString, double>> unitMapping = { { "Sm3", { "SM3", 1.0 } },
{ "Sm3/day", { "SM3/DAY", 1.0 } },
{ "Sm3/day/bar", { "SM3/DAY/BAR", 1.0 } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <QDateTime>
#include <QFile>
#include <QTextStream>
#include <memory>

//--------------------------------------------------------------------------------------------------
///
Expand Down Expand Up @@ -76,7 +77,7 @@ std::pair<bool, QString> RifStimPlanCsvSummaryReader::parse( const QString& file
parseOptions.timeSeriesColumnName = "Time";
parseOptions.startDateTime = startDateTime;

m_parser = std::unique_ptr<RifCsvUserDataPastedTextParser>( new RifCsvUserDataPastedTextParser( fileContents, errorText ) );
m_parser = std::make_unique<RifCsvUserDataPastedTextParser>( fileContents, errorText );

if ( !m_parser->parse( parseOptions ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <chrono>
#include <cmath>
#include <cstdlib>
#include <memory>
#include <random>

CAF_PDM_SOURCE_INIT( RimFishbones, "FishbonesMultipleSubs" );
Expand Down Expand Up @@ -126,7 +127,7 @@ RimFishbones::RimFishbones()

m_pipeProperties = new RimFishbonesPipeProperties;

m_rigFishbonesGeometry = std::unique_ptr<RigFisbonesGeometry>( new RigFisbonesGeometry( this ) );
m_rigFishbonesGeometry = std::make_unique<RigFisbonesGeometry>( this );
setDeletable( true );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include "RimWellAllocationPlot.h"

#include <memory>

#include "RiaNumericalTools.h"
#include "RiaPlotDefines.h"
#include "RiaPreferences.h"
Expand Down Expand Up @@ -332,18 +334,18 @@ void RimWellAllocationPlot::updateFromWell()
RigEclCellIndexCalculator cellIdxCalc( m_case->eclipseCaseData()->mainGrid(),
m_case->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ),
nullptr );
wfCalculator.reset( new RigAccWellFlowCalculator( pipeBranchesCLCoords,
pipeBranchesCellIds,
tracerFractionCellValues,
cellIdxCalc,
smallContributionThreshold,
isProducer ) );
wfCalculator = std::make_unique<RigAccWellFlowCalculator>( pipeBranchesCLCoords,
pipeBranchesCellIds,
tracerFractionCellValues,
cellIdxCalc,
smallContributionThreshold,
isProducer );
}
else
{
if ( !pipeBranchesCLCoords.empty() )
{
wfCalculator.reset( new RigAccWellFlowCalculator( pipeBranchesCLCoords, pipeBranchesCellIds, smallContributionThreshold ) );
wfCalculator = std::make_unique<RigAccWellFlowCalculator>( pipeBranchesCLCoords, pipeBranchesCellIds, smallContributionThreshold );
}
}

Expand Down
5 changes: 3 additions & 2 deletions ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

#include <algorithm>
#include <iterator>
#include <memory>
#include <tuple>

CAF_PDM_SOURCE_INIT( RimWellPltPlot, "WellPltPlot" );
Expand Down Expand Up @@ -507,11 +508,11 @@ void RimWellPltPlot::syncCurvesFromUiSelection()

if ( sourceDef.sourceType() == RifDataSourceForRftPlt::SourceType::RFT_SIM_WELL_DATA )
{
resultPointCalc.reset( new RigRftResultPointCalculator( m_wellPathName, rimEclipseResultCase, timeStep ) );
resultPointCalc = std::make_unique<RigRftResultPointCalculator>( m_wellPathName, rimEclipseResultCase, timeStep );
}
else if ( sourceDef.sourceType() == RifDataSourceForRftPlt::SourceType::GRID_MODEL_CELL_DATA )
{
resultPointCalc.reset( new RigSimWellResultPointCalculator( m_wellPathName, rimEclipseResultCase, timeStep ) );
resultPointCalc = std::make_unique<RigSimWellResultPointCalculator>( m_wellPathName, rimEclipseResultCase, timeStep );
}

RiaDefines::EclipseUnitSystem unitSet = RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include "caf.h"

#include <QLocale>
#include <memory>

CAF_PDM_SOURCE_INIT( Rim3dOverlayInfoConfig, "View3dOverlayInfoConfig" );
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -98,7 +99,7 @@ Rim3dOverlayInfoConfig::Rim3dOverlayInfoConfig()
RimHistogramCalculator::StatisticsCellRangeType::VISIBLE_CELLS;
CAF_PDM_InitField( &m_statisticsCellRange, "StatisticsCellRange", defaultCellRange, "Statistics Cell Range" );

m_histogramCalculator.reset( new RimHistogramCalculator );
m_histogramCalculator = std::make_unique<RimHistogramCalculator>();
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -240,7 +241,7 @@ RicGridStatisticsDialog* Rim3dOverlayInfoConfig::getOrCreateGridStatisticsDialog
{
if ( !m_gridStatisticsDialog )
{
m_gridStatisticsDialog.reset( new RicGridStatisticsDialog( nullptr ) );
m_gridStatisticsDialog = std::make_unique<RicGridStatisticsDialog>( nullptr );
}
CVF_ASSERT( m_gridStatisticsDialog );
return m_gridStatisticsDialog.get();
Expand Down
30 changes: 15 additions & 15 deletions ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include "RimGridTimeHistoryCurve.h"

#include <memory>

#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
#include "RigFemResultAddress.h"
Expand Down Expand Up @@ -714,24 +716,22 @@ std::unique_ptr<RiuFemTimeHistoryResultAccessor> RimGridTimeHistoryCurve::femTim
intersectionTriangle[1] = cvf::Vec3f( geoMechTopItem->m_intersectionTriangle_1() );
intersectionTriangle[2] = cvf::Vec3f( geoMechTopItem->m_intersectionTriangle_2() );

timeHistResultAccessor = std::unique_ptr<RiuFemTimeHistoryResultAccessor>(
new RiuFemTimeHistoryResultAccessor( geoMechTopItem->geoMechCase()->geoMechData(),
m_geoMechResultDefinition()->resultAddress(),
geoMechTopItem->m_gridIndex,
static_cast<int>( geoMechTopItem->m_cellIndex ),
geoMechTopItem->m_elementFace,
geoMechTopItem->m_localIntersectionPoint,
intersectionTriangle ) );
timeHistResultAccessor = std::make_unique<RiuFemTimeHistoryResultAccessor>( geoMechTopItem->geoMechCase()->geoMechData(),
m_geoMechResultDefinition()->resultAddress(),
geoMechTopItem->m_gridIndex,
static_cast<int>( geoMechTopItem->m_cellIndex ),
geoMechTopItem->m_elementFace,
geoMechTopItem->m_localIntersectionPoint,
intersectionTriangle );
}
else
{
timeHistResultAccessor = std::unique_ptr<RiuFemTimeHistoryResultAccessor>(
new RiuFemTimeHistoryResultAccessor( geoMechTopItem->geoMechCase()->geoMechData(),
m_geoMechResultDefinition()->resultAddress(),
geoMechTopItem->m_gridIndex,
static_cast<int>( geoMechTopItem->m_cellIndex ),
geoMechTopItem->m_elementFace,
geoMechTopItem->m_localIntersectionPoint ) );
timeHistResultAccessor = std::make_unique<RiuFemTimeHistoryResultAccessor>( geoMechTopItem->geoMechCase()->geoMechData(),
m_geoMechResultDefinition()->resultAddress(),
geoMechTopItem->m_gridIndex,
static_cast<int>( geoMechTopItem->m_cellIndex ),
geoMechTopItem->m_elementFace,
geoMechTopItem->m_localIntersectionPoint );
}
}

Expand Down
3 changes: 2 additions & 1 deletion ApplicationLibCode/ProjectDataModel/RimProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
#include <QMenu>

#include <algorithm>
#include <memory>

CAF_PDM_SOURCE_INIT( RimProject, "ResInsightProject" );
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1545,7 +1546,7 @@ QString RimProject::updatedFilePathFromPathId( QString filePath, RiaVariableMapp

if ( pathListMapper == nullptr )
{
internalMapper.reset( new RiaVariableMapper( m_globalPathList ) );
internalMapper = std::make_unique<RiaVariableMapper>( m_globalPathList );
pathListMapper = internalMapper.get();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "cafPdmUiTextEditor.h"

#include <algorithm>
#include <memory>

CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimUserDefinedCalculation, "RimUserDefinedCalculation" );

Expand Down Expand Up @@ -77,7 +78,7 @@ RimUserDefinedCalculation::RimUserDefinedCalculation()
CAF_PDM_InitField( &m_id, "Id", -1, "Id" );
m_id.uiCapability()->setUiHidden( true );

m_exprContextMenuMgr = std::unique_ptr<RiuExpressionContextMenuManager>( new RiuExpressionContextMenuManager() );
m_exprContextMenuMgr = std::make_unique<RiuExpressionContextMenuManager>();

m_isDirty = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

#include <cmath>
#include <limits>
#include <memory>

CAF_PDM_SOURCE_INIT( RimStimPlanModel, "StimPlanModel" );

Expand Down Expand Up @@ -240,7 +241,7 @@ RimStimPlanModel::RimStimPlanModel()

CAF_PDM_InitScriptableFieldNoDefault( &m_perforationInterval, "PerforationInterval", "Perforation Interval" );

m_calculator = std::shared_ptr<RimStimPlanModelCalculator>( new RimStimPlanModelCalculator );
m_calculator = std::make_shared<RimStimPlanModelCalculator>();
m_calculator->setStimPlanModel( this );

setDeletable( true );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <QDateTime>

#include <algorithm>
#include <memory>

namespace caf
{
Expand Down Expand Up @@ -297,7 +298,7 @@ void RimDerivedSummaryCase::createSummaryReaderInterface()
summaryCase1Reader2 = m_summaryCase2->summaryReader();
}

m_reader.reset( new RifDerivedEnsembleReader( this, summaryCase1Reader1, summaryCase1Reader2 ) );
m_reader = std::make_unique<RifDerivedEnsembleReader>( this, summaryCase1Reader1, summaryCase1Reader2 );
}

//--------------------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit fc2106e

Please sign in to comment.