Skip to content
Permalink
Browse files

Fix clazy warnings

  • Loading branch information
elpaso committed Jan 6, 2021
1 parent fd7406c commit 112810c2fb76c83b4e3ed5df41c3267b899dc271
@@ -1,4 +1,5 @@
# The following has been generated automatically from src/core/qgsabstractdatabaseproviderconnection.h
QgsAbstractDatabaseProviderConnection.TableFlag.baseClass = QgsAbstractDatabaseProviderConnection
QgsAbstractDatabaseProviderConnection.TableFlags.baseClass = QgsAbstractDatabaseProviderConnection
TableFlags = QgsAbstractDatabaseProviderConnection # dirty hack since SIP seems to introduce the flags in module
QgsAbstractDatabaseProviderConnection.Capability.baseClass = QgsAbstractDatabaseProviderConnection
@@ -63,7 +63,7 @@ class CORE_EXPORT QgsAbstractDatabaseProviderConnection : public QgsAbstractProv
Foreign = 1 << 6, //!< Foreign data wrapper
};

Q_ENUMS( TableFlag )
Q_ENUM( TableFlag )
Q_DECLARE_FLAGS( TableFlags, TableFlag )
Q_FLAG( TableFlags )

@@ -84,8 +84,7 @@ void QgsPostgresProviderConnection::setDefaultCapabilities()
void QgsPostgresProviderConnection::dropTablePrivate( const QString &schema, const QString &name ) const
{
executeSqlPrivate( QStringLiteral( "DROP TABLE %1.%2" )
.arg( QgsPostgresConn::quotedIdentifier( schema ) )
.arg( QgsPostgresConn::quotedIdentifier( name ) ) );
.arg( QgsPostgresConn::quotedIdentifier( schema ), QgsPostgresConn::quotedIdentifier( name ) ) );
}

void QgsPostgresProviderConnection::createVectorTable( const QString &schema,
@@ -151,9 +150,9 @@ void QgsPostgresProviderConnection::dropRasterTable( const QString &schema, cons
void QgsPostgresProviderConnection::renameTablePrivate( const QString &schema, const QString &name, const QString &newName ) const
{
executeSqlPrivate( QStringLiteral( "ALTER TABLE %1.%2 RENAME TO %3" )
.arg( QgsPostgresConn::quotedIdentifier( schema ) )
.arg( QgsPostgresConn::quotedIdentifier( name ) )
.arg( QgsPostgresConn::quotedIdentifier( newName ) ) );
.arg( QgsPostgresConn::quotedIdentifier( schema ),
QgsPostgresConn::quotedIdentifier( name ),
QgsPostgresConn::quotedIdentifier( newName ) ) );
}

void QgsPostgresProviderConnection::renameVectorTable( const QString &schema, const QString &name, const QString &newName ) const
@@ -180,16 +179,16 @@ void QgsPostgresProviderConnection::dropSchema( const QString &name, bool force
{
checkCapability( Capability::DropSchema );
executeSqlPrivate( QStringLiteral( "DROP SCHEMA %1 %2" )
.arg( QgsPostgresConn::quotedIdentifier( name ) )
.arg( force ? QStringLiteral( "CASCADE" ) : QString() ) );
.arg( QgsPostgresConn::quotedIdentifier( name ),
force ? QStringLiteral( "CASCADE" ) : QString() ) );
}

void QgsPostgresProviderConnection::renameSchema( const QString &name, const QString &newName ) const
{
checkCapability( Capability::RenameSchema );
executeSqlPrivate( QStringLiteral( "ALTER SCHEMA %1 RENAME TO %2" )
.arg( QgsPostgresConn::quotedIdentifier( name ) )
.arg( QgsPostgresConn::quotedIdentifier( newName ) ) );
.arg( QgsPostgresConn::quotedIdentifier( name ),
QgsPostgresConn::quotedIdentifier( newName ) ) );
}

