Skip to content

Commit bcd9071

Browse files
committedNov 11, 2017
Run clang-tidy code readability fixits
1 parent c97fa5b commit bcd9071

19 files changed

+31
-72
lines changed
 

‎src/analysis/vector/geometry_checker/qgsgeometryareacheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ bool QgsGeometryAreaCheck::mergeWithNeighbor( const QString &layerId, QgsFeature
173173

174174
if ( !matchFound && maxVal == 0. )
175175
{
176-
return method == MergeIdenticalAttribute ? true : false;
176+
return method == MergeIdenticalAttribute;
177177
}
178178

179179
// Merge geometries

‎src/analysis/vector/geometry_checker/qgsgeometrycheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ bool QgsGeometryCheckError::handleChanges( const QgsGeometryCheck::Changes &chan
9797
// If the check is checking the feature at geometry nodes level, the
9898
// error almost certainly invalid after a geometry change. In the other
9999
// cases, it might likely still be valid.
100-
return mCheck->getCheckType() == QgsGeometryCheck::FeatureNodeCheck ? false : true;
100+
return mCheck->getCheckType() != QgsGeometryCheck::FeatureNodeCheck;
101101
}
102102
}
103103
else if ( change.what == QgsGeometryCheck::ChangePart )

‎src/analysis/vector/geometry_checker/qgsgeometrypointcoveredbylinecheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ void QgsGeometryPointCoveredByLineCheck::collectErrors( QList<QgsGeometryCheckEr
5353
break;
5454
}
5555
}
56-
if ( touches == true )
56+
if ( touches )
5757
{
5858
break;
5959
}
6060
}
61-
if ( touches == true )
61+
if ( touches )
6262
{
6363
continue;
6464
}

‎src/app/qgsmaptooldeletepart.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ void QgsMapToolDeletePart::canvasReleaseEvent( QgsMapMouseEvent *e )
112112
{
113113
emit messageEmitted( tr( "Couldn't remove the selected part." ) );
114114
}
115-
return;
116115
}
117116

118117
QgsGeometry QgsMapToolDeletePart::partUnderPoint( QPoint point, QgsFeatureId &fid, int &partNum )

‎src/app/qgswelcomepageitemsmodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void QgsWelcomePageItemDelegate::paint( QPainter *painter, const QStyleOptionVie
7777

7878
doc.setHtml( QStringLiteral( "<div style='font-size:%1px;'><span style='font-size:%2px;font-weight:bold;'>%3%4</span><br>%5<br>%6</div>" ).arg( textSize ).arg( titleSize )
7979
.arg( index.data( QgsWelcomePageItemsModel::TitleRole ).toString(),
80-
index.data( QgsWelcomePageItemsModel::PinRole ).toBool() == true ? QStringLiteral( "<img src=\"qrc:/images/themes/default/pin.svg\">" ) : QString(),
80+
index.data( QgsWelcomePageItemsModel::PinRole ).toBool() ? QStringLiteral( "<img src=\"qrc:/images/themes/default/pin.svg\">" ) : QString(),
8181
index.data( QgsWelcomePageItemsModel::NativePathRole ).toString(),
8282
index.data( QgsWelcomePageItemsModel::CrsRole ).toString() ) );
8383
doc.setTextWidth( option.rect.width() - ( !icon.isNull() ? icon.width() + 35 : 35 ) );
@@ -114,7 +114,7 @@ QSize QgsWelcomePageItemDelegate::sizeHint( const QStyleOptionViewItem &option,
114114

115115
doc.setHtml( QStringLiteral( "<div style='font-size:%1px;'><span style='font-size:%2px;font-weight:bold;'>%3%4</span><br>%5<br>%6</div>" ).arg( textSize ).arg( titleSize )
116116
.arg( index.data( QgsWelcomePageItemsModel::TitleRole ).toString(),
117-
index.data( QgsWelcomePageItemsModel::PinRole ).toBool() == true ? QStringLiteral( "<img src=\"qrc:/images/themes/default/pin.svg\">" ) : QString(),
117+
index.data( QgsWelcomePageItemsModel::PinRole ).toBool() ? QStringLiteral( "<img src=\"qrc:/images/themes/default/pin.svg\">" ) : QString(),
118118
index.data( QgsWelcomePageItemsModel::NativePathRole ).toString(),
119119
index.data( QgsWelcomePageItemsModel::CrsRole ).toString() ) );
120120
doc.setTextWidth( width - ( !icon.isNull() ? icon.width() + 35 : 35 ) );

‎src/core/pal/rtree.hpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,7 @@ namespace pal
389389
fclose( m_file );
390390

391391
m_file = fopen( a_fileName, "rb" );
392-
if ( !m_file )
393-
{
394-
return false;
395-
}
396-
return true;
392+
return m_file != nullptr;
397393
}
398394

399395
bool OpenWrite( const char *a_fileName )
@@ -402,11 +398,7 @@ namespace pal
402398
fclose( m_file );
403399

404400
m_file = fopen( a_fileName, "wb" );
405-
if ( !m_file )
406-
{
407-
return false;
408-
}
409-
return true;
401+
return m_file != nullptr;
410402
}
411403

