Run clang-tidy code readability fixits

This commit is contained in:
Nyall Dawson 2017-11-11 12:19:59 +10:00
parent c97fa5bdd0
commit bcd90715b0
19 changed files with 31 additions and 72 deletions

View File

@ -173,7 +173,7 @@ bool QgsGeometryAreaCheck::mergeWithNeighbor( const QString &layerId, QgsFeature
if ( !matchFound && maxVal == 0. ) if ( !matchFound && maxVal == 0. )
{ {
return method == MergeIdenticalAttribute ? true : false; return method == MergeIdenticalAttribute;
} }
// Merge geometries // Merge geometries

View File

@ -97,7 +97,7 @@ bool QgsGeometryCheckError::handleChanges( const QgsGeometryCheck::Changes &chan
// If the check is checking the feature at geometry nodes level, the // If the check is checking the feature at geometry nodes level, the
// error almost certainly invalid after a geometry change. In the other // error almost certainly invalid after a geometry change. In the other
// cases, it might likely still be valid. // 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 ) else if ( change.what == QgsGeometryCheck::ChangePart )

View File

@ -53,12 +53,12 @@ void QgsGeometryPointCoveredByLineCheck::collectErrors( QList<QgsGeometryCheckEr
break; break;
} }
} }
if ( touches == true ) if ( touches )
{ {
break; break;
} }
} }
if ( touches == true ) if ( touches )
{ {
continue; continue;
} }

View File

@ -112,7 +112,6 @@ void QgsMapToolDeletePart::canvasReleaseEvent( QgsMapMouseEvent *e )
{ {
emit messageEmitted( tr( "Couldn't remove the selected part." ) ); emit messageEmitted( tr( "Couldn't remove the selected part." ) );
} }
return;
} }
QgsGeometry QgsMapToolDeletePart::partUnderPoint( QPoint point, QgsFeatureId &fid, int &partNum ) QgsGeometry QgsMapToolDeletePart::partUnderPoint( QPoint point, QgsFeatureId &fid, int &partNum )

View File

@ -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 ) 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(), .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::NativePathRole ).toString(),
index.data( QgsWelcomePageItemsModel::CrsRole ).toString() ) ); index.data( QgsWelcomePageItemsModel::CrsRole ).toString() ) );
doc.setTextWidth( option.rect.width() - ( !icon.isNull() ? icon.width() + 35 : 35 ) ); doc.setTextWidth( option.rect.width() - ( !icon.isNull() ? icon.width() + 35 : 35 ) );
@ -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 ) 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(), .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::NativePathRole ).toString(),
index.data( QgsWelcomePageItemsModel::CrsRole ).toString() ) ); index.data( QgsWelcomePageItemsModel::CrsRole ).toString() ) );
doc.setTextWidth( width - ( !icon.isNull() ? icon.width() + 35 : 35 ) ); doc.setTextWidth( width - ( !icon.isNull() ? icon.width() + 35 : 35 ) );

View File

@ -389,11 +389,7 @@ namespace pal
fclose( m_file ); fclose( m_file );
m_file = fopen( a_fileName, "rb" ); m_file = fopen( a_fileName, "rb" );
if ( !m_file ) return m_file != nullptr;
{
return false;
}
return true;
} }
bool OpenWrite( const char *a_fileName ) bool OpenWrite( const char *a_fileName )
@ -402,11 +398,7 @@ namespace pal
fclose( m_file ); fclose( m_file );
m_file = fopen( a_fileName, "wb" ); m_file = fopen( a_fileName, "wb" );
if ( !m_file ) return m_file != nullptr;
{
return false;
}
return true;
} }
void Close() void Close()

View File

@ -2262,7 +2262,7 @@ QList<QgsMapLayer *> QgsProject::addMapLayers(
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( mlayer ); QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( mlayer );
if ( vl ) if ( vl )
{ {
vl->loadAuxiliaryLayer( *mAuxiliaryStorage.get() ); vl->loadAuxiliaryLayer( *mAuxiliaryStorage );
} }
} }
} }

View File

