Skip to content
Permalink
Browse files

Run clang-tidy code readability fixits

  • Loading branch information
nyalldawson committed Nov 11, 2017
1 parent c97fa5b commit bcd90715b05b4a8bf308c552b9f7f5632bd6b85c
@@ -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
@@ -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 )
@@ -53,12 +53,12 @@ void QgsGeometryPointCoveredByLineCheck::collectErrors( QList<QgsGeometryCheckEr
break;
}
}
if ( touches == true )
if ( touches )
{
break;
}
}
if ( touches == true )
if ( touches )
{
continue;
}
@@ -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 )
@@ -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 ) );
@@ -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 ) );
@@ -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 )
@@ -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()
@@ -2262,7 +2262,7 @@ QList<QgsMapLayer *> QgsProject::addMapLayers(
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( mlayer );
if ( vl )
{
vl->loadAuxiliaryLayer( *mAuxiliaryStorage.get() );
vl->loadAuxiliaryLayer( *mAuxiliaryStorage );
}
}
}
@@ -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();
}
@@ -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 ) )
{
@@ -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 );
}
@@ -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*/ )
@@ -103,7 +103,6 @@ void QgsGrassVectorMap::close()
closeMap();
mOpen = false;
unlockOpenClose();
return;
}

bool QgsGrassVectorMap::openMap()
@@ -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 )
@@ -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
@@ -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 )
@@ -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 )
@@ -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 )
@@ -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() );
@@ -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 );

@@ -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 ( ... )
@@ -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 );
}
@@ -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() );
@@ -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() );
@@ -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()
@@ -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() );

0 comments on commit bcd9071

Please sign in to comment.
You can’t perform that action at this time.