412404
void Close()

‎src/core/qgsproject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,7 @@ QList<QgsMapLayer *> QgsProject::addMapLayers(
22622262
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( mlayer );
22632263
if ( vl )
22642264
{
2265-
vl->loadAuxiliaryLayer( *mAuxiliaryStorage.get() );
2265+
vl->loadAuxiliaryLayer( *mAuxiliaryStorage );
22662266
}
22672267
}
22682268
}

‎src/core/qgsvectorlayerjoinbuffer.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,5 @@ bool QgsVectorLayerJoinBuffer::isAuxiliaryJoin( const QgsVectorLayerJoinInfo &in
667667
{
668668
const QgsAuxiliaryLayer *al = mLayer->auxiliaryLayer();
669669

670-
if ( al && al->id() == info.joinLayerId() )
671-
return true;
672-
else
673-
return false;
670+
return al && al->id() == info.joinLayerId();
674671
}

‎src/gui/qgsmetadatawidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ bool QgsMetadataWidget::checkMetadata() const
508508
bool results = validator.validate( metadata, validationResults );
509509

510510
QString errors;
511-
if ( results == false )
511+
if ( !results )
512512
{
513513
for ( const QgsMetadataValidator::ValidationResult &result : qgis::as_const( validationResults ) )
514514
{

‎src/plugins/topology/topolTest.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,14 +1732,7 @@ ErrorList topolTest::runTest( const QString &testName, QgsVectorLayer *layer1, Q
17321732

17331733
//call test routine
17341734
bool isValidatingExtent;
1735-
if ( type == ValidateExtent )
1736-
{
1737-
isValidatingExtent = true;
1738-
}
1739-
else
1740-
{
1741-
isValidatingExtent = false;
1742-
}
1735+
isValidatingExtent = type == ValidateExtent;
17431736

17441737
return ( this->*( mTopologyRuleMap[testName].f ) )( tolerance, layer1, layer2, isValidatingExtent );
17451738
}

‎src/providers/arcgisrest/qgsamsprovider.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ void QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int p
347347
mCachedImage = mCachedImage.convertToFormat( QImage::Format_ARGB32 );
348348
}
349349
}
350-
return;
351350
}
352351

353352
QImage QgsAmsProvider::getLegendGraphic( double /*scale*/, bool forceRefresh, const QgsRectangle * /*visibleExtent*/ )

‎src/providers/grass/qgsgrassvectormap.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ void QgsGrassVectorMap::close()
103103
closeMap();
104104
mOpen = false;
105105
unlockOpenClose();
106-
return;
107106
}
108107

109108
bool QgsGrassVectorMap::openMap()

‎src/providers/grass/qgsgrassvectormaplayer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,7 @@ void QgsGrassVectorMapLayer::executeSql( const QString &sql, QString &error )
548548
QgsDebugMsg( error );
549549
}
550550

551-
db_free_string( &dbstr ); //if ( index < 0 || index > )
552-
return;
551+
db_free_string( &dbstr );
553552
}
554553