@ -667,8 +667,5 @@ bool QgsVectorLayerJoinBuffer::isAuxiliaryJoin( const QgsVectorLayerJoinInfo &in
{ {
const QgsAuxiliaryLayer *al = mLayer->auxiliaryLayer(); const QgsAuxiliaryLayer *al = mLayer->auxiliaryLayer();
if ( al && al->id() == info.joinLayerId() ) return al && al->id() == info.joinLayerId();
return true;
else
return false;
} }

View File

@ -508,7 +508,7 @@ bool QgsMetadataWidget::checkMetadata() const
bool results = validator.validate( metadata, validationResults ); bool results = validator.validate( metadata, validationResults );
QString errors; QString errors;
if ( results == false ) if ( !results )
{ {
for ( const QgsMetadataValidator::ValidationResult &result : qgis::as_const( validationResults ) ) for ( const QgsMetadataValidator::ValidationResult &result : qgis::as_const( validationResults ) )
{ {

View File

@ -1732,14 +1732,7 @@ ErrorList topolTest::runTest( const QString &testName, QgsVectorLayer *layer1, Q
//call test routine //call test routine
bool isValidatingExtent; bool isValidatingExtent;
if ( type == ValidateExtent ) isValidatingExtent = type == ValidateExtent;
{
isValidatingExtent = true;
}
else
{
isValidatingExtent = false;
}
return ( this->*( mTopologyRuleMap[testName].f ) )( tolerance, layer1, layer2, isValidatingExtent ); return ( this->*( mTopologyRuleMap[testName].f ) )( tolerance, layer1, layer2, isValidatingExtent );
} }

View File

@ -347,7 +347,6 @@ void QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int p
mCachedImage = mCachedImage.convertToFormat( QImage::Format_ARGB32 ); mCachedImage = mCachedImage.convertToFormat( QImage::Format_ARGB32 );
} }
} }
return;
} }
QImage QgsAmsProvider::getLegendGraphic( double /*scale*/, bool forceRefresh, const QgsRectangle * /*visibleExtent*/ ) QImage QgsAmsProvider::getLegendGraphic( double /*scale*/, bool forceRefresh, const QgsRectangle * /*visibleExtent*/ )

View File

@ -103,7 +103,6 @@ void QgsGrassVectorMap::close()
closeMap(); closeMap();
mOpen = false; mOpen = false;
unlockOpenClose(); unlockOpenClose();
return;
} }
bool QgsGrassVectorMap::openMap() bool QgsGrassVectorMap::openMap()

View File

@ -548,8 +548,7 @@ void QgsGrassVectorMapLayer::executeSql( const QString &sql, QString &error )
QgsDebugMsg( error ); QgsDebugMsg( error );
} }
db_free_string( &dbstr ); //if ( index < 0 || index > ) db_free_string( &dbstr );
return;
} }
void QgsGrassVectorMapLayer::createTable( const QgsFields &fields, QString &error ) void QgsGrassVectorMapLayer::createTable( const QgsFields &fields, QString &error )

View File

@ -1484,14 +1484,7 @@ bool QgsWFSProvider::transactionSuccess( const QDomDocument &serverResponse ) co
return false; return false;
} }
if ( statusList.at( 0 ).firstChildElement().localName() == QLatin1String( "SUCCESS" ) ) return statusList.at( 0 ).firstChildElement().localName() == QLatin1String( "SUCCESS" );
{
return true;
}
else
{
return false;
}
} }
QStringList QgsWFSProvider::insertedFeatureIds( const QDomDocument &serverResponse ) const QStringList QgsWFSProvider::insertedFeatureIds( const QDomDocument &serverResponse ) const

View File

@ -114,36 +114,24 @@ bool QgsServerProjectUtils::wmsInfoFormatSia2045( const QgsProject &project )
{ {
QString sia2045 = project.readEntry( QStringLiteral( "WMSInfoFormatSIA2045" ), QStringLiteral( "/" ), "" ); QString sia2045 = project.readEntry( QStringLiteral( "WMSInfoFormatSIA2045" ), QStringLiteral( "/" ), "" );
if ( sia2045.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0 return sia2045.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
|| sia2045.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 ) || sia2045.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
{
return true;
}
return false;
} }
bool QgsServerProjectUtils::wmsFeatureInfoAddWktGeometry( const QgsProject &project ) bool QgsServerProjectUtils::wmsFeatureInfoAddWktGeometry( const QgsProject &project )
{ {
QString wktGeom = project.readEntry( QStringLiteral( "WMSAddWktGeometry" ), QStringLiteral( "/" ), "" ); QString wktGeom = project.readEntry( QStringLiteral( "WMSAddWktGeometry" ), QStringLiteral( "/" ), "" );
if ( wktGeom.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0 return wktGeom.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
|| wktGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 ) || wktGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
{
return true;
}
return false;
} }
bool QgsServerProjectUtils::wmsFeatureInfoSegmentizeWktGeometry( const QgsProject &project ) bool QgsServerProjectUtils::wmsFeatureInfoSegmentizeWktGeometry( const QgsProject &project )
{ {
QString segmGeom = project.readEntry( QStringLiteral( "WMSSegmentizeFeatureInfoGeometry" ), QStringLiteral( "/" ), "" ); QString segmGeom = project.readEntry( QStringLiteral( "WMSSegmentizeFeatureInfoGeometry" ), QStringLiteral( "/" ), "" );
if ( segmGeom.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0 return segmGeom.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
|| segmGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 ) || segmGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
{
return true;
}
return false;
} }
int QgsServerProjectUtils::wmsFeatureInfoPrecision( const QgsProject &project ) int QgsServerProjectUtils::wmsFeatureInfoPrecision( const QgsProject &project )

