Skip to content

Commit

Permalink
Run clang-tidy code readability fixits
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 11, 2017
1 parent c97fa5b commit bcd9071
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 72 deletions.
Expand Up @@ -173,7 +173,7 @@ bool QgsGeometryAreaCheck::mergeWithNeighbor( const QString &layerId, QgsFeature

if ( !matchFound && maxVal == 0. )
{
return method == MergeIdenticalAttribute ? true : false;
return method == MergeIdenticalAttribute;
}

// Merge geometries
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/vector/geometry_checker/qgsgeometrycheck.cpp
Expand Up @@ -97,7 +97,7 @@ bool QgsGeometryCheckError::handleChanges( const QgsGeometryCheck::Changes &chan
// If the check is checking the feature at geometry nodes level, the
// error almost certainly invalid after a geometry change. In the other
// cases, it might likely still be valid.
return mCheck->getCheckType() == QgsGeometryCheck::FeatureNodeCheck ? false : true;
return mCheck->getCheckType() != QgsGeometryCheck::FeatureNodeCheck;
}
}
else if ( change.what == QgsGeometryCheck::ChangePart )
Expand Down
Expand Up @@ -53,12 +53,12 @@ void QgsGeometryPointCoveredByLineCheck::collectErrors( QList<QgsGeometryCheckEr
break;
}
}
if ( touches == true )
if ( touches )
{
break;
}
}
if ( touches == true )
if ( touches )
{
continue;
}
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsmaptooldeletepart.cpp
Expand Up @@ -112,7 +112,6 @@ void QgsMapToolDeletePart::canvasReleaseEvent( QgsMapMouseEvent *e )
{
emit messageEmitted( tr( "Couldn't remove the selected part." ) );
}
return;
}

QgsGeometry QgsMapToolDeletePart::partUnderPoint( QPoint point, QgsFeatureId &fid, int &partNum )
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgswelcomepageitemsmodel.cpp
Expand Up @@ -77,7 +77,7 @@ void QgsWelcomePageItemDelegate::paint( QPainter *painter, const QStyleOptionVie

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 )
.arg( index.data( QgsWelcomePageItemsModel::TitleRole ).toString(),
index.data( QgsWelcomePageItemsModel::PinRole ).toBool() == true ? QStringLiteral( "<img src=\"qrc:/images/themes/default/pin.svg\">" ) : QString(),
index.data( QgsWelcomePageItemsModel::PinRole ).toBool() ? QStringLiteral( "<img src=\"qrc:/images/themes/default/pin.svg\">" ) : QString(),
index.data( QgsWelcomePageItemsModel::NativePathRole ).toString(),
index.data( QgsWelcomePageItemsModel::CrsRole ).toString() ) );
doc.setTextWidth( option.rect.width() - ( !icon.isNull() ? icon.width() + 35 : 35 ) );
Expand Down Expand Up @@ -114,7 +114,7 @@ QSize QgsWelcomePageItemDelegate::sizeHint( const QStyleOptionViewItem &option,

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 )
.arg( index.data( QgsWelcomePageItemsModel::TitleRole ).toString(),
index.data( QgsWelcomePageItemsModel::PinRole ).toBool() == true ? QStringLiteral( "<img src=\"qrc:/images/themes/default/pin.svg\">" ) : QString(),
index.data( QgsWelcomePageItemsModel::PinRole ).toBool() ? QStringLiteral( "<img src=\"qrc:/images/themes/default/pin.svg\">" ) : QString(),
index.data( QgsWelcomePageItemsModel::NativePathRole ).toString(),
index.data( QgsWelcomePageItemsModel::CrsRole ).toString() ) );
doc.setTextWidth( width - ( !icon.isNull() ? icon.width() + 35 : 35 ) );
Expand Down
12 changes: 2 additions & 10 deletions src/core/pal/rtree.hpp
Expand Up @@ -389,11 +389,7 @@ namespace pal
fclose( m_file );

m_file = fopen( a_fileName, "rb" );
if ( !m_file )
{
return false;
}
return true;
return m_file != nullptr;
}

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

m_file = fopen( a_fileName, "wb" );
if ( !m_file )
{
return false;
}
return true;
return m_file != nullptr;
}