QgsAbstractDatabaseProviderConnection::QueryResult QgsPostgresProviderConnection::execSql( const QString &sql, QgsFeedback *feedback ) const
@@ -606,8 +605,8 @@ QList<QgsPostgresProviderConnection::TableProperty> QgsPostgresProviderConnectio
ORDER BY CASE WHEN indisprimary THEN 1 ELSE 2 END LIMIT 1)
SELECT attname FROM pg_index,pg_attribute, pkrelid
WHERE indexrelid=pkrelid.idxri AND indrelid=attrelid AND pg_attribute.attnum=any(pg_index.indkey);
)" ).arg( QgsPostgresConn::quotedIdentifier( pr.schemaName ) )
.arg( QgsPostgresConn::quotedIdentifier( pr.tableName ) ) );
)" ).arg( QgsPostgresConn::quotedIdentifier( pr.schemaName ),
QgsPostgresConn::quotedIdentifier( pr.tableName ) ) );
QStringList pkNames;
for ( const auto &pk : qgis::as_const( pks ) )
{
@@ -761,14 +760,16 @@ QgsFields QgsPostgresProviderConnection::fields( const QString &schema, const QS
QgsDataSourceUri tUri { tableUri( schema, tableName ) };
if ( tableInfo.geometryColumnTypes().count( ) > 1 )
{
TableProperty::GeometryColumnType geomCol { tableInfo.geometryColumnTypes().first() };
const auto geomColTypes( tableInfo.geometryColumnTypes() );
TableProperty::GeometryColumnType geomCol { geomColTypes.first() };
tUri.setGeometryColumn( tableInfo.geometryColumn() );
tUri.setWkbType( geomCol.wkbType );
tUri.setSrid( QString::number( geomCol.crs.postgisSrid() ) );
}
if ( tableInfo.primaryKeyColumns().count() > 0 )
{
tUri.setKeyColumn( tableInfo.primaryKeyColumns().first() );
const auto constPkCols( tableInfo.primaryKeyColumns() );
tUri.setKeyColumn( constPkCols.first() );
}
tUri.setParam( QStringLiteral( "checkPrimaryKeyUnicity" ), QLatin1String( "0" ) );
QgsVectorLayer::LayerOptions options { false, true };
@@ -372,7 +372,7 @@ int main( int argc, char *argv[] )
// Take Host header if defined
if ( headers.contains( QStringLiteral( "Host" ) ) )
{
url = QStringLiteral( "http://%1%2" ).arg( headers.value( QStringLiteral( "Host" ) ) ).arg( path );
url = QStringLiteral( "http://%1%2" ).arg( headers.value( QStringLiteral( "Host" ) ), path );
}
else
{
@@ -150,8 +150,9 @@ QString QgsServerOgcApi::contentTypeToExtension( const ContentType &ct )
QgsServerOgcApi::ContentType QgsServerOgcApi::contenTypeFromExtension( const std::string &extension )
{
const QString exts = QString::fromStdString( extension );
for ( auto it = QgsServerOgcApi::contentTypeMimes().constBegin();
it != QgsServerOgcApi::contentTypeMimes().constEnd();
const auto constMimeTypes( QgsServerOgcApi::contentTypeMimes() );
for ( auto it = constMimeTypes.constBegin();
it != constMimeTypes.constEnd();
++it )
{
const auto constValues = it.value();
@@ -67,7 +67,8 @@ QgsServerOgcApiHandler::~QgsServerOgcApiHandler()

QgsServerOgcApi::ContentType QgsServerOgcApiHandler::defaultContentType() const
{
return contentTypes().size() > 0 ? contentTypes().first() : QgsServerOgcApi::ContentType::JSON;
const auto constContentTypes( contentTypes() );
return constContentTypes.size() > 0 ? constContentTypes.first() : QgsServerOgcApi::ContentType::JSON;
}

QList<QgsServerOgcApi::ContentType> QgsServerOgcApiHandler::contentTypes() const
@@ -83,8 +84,9 @@ void QgsServerOgcApiHandler::handleRequest( const QgsServerApiContext &context )

QString QgsServerOgcApiHandler::contentTypeForAccept( const QString &accept ) const
{
for ( auto it = QgsServerOgcApi::contentTypeMimes().constBegin();
it != QgsServerOgcApi::contentTypeMimes().constEnd(); ++it )
const auto constContentTypes( QgsServerOgcApi::contentTypeMimes() );
for ( auto it = constContentTypes.constBegin();
it != constContentTypes.constEnd(); ++it )
{
const auto constValues = it.value();
for ( const auto &value : constValues )
@@ -452,8 +454,9 @@ QgsServerOgcApi::ContentType QgsServerOgcApiHandler::contentTypeFromRequest( con
const QString ctFromAccept { contentTypeForAccept( accept ) };
if ( ! ctFromAccept.isEmpty() )
{
auto it = QgsServerOgcApi::contentTypeMimes().constBegin();
while ( ! found && it != QgsServerOgcApi::contentTypeMimes().constEnd() )
const auto constContentTypes( QgsServerOgcApi::contentTypeMimes() );
auto it = constContentTypes.constBegin();
while ( ! found && it != constContentTypes.constEnd() )
{
int idx = it.value().indexOf( ctFromAccept );
if ( idx >= 0 )
@@ -94,7 +94,8 @@ QList<QgsGeometry> QgsServerParameterDefinition::toGeomList( bool &ok, const cha
ok = true;
QList<QgsGeometry> geoms;

for ( const auto &wkt : toStringList( delimiter ) )
const auto constStringList( toStringList( delimiter ) );
for ( const auto &wkt : constStringList )
{
const QgsGeometry g( QgsGeometry::fromWkt( wkt ) );

@@ -117,7 +118,8 @@ QList<QColor> QgsServerParameterDefinition::toColorList( bool &ok, const char de
ok = true;
QList<QColor> colors;

for ( const auto &part : toStringList( delimiter ) )
const auto constStringList( toStringList( delimiter ) );
for ( const auto &part : constStringList )
{
QString cStr( part );
if ( !cStr.isEmpty() )
@@ -148,7 +150,8 @@ QList<int> QgsServerParameterDefinition::toIntList( bool &ok, const char delimit
ok = true;
QList<int> ints;

for ( const auto &part : toStringList( delimiter ) )
const auto constStringList( toStringList( delimiter ) );
for ( const auto &part : constStringList )
{
const int val = part.toInt( &ok );

@@ -168,7 +171,8 @@ QList<double> QgsServerParameterDefinition::toDoubleList( bool &ok, const char d
ok = true;
QList<double> vals;

for ( const auto &part : toStringList( delimiter ) )
const auto constStringList( toStringList( delimiter ) );
for ( const auto &part : constStringList )
{
const double val = part.toDouble( &ok );

@@ -439,7 +443,8 @@ QUrlQuery QgsServerParameters::urlQuery() const
{
query.clear();

for ( auto param : toMap().toStdMap() )
const auto constMap( toMap().toStdMap() );
for ( const auto &param : constMap )
{
query.addQueryItem( param.first, param.second );
}
@@ -553,7 +558,8 @@ void QgsServerParameters::load( const QUrlQuery &query )
cleanQuery.setQuery( query.query().replace( '+', QLatin1String( "%20" ) ) );

// load parameters
for ( const auto &item : cleanQuery.queryItems( QUrl::FullyDecoded ) )
const auto constQueryItems( cleanQuery.queryItems( QUrl::FullyDecoded ) );
for ( const auto &item : constQueryItems )
{
const QgsServerParameter::Name name = QgsServerParameter::name( item.first );
if ( name >= 0 )
@@ -88,7 +88,9 @@ bool QgsServerPlugins::initPlugins( QgsServerInterface *interface )
//Init plugins: loads a list of installed plugins and filter them
//for "server" metadata
bool atLeastOneEnabled = false;
for ( const QString &pluginName : sPythonUtils->pluginList() )

const auto constPluginList( sPythonUtils->pluginList() );
for ( const QString &pluginName : constPluginList )
{
QString pluginService = sPythonUtils->getPluginMetadata( pluginName, QStringLiteral( "server" ) );
if ( pluginService == QLatin1String( "True" ) )
@@ -95,15 +95,14 @@ QVariant QgsServerQueryStringParameter::value( const QgsServerApiContext &contex

if ( ! ok )
{
throw QgsServerApiBadRequestException( QStringLiteral( "Argument '%1' could not be converted to %2" ).arg( mName )
.arg( typeName( mType ) ) );
throw QgsServerApiBadRequestException( QStringLiteral( "Argument '%1' could not be converted to %2" ).arg( mName, typeName( mType ) ) );
}
}

// 4: check custom validation
if ( mCustomValidator && ! mCustomValidator( context, value ) )
{
throw QgsServerApiBadRequestException( QStringLiteral( "Argument '%1' is not valid. %2" ).arg( name() ).arg( description() ) );
throw QgsServerApiBadRequestException( QStringLiteral( "Argument '%1' is not valid. %2" ).arg( name(), description() ) );
}
}
return value;
@@ -356,7 +356,8 @@ void QgsServerSettings::loadQSettings( const QString &envOptPath ) const

void QgsServerSettings::prioritize( const QMap<QgsServerSettingsEnv::EnvVar, QString> &env )
{
for ( QgsServerSettingsEnv::EnvVar e : env.keys() )
const auto constKeys( env.keys() );
for ( const QgsServerSettingsEnv::EnvVar &e : constKeys )
{
Setting s = mSettings[ e ];

@@ -405,7 +406,7 @@ void QgsServerSettings::logSummary() const
const QMetaEnum metaEnumSrc( QMetaEnum::fromType<QgsServerSettingsEnv::Source>() );

QgsMessageLog::logMessage( "QGIS Server Settings: ", "Server", Qgis::Info );
for ( Setting s : mSettings )
for ( const Setting &s : qgis::as_const( mSettings ) )
{
const QString src = metaEnumSrc.valueToKey( s.src );
const QString var = name( s.envVar );
@@ -67,7 +67,8 @@ void QgsServiceNativeLoader::loadModules( const QString &modulePath, QgsServiceR

// qDebug() << QString( "Checking %1 for native services modules" ).arg( moduleDir.path() );

for ( const QFileInfo &fi : moduleDir.entryInfoList() )
const auto constFiList( moduleDir.entryInfoList() );
for ( const QFileInfo &fi : constFiList )
{
QgsServiceModule *module = loadNativeModule( fi.filePath() );
if ( module )
@@ -103,7 +103,7 @@ QMap<QString, QString> QgsLandingPageUtils::projects( const QgsServerSettings &s
}
else
{
QgsMessageLog::logMessage( QStringLiteral( "%1 entry '%2' was not found: skipping." ).arg( envDirName ).arg( path ), QStringLiteral( "Landing Page" ), Qgis::MessageLevel::Warning );
QgsMessageLog::logMessage( QStringLiteral( "%1 entry '%2' was not found: skipping." ).arg( envDirName, path ), QStringLiteral( "Landing Page" ), Qgis::MessageLevel::Warning );
}
}
else
@@ -135,7 +135,7 @@ QMap<QString, QString> QgsLandingPageUtils::projects( const QgsServerSettings &s
}
else
{
QgsMessageLog::logMessage( QStringLiteral( "%1 entry '%2' was not found or has not projects: skipping." ).arg( envPgName ).arg( connectionString ), QStringLiteral( "Landing Page" ), Qgis::MessageLevel::Warning );
QgsMessageLog::logMessage( QStringLiteral( "%1 entry '%2' was not found or has not projects: skipping." ).arg( envPgName, connectionString ), QStringLiteral( "Landing Page" ), Qgis::MessageLevel::Warning );
}
}
else
@@ -531,9 +531,10 @@ json QgsLandingPageUtils::projectInfo( const QString &projectUri, const QgsServe
// Keywords
json jKeywords = json::object();
const auto &cKw { md.keywords().keys() };
const auto &cVals { md.keywords() };
for ( const auto &k : cKw )
{
jKeywords[ k.toStdString() ] = jList( md.keywords()[ k ] );
jKeywords[ k.toStdString() ] = jList( cVals[ k ] );
}
layerMetadata[ "keywords" ] = jKeywords;
layerMetadata[ "language" ] = md.language( ).toStdString();
@@ -141,7 +141,7 @@ def setUp(self):
os.environ["QGIS_SERVER_DISABLED_APIS"] = "Landing Page"

def tearDown(self):
""""Cleanup env"""
"""Cleanup env"""

super().tearDown()
try:

0 comments on commit 112810c

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