View File

@ -317,7 +317,7 @@ namespace QgsWms
removeUnwantedLayers( layers ); removeUnwantedLayers( layers );
// configure each layer with opacity, selection filter, ... // 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 ( QgsMapLayer *layer, layers )
{ {
Q_FOREACH ( QgsWmsParametersLayer param, params ) Q_FOREACH ( QgsWmsParametersLayer param, params )
@ -720,7 +720,7 @@ namespace QgsWms
removeUnwantedLayers( layers ); removeUnwantedLayers( layers );
// configure each layer with opacity, selection filter, ... // 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 ( QgsMapLayer *layer, layers )
{ {
Q_FOREACH ( QgsWmsParametersLayer param, params ) Q_FOREACH ( QgsWmsParametersLayer param, params )
@ -760,7 +760,7 @@ namespace QgsWms
mapSettings.setLayers( layers ); mapSettings.setLayers( layers );
// rendering step for layers // rendering step for layers
painter.reset( layersRendering( mapSettings, *image.get(), hitTest ) ); painter.reset( layersRendering( mapSettings, *image, hitTest ) );
// rendering step for annotations // rendering step for annotations
annotationsRendering( painter.get() ); annotationsRendering( painter.get() );

View File

@ -1173,7 +1173,7 @@ void TestQgsProcessing::createIndex()
// disable selected features check // disable selected features check
std::unique_ptr< QgsFeatureSource > source( QgsProcessingParameters::parameterAsSource( def.get(), params, context ) ); std::unique_ptr< QgsFeatureSource > source( QgsProcessingParameters::parameterAsSource( def.get(), params, context ) );
QVERIFY( source.get() ); QVERIFY( source.get() );
QgsSpatialIndex index( *source.get() ); QgsSpatialIndex index( *source );
QList<QgsFeatureId> ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 ); QList<QgsFeatureId> ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 );
QCOMPARE( ids, QList<QgsFeatureId>() << 2 ); QCOMPARE( ids, QList<QgsFeatureId>() << 2 );
@ -1183,7 +1183,7 @@ void TestQgsProcessing::createIndex()
bool caught = false; bool caught = false;
try try
{ {
index = QgsSpatialIndex( *source.get() ); index = QgsSpatialIndex( *source );
ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 ); ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 );
} }
catch ( ... ) catch ( ... )
@ -1195,14 +1195,14 @@ void TestQgsProcessing::createIndex()
// create selection // create selection
layer->selectByIds( QgsFeatureIds() << 4 << 5 ); layer->selectByIds( QgsFeatureIds() << 4 << 5 );
source.reset( QgsProcessingParameters::parameterAsSource( def.get(), params, context ) ); source.reset( QgsProcessingParameters::parameterAsSource( def.get(), params, context ) );
index = QgsSpatialIndex( *source.get() ); index = QgsSpatialIndex( *source );
ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 ); ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 );
QCOMPARE( ids, QList<QgsFeatureId>() << 4 ); QCOMPARE( ids, QList<QgsFeatureId>() << 4 );
// selection but not using selection mode // selection but not using selection mode
params.insert( QStringLiteral( "layer" ), QVariant::fromValue( QgsProcessingFeatureSourceDefinition( layer->id(), false ) ) ); params.insert( QStringLiteral( "layer" ), QVariant::fromValue( QgsProcessingFeatureSourceDefinition( layer->id(), false ) ) );
source.reset( QgsProcessingParameters::parameterAsSource( def.get(), params, context ) ); source.reset( QgsProcessingParameters::parameterAsSource( def.get(), params, context ) );
index = QgsSpatialIndex( *source.get() ); index = QgsSpatialIndex( *source );
ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 ); ids = index.nearestNeighbor( QgsPointXY( 2.1, 2 ), 1 );
QCOMPARE( ids, QList<QgsFeatureId>() << 2 ); QCOMPARE( ids, QList<QgsFeatureId>() << 2 );
} }

View File

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

View File

@ -79,7 +79,7 @@ void TestQgsRelationReferenceWidget::init()
mRelation->setReferencedLayer( mLayer2->id() ); mRelation->setReferencedLayer( mLayer2->id() );
mRelation->addFieldPair( QStringLiteral( "fk" ), QStringLiteral( "pk" ) ); mRelation->addFieldPair( QStringLiteral( "fk" ), QStringLiteral( "pk" ) );
QVERIFY( mRelation->isValid() ); QVERIFY( mRelation->isValid() );
QgsProject::instance()->relationManager()->addRelation( *mRelation.get() ); QgsProject::instance()->relationManager()->addRelation( *mRelation );
// add features // add features
QgsFeature ft0( mLayer1->fields() ); QgsFeature ft0( mLayer1->fields() );