void Close()
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsproject.cpp
Expand Up @@ -2262,7 +2262,7 @@ QList<QgsMapLayer *> QgsProject::addMapLayers(
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( mlayer );
if ( vl )
{
vl->loadAuxiliaryLayer( *mAuxiliaryStorage.get() );
vl->loadAuxiliaryLayer( *mAuxiliaryStorage );
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/core/qgsvectorlayerjoinbuffer.cpp
Expand Up @@ -667,8 +667,5 @@ bool QgsVectorLayerJoinBuffer::isAuxiliaryJoin( const QgsVectorLayerJoinInfo &in
{
const QgsAuxiliaryLayer *al = mLayer->auxiliaryLayer();

if ( al && al->id() == info.joinLayerId() )
return true;
else
return false;
return al && al->id() == info.joinLayerId();
}
2 changes: 1 addition & 1 deletion src/gui/qgsmetadatawidget.cpp
Expand Up @@ -508,7 +508,7 @@ bool QgsMetadataWidget::checkMetadata() const
bool results = validator.validate( metadata, validationResults );

QString errors;
if ( results == false )
if ( !results )
{
for ( const QgsMetadataValidator::ValidationResult &result : qgis::as_const( validationResults ) )
{
Expand Down
9 changes: 1 addition & 8 deletions src/plugins/topology/topolTest.cpp
Expand Up @@ -1732,14 +1732,7 @@ ErrorList topolTest::runTest( const QString &testName, QgsVectorLayer *layer1, Q

//call test routine
bool isValidatingExtent;
if ( type == ValidateExtent )
{
isValidatingExtent = true;
}
else
{
isValidatingExtent = false;
}
isValidatingExtent = type == ValidateExtent;

return ( this->*( mTopologyRuleMap[testName].f ) )( tolerance, layer1, layer2, isValidatingExtent );
}
1 change: 0 additions & 1 deletion src/providers/arcgisrest/qgsamsprovider.cpp
Expand Up @@ -347,7 +347,6 @@ void QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int p
mCachedImage = mCachedImage.convertToFormat( QImage::Format_ARGB32 );
}
}
return;
}

QImage QgsAmsProvider::getLegendGraphic( double /*scale*/, bool forceRefresh, const QgsRectangle * /*visibleExtent*/ )
Expand Down
1 change: 0 additions & 1 deletion src/providers/grass/qgsgrassvectormap.cpp
Expand Up @@ -103,7 +103,6 @@ void QgsGrassVectorMap::close()
closeMap();
mOpen = false;
unlockOpenClose();
return;
}

bool QgsGrassVectorMap::openMap()
Expand Down
3 changes: 1 addition & 2 deletions src/providers/grass/qgsgrassvectormaplayer.cpp
Expand Up @@ -548,8 +548,7 @@ void QgsGrassVectorMapLayer::executeSql( const QString &sql, QString &error )
QgsDebugMsg( error );
}

db_free_string( &dbstr ); //if ( index < 0 || index > )
return;
db_free_string( &dbstr );
}

void QgsGrassVectorMapLayer::createTable( const QgsFields &fields, QString &error )
Expand Down
9 changes: 1 addition & 8 deletions src/providers/wfs/qgswfsprovider.cpp
Expand Up @@ -1484,14 +1484,7 @@ bool QgsWFSProvider::transactionSuccess( const QDomDocument &serverResponse ) co
return false;
}

if ( statusList.at( 0 ).firstChildElement().localName() == QLatin1String( "SUCCESS" ) )
{
return true;
}
else
{
return false;
}
return statusList.at( 0 ).firstChildElement().localName() == QLatin1String( "SUCCESS" );
}

