Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
...and DEFINITELY no 'foreach'!!
  • Loading branch information
nyalldawson committed Mar 21, 2021
1 parent 2559555 commit 55a79ac
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/app/qtmain_android.cpp
Expand Up @@ -82,7 +82,7 @@ static jboolean startQtApp( JNIEnv *env, jobject /*object*/, jstring paramsStrin
env->ReleaseStringUTFChars( environmentString, nativeString );
m_applicationParams = string.split( '\t' );
qDebug() << "environmentString" << string << m_applicationParams;
foreach ( string, m_applicationParams )
for ( string : m_applicationParams )
if ( putenv( string.constData() ) )
qWarning() << "Can't set environment" << string;

Expand Down
2 changes: 1 addition & 1 deletion src/core/expression/qgsexpressionfunction.cpp
Expand Up @@ -7351,7 +7351,7 @@ const QStringList &QgsExpression::BuiltinFunctions()


QgsArrayForeachExpressionFunction::QgsArrayForeachExpressionFunction()
: QgsExpressionFunction( QStringLiteral( "array_foreach" ), QgsExpressionFunction::ParameterList()
: QgsExpressionFunction( QStringLiteral( "array_foreach" ), QgsExpressionFunction::ParameterList() // skip-keyword-check
<< QgsExpressionFunction::Parameter( QStringLiteral( "array" ) )
<< QgsExpressionFunction::Parameter( QStringLiteral( "expression" ) ),
QStringLiteral( "Arrays" ) )
Expand Down
2 changes: 1 addition & 1 deletion src/core/expression/qgsexpressionfunction.h
Expand Up @@ -522,7 +522,7 @@ class QgsStaticExpressionFunction : public QgsExpressionFunction
};

/**
* \brief Handles the ``array_foreach(array, expression)`` expression function.
* \brief Handles the array looping``array_Foreach(array, expression)`` expression function.
* It temporarily appends a new scope to the expression context.
*
* \ingroup core
Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/feature.cpp
Expand Up @@ -1660,7 +1660,7 @@ std::size_t FeaturePart::createCandidatesForPolygon( std::vector< std::unique_pt
std::vector< OrientedConvexHullBoundingBox > boxes;
boxes.reserve( shapes_final.size() );

// Compute bounding box foreach finalShape
// Compute bounding box for each finalShape
while ( !shapes_final.isEmpty() )
{
PointSet *shape = shapes_final.takeFirst();
Expand Down
4 changes: 2 additions & 2 deletions src/core/pal/pal.cpp
Expand Up @@ -311,7 +311,7 @@ std::unique_ptr<Problem> Pal::extract( const QgsRectangle &extent, const QgsGeom
}

int idlp = 0;
for ( std::size_t i = 0; i < prob->mFeatureCount; i++ ) /* foreach feature into prob */
for ( std::size_t i = 0; i < prob->mFeatureCount; i++ ) /* for each feature into prob */
{
std::unique_ptr< Feats > feat = std::move( features.front() );
features.pop_front();
Expand Down Expand Up @@ -424,7 +424,7 @@ std::unique_ptr<Problem> Pal::extract( const QgsRectangle &extent, const QgsGeom

double amin[2];
double amax[2];
while ( !features.empty() ) // foreach feature
while ( !features.empty() ) // for each feature
{
if ( isCanceled() )
return nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/core/pal/problem.cpp
Expand Up @@ -90,7 +90,7 @@ void Problem::reduce()
for ( i = 0; i < static_cast< int >( mFeatureCount ); i++ )
{
// ok[i] = true;
for ( j = 0; j < mFeatNbLp[i]; j++ ) // foreach candidate
for ( j = 0; j < mFeatNbLp[i]; j++ ) // for each candidate
{
if ( !ok[mFeatStartId[i] + j] )
{
Expand Down Expand Up @@ -503,7 +503,7 @@ inline Chain *Problem::chain( int seed )
{
conflicts.clear();
}
} // end foreach labelposition
} // end for each labelposition

if ( next_seed == -1 )
{
Expand Down
2 changes: 1 addition & 1 deletion src/providers/grass/qgsgrassgislib.cpp
Expand Up @@ -455,7 +455,7 @@ QgsGrassGisLib::Raster QgsGrassGisLib::raster( QString name )
{
QgsDebugMsg( "name = " + name );

foreach ( Raster raster, mRasters )
for ( Raster raster : mRasters )
{
if ( raster.name == name ) return raster;
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/mssql/qgsmssqlfeatureiterator.cpp
Expand Up @@ -498,7 +498,7 @@ bool QgsMssqlFeatureIterator::fetchFeature( QgsFeature &feature )
case PktFidMap:
{
QVariantList primaryKeyVals;
foreach ( int idx, mSource->mPrimaryKeyAttrs )
for ( int idx : mSource->mPrimaryKeyAttrs )
{
QgsField fld = mSource->mFields.at( idx );

Expand Down
4 changes: 2 additions & 2 deletions src/providers/oracle/ocispatial/qsql_ocispatial.cpp
Expand Up @@ -657,14 +657,14 @@ int QOCISpatialResultPrivate::bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError
geometryInd->elem_info = g.eleminfo.size() == 0 ? OCI_IND_NULL : OCI_IND_NOTNULL;
geometryInd->ordinates = g.ordinates.size() == 0 ? OCI_IND_NULL : OCI_IND_NOTNULL;

foreach ( int e, g.eleminfo )
for ( int e : g.eleminfo )
{
OCINumber n;
OCI_VERIFY_E( err, OCINumberFromInt( err, &e, sizeof( int ), OCI_NUMBER_SIGNED, &n ) );
OCI_VERIFY_E( err, OCICollAppend( env, err, &n, nullptr, geometryObj->elem_info ) );
}

foreach ( double o, g.ordinates )
for ( double o : g.ordinates )
{
OCINumber n;
OCI_VERIFY_E( err, OCINumberFromReal( err, &o, sizeof( double ), &n ) );
Expand Down
4 changes: 2 additions & 2 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -1734,8 +1734,8 @@ namespace QgsWms
parentElem.appendChild( nameElem );
}

QList<QgsAttributeEditorElement *> children = container->children();
foreach ( const QgsAttributeEditorElement *child, children )
const QList<QgsAttributeEditorElement *> children = container->children();
for ( const QgsAttributeEditorElement *child : children )
{
if ( child->type() == QgsAttributeEditorElement::AeTypeContainer )
{
Expand Down
3 changes: 3 additions & 0 deletions tests/code_layout/test_banned_keywords.sh
Expand Up @@ -134,6 +134,9 @@ HINTS[36]="Use \brief instead (works correct with Python docstrings)"
KEYWORDS[37]="Q_FOREACH"
HINTS[37]="Use range based for loops instead"

KEYWORDS[38]="foreach"
HINTS[38]="Use range based for loops instead"

RES=
DIR=$(git rev-parse --show-toplevel)

Expand Down

0 comments on commit 55a79ac

Please sign in to comment.