555554
void QgsGrassVectorMapLayer::createTable( const QgsFields &fields, QString &error )

‎src/providers/wfs/qgswfsprovider.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,14 +1484,7 @@ bool QgsWFSProvider::transactionSuccess( const QDomDocument &serverResponse ) co
14841484
return false;
14851485
}
14861486

1487-
if ( statusList.at( 0 ).firstChildElement().localName() == QLatin1String( "SUCCESS" ) )
1488-
{
1489-
return true;
1490-
}
1491-
else
1492-
{
1493-
return false;
1494-
}
1487+
return statusList.at( 0 ).firstChildElement().localName() == QLatin1String( "SUCCESS" );
14951488
}
14961489

14971490
QStringList QgsWFSProvider::insertedFeatureIds( const QDomDocument &serverResponse ) const

‎src/server/qgsserverprojectutils.cpp

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,36 +114,24 @@ bool QgsServerProjectUtils::wmsInfoFormatSia2045( const QgsProject &project )
114114
{
115115
QString sia2045 = project.readEntry( QStringLiteral( "WMSInfoFormatSIA2045" ), QStringLiteral( "/" ), "" );
116116

117-
if ( sia2045.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
118-
|| sia2045.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
119-
{
120-
return true;
121-
}
122-
return false;
117+
return sia2045.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
118+
|| sia2045.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
123119
}
124120

125121
bool QgsServerProjectUtils::wmsFeatureInfoAddWktGeometry( const QgsProject &project )
126122
{
127123
QString wktGeom = project.readEntry( QStringLiteral( "WMSAddWktGeometry" ), QStringLiteral( "/" ), "" );
128124

129-
if ( wktGeom.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
130-
|| wktGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
131-
{
132-
return true;
133-
}
134-
return false;
125+
return wktGeom.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
126+
|| wktGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
135127
}
136128

137129
bool QgsServerProjectUtils::wmsFeatureInfoSegmentizeWktGeometry( const QgsProject &project )
138130
{
139131
QString segmGeom = project.readEntry( QStringLiteral( "WMSSegmentizeFeatureInfoGeometry" ), QStringLiteral( "/" ), "" );
140132

141-
if ( segmGeom.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
142-
|| segmGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
143-
{
144-
return true;
145-
}
146-
return false;
133+
return segmGeom.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
134+
|| segmGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
147135
}
148136

149137
int QgsServerProjectUtils::wmsFeatureInfoPrecision( const QgsProject &project )

‎src/server/services/wms/qgswmsrenderer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ namespace QgsWms
317317
removeUnwantedLayers( layers );
318318

319319
// configure each layer with opacity, selection filter, ...
320-
bool updateMapExtent = mWmsParameters.bbox().isEmpty() ? true : false;
320+
bool updateMapExtent = mWmsParameters.bbox().isEmpty();
321321
Q_FOREACH ( QgsMapLayer *layer, layers )
322322
{
323323
Q_FOREACH ( QgsWmsParametersLayer param, params )
@@ -720,7 +720,7 @@ namespace QgsWms
720720
removeUnwantedLayers( layers );
721721

722722
// configure each layer with opacity, selection filter, ...
723-
bool updateMapExtent = mWmsParameters.bbox().isEmpty() ? true : false;
723+
bool updateMapExtent = mWmsParameters.bbox().isEmpty();
724724
Q_FOREACH ( QgsMapLayer *layer, layers )
725725
{
726726
Q_FOREACH ( QgsWmsParametersLayer param, params )
@@ -760,7 +760,7 @@ namespace QgsWms
760760
mapSettings.setLayers( layers );
761761

762762
// rendering step for layers
763-
painter.reset( layersRendering( mapSettings, *image.get(), hitTest ) );
763+
painter.reset( layersRendering( mapSettings, *image, hitTest ) );
764764

765765
// rendering step for annotations
766766
annotationsRendering( painter.get() );

‎tests/src/analysis/testqgsprocessing.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ void TestQgsProcessing::createIndex()
11731173
// disable selected features check
11741174
std::unique_ptr< QgsFeatureSource > source( QgsProcessingParameters::parameterAsSource( def.get(), params, context ) );
11751175
QVERIFY( source.get() );
1176-
QgsSpatialIndex index( *source.get() );
1176+
QgsSpatialIndex index( *source );
11771177
QList<QgsFeatureId> ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 );
11781178
QCOMPARE( ids, QList<QgsFeatureId>() << 2 );
11791179

@@ -1183,7 +1183,7 @@ void TestQgsProcessing::createIndex()
11831183
bool caught = false;
11841184
try
11851185
{
1186-
index = QgsSpatialIndex( *source.get() );
1186+
index = QgsSpatialIndex( *source );
11871187
ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 );
11881188
}
11891189
catch ( ... )
@@ -1195,14 +1195,14 @@ void TestQgsProcessing::createIndex()
11951195
// create selection
11961196
layer->selectByIds( QgsFeatureIds() << 4 << 5 );
11971197
source.reset( QgsProcessingParameters::parameterAsSource( def.get(), params, context ) );
1198-
index = QgsSpatialIndex( *source.get() );
1198+
index = QgsSpatialIndex( *source );
11991199
ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 );
12001200
QCOMPARE( ids, QList<QgsFeatureId>() << 4 );
12011201

12021202
// selection but not using selection mode
12031203
params.insert( QStringLiteral( "layer" ), QVariant::fromValue( QgsProcessingFeatureSourceDefinition( layer->id(), false ) ) );
12041204
source.reset( QgsProcessingParameters::parameterAsSource( def.get(), params, context ) );
1205-
index = QgsSpatialIndex( *source.get() );
1205+
index = QgsSpatialIndex( *source );
12061206
ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 );
12071207
QCOMPARE( ids, QList<QgsFeatureId>() << 2 );
12081208
}