QStringList QgsWFSProvider::insertedFeatureIds( const QDomDocument &serverResponse ) const
Expand Down
24 changes: 6 additions & 18 deletions src/server/qgsserverprojectutils.cpp
Expand Up @@ -114,36 +114,24 @@ bool QgsServerProjectUtils::wmsInfoFormatSia2045( const QgsProject &project )
{
QString sia2045 = project.readEntry( QStringLiteral( "WMSInfoFormatSIA2045" ), QStringLiteral( "/" ), "" );

if ( sia2045.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
|| sia2045.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
{
return true;
}
return false;
return sia2045.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
|| sia2045.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
}

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

if ( wktGeom.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
|| wktGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
{
return true;
}
return false;
return wktGeom.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
|| wktGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
}

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

if ( segmGeom.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
|| segmGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
{
return true;
}
return false;
return segmGeom.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
|| segmGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
}

int QgsServerProjectUtils::wmsFeatureInfoPrecision( const QgsProject &project )
Expand Down
6 changes: 3 additions & 3 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -317,7 +317,7 @@ namespace QgsWms
removeUnwantedLayers( layers );

// configure each layer with opacity, selection filter, ...
bool updateMapExtent = mWmsParameters.bbox().isEmpty() ? true : false;
bool updateMapExtent = mWmsParameters.bbox().isEmpty();
Q_FOREACH ( QgsMapLayer *layer, layers )
{
Q_FOREACH ( QgsWmsParametersLayer param, params )
Expand Down Expand Up @@ -720,7 +720,7 @@ namespace QgsWms
removeUnwantedLayers( layers );

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

// rendering step for layers
painter.reset( layersRendering( mapSettings, *image.get(), hitTest ) );
painter.reset( layersRendering( mapSettings, *image, hitTest ) );

// rendering step for annotations
annotationsRendering( painter.get() );
Expand Down
8 changes: 4 additions & 4 deletions tests/src/analysis/testqgsprocessing.cpp
Expand Up @@ -1173,7 +1173,7 @@ void TestQgsProcessing::createIndex()
// disable selected features check
std::unique_ptr< QgsFeatureSource > source( QgsProcessingParameters::parameterAsSource( def.get(), params, context ) );
QVERIFY( source.get() );
QgsSpatialIndex index( *source.get() );
QgsSpatialIndex index( *source );
QList<QgsFeatureId> ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 );
QCOMPARE( ids, QList<QgsFeatureId>() << 2 );

Expand All @@ -1183,7 +1183,7 @@ void TestQgsProcessing::createIndex()
bool caught = false;
try
{
index = QgsSpatialIndex( *source.get() );
index = QgsSpatialIndex( *source );
ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 );
}
catch ( ... )
Expand All @@ -1195,14 +1195,14 @@ void TestQgsProcessing::createIndex()
// create selection
layer->selectByIds( QgsFeatureIds() << 4 << 5 );
source.reset( QgsProcessingParameters::parameterAsSource( def.get(), params, context ) );
index = QgsSpatialIndex( *source.get() );
index = QgsSpatialIndex( *source );
ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 );
QCOMPARE( ids, QList<QgsFeatureId>() << 4 );

// selection but not using selection mode
params.insert( QStringLiteral( "layer" ), QVariant::fromValue( QgsProcessingFeatureSourceDefinition( layer->id(), false ) ) );
source.reset( QgsProcessingParameters::parameterAsSource( def.get(), params, context ) );
index = QgsSpatialIndex( *source.get() );
index = QgsSpatialIndex( *source );
ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 );
QCOMPARE( ids, QList<QgsFeatureId>() << 2 );
}
Expand Down
6 changes: 3 additions & 3 deletions tests/src/core/testqgsauthmanager.cpp
Expand Up @@ -209,7 +209,7 @@ void TestQgsAuthManager::testMasterPassword()
QCOMPARE( spy.count(), 1 );
spyargs = spy.takeFirst();
QVERIFY( spyargs.at( 0 ).type() == QVariant::Bool );
QVERIFY( spyargs.at( 0 ).toBool() == true );
QVERIFY( spyargs.at( 0 ).toBool() );

authm->clearMasterPassword();
QVERIFY( !authm->masterPasswordIsSet() );
Expand All @@ -218,7 +218,7 @@ void TestQgsAuthManager::testMasterPassword()
QCOMPARE( spy.count(), 1 );
spyargs = spy.takeFirst();
QVERIFY( spyargs.at( 0 ).type() == QVariant::Bool );
QVERIFY( spyargs.at( 0 ).toBool() == false );
QVERIFY( !spyargs.at( 0 ).toBool() );

authm->clearMasterPassword();
QVERIFY( !authm->masterPasswordIsSet() );
Expand All @@ -227,7 +227,7 @@ void TestQgsAuthManager::testMasterPassword()
QCOMPARE( spy.count(), 1 );
spyargs = spy.takeFirst();
QVERIFY( spyargs.at( 0 ).type() == QVariant::Bool );
QVERIFY( spyargs.at( 0 ).toBool() == true );
QVERIFY( spyargs.at( 0 ).toBool() );
}

void TestQgsAuthManager::testAuthConfigs()
Expand Down
2 changes: 1 addition & 1 deletion tests/src/gui/testqgsrelationreferencewidget.cpp
Expand Up @@ -79,7 +79,7 @@ void TestQgsRelationReferenceWidget::init()
mRelation->setReferencedLayer( mLayer2->id() );
mRelation->addFieldPair( QStringLiteral( "fk" ), QStringLiteral( "pk" ) );
QVERIFY( mRelation->isValid() );
QgsProject::instance()->relationManager()->addRelation( *mRelation.get() );
QgsProject::instance()->relationManager()->addRelation( *mRelation );

// add features
QgsFeature ft0( mLayer1->fields() );
Expand Down

0 comments on commit bcd9071

Please sign in to comment.