‎tests/src/core/testqgsauthmanager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void TestQgsAuthManager::testMasterPassword()
209209
QCOMPARE( spy.count(), 1 );
210210
spyargs = spy.takeFirst();
211211
QVERIFY( spyargs.at( 0 ).type() == QVariant::Bool );
212-
QVERIFY( spyargs.at( 0 ).toBool() == true );
212+
QVERIFY( spyargs.at( 0 ).toBool() );
213213

214214
authm->clearMasterPassword();
215215
QVERIFY( !authm->masterPasswordIsSet() );
@@ -218,7 +218,7 @@ void TestQgsAuthManager::testMasterPassword()
218218
QCOMPARE( spy.count(), 1 );
219219
spyargs = spy.takeFirst();
220220
QVERIFY( spyargs.at( 0 ).type() == QVariant::Bool );
221-
QVERIFY( spyargs.at( 0 ).toBool() == false );
221+
QVERIFY( !spyargs.at( 0 ).toBool() );
222222

223223
authm->clearMasterPassword();
224224
QVERIFY( !authm->masterPasswordIsSet() );
@@ -227,7 +227,7 @@ void TestQgsAuthManager::testMasterPassword()
227227
QCOMPARE( spy.count(), 1 );
228228
spyargs = spy.takeFirst();
229229
QVERIFY( spyargs.at( 0 ).type() == QVariant::Bool );
230-
QVERIFY( spyargs.at( 0 ).toBool() == true );
230+
QVERIFY( spyargs.at( 0 ).toBool() );
231231
}
232232

233233
void TestQgsAuthManager::testAuthConfigs()

‎tests/src/gui/testqgsrelationreferencewidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void TestQgsRelationReferenceWidget::init()
7979
mRelation->setReferencedLayer( mLayer2->id() );
8080
mRelation->addFieldPair( QStringLiteral( "fk" ), QStringLiteral( "pk" ) );
8181
QVERIFY( mRelation->isValid() );
82-
QgsProject::instance()->relationManager()->addRelation( *mRelation.get() );
82+
QgsProject::instance()->relationManager()->addRelation( *mRelation );
8383

8484
// add features
8585
QgsFeature ft0( mLayer1->fields() );

0 commit comments

Comments
 (0)
Please sign in to comment.