Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport cppcheck error fixes #59091

Merged
merged 30 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2fa964c
Avoid some false-positive cppcheck functionConst warnings
nyalldawson Oct 15, 2024
fed04fa
Rename private method to sensible name
nyalldawson Oct 15, 2024
24a3550
Remove unused legacy pal class
nyalldawson Oct 15, 2024
0754359
Fix cppcheck 'function can be const' warnings
nyalldawson Oct 15, 2024
db3c6dc
Const
nyalldawson Oct 15, 2024
923b577
Add docs
nyalldawson Oct 15, 2024
08c0791
Define macros for cppcheck
nyalldawson Oct 15, 2024
2d71d00
Avoid some cppcheck false positives
nyalldawson Oct 15, 2024
99c8c03
Fix some (false positive) cppcheck uninitialized variable warnings
nyalldawson Oct 15, 2024
d7fc1b8
Uninitialized member fixes
nyalldawson Oct 15, 2024
0029bbf
Remove duplicate methods defined in subclasses
nyalldawson Oct 15, 2024
69d221a
Remove duplicate inherited members
nyalldawson Oct 15, 2024
34d52fd
Fix ignored release value warning
nyalldawson Oct 15, 2024
3acebb7
Suppress some duplInheritedMember warnings
nyalldawson Oct 15, 2024
3ace166
Avoid false-positive cppcheck missingMemberCopy warnings
nyalldawson Oct 15, 2024
db24c27
Suppress cppcheck warning
nyalldawson Oct 15, 2024
45fe4eb
Remove broken swap methods, replace with standard assignment op
nyalldawson Oct 15, 2024
85b98f2
Fix/suppress more duplInheritedMember warnings
nyalldawson Oct 15, 2024
461203c
Fix assert with side effects warning
nyalldawson Oct 15, 2024
4b7332c
Fix out of bound access
nyalldawson Oct 15, 2024
f46721f
Suppress some possibly valid cppcheck copy member warnings
nyalldawson Oct 15, 2024
168a7d7
Fix unused return value warning
nyalldawson Oct 15, 2024
6bdfca7
Suppress more duplInheritedMember warnings
nyalldawson Oct 15, 2024
a5c1510
Fix uninitialized member
nyalldawson Oct 15, 2024
55e30f7
Fix nullptr connection
nyalldawson Oct 15, 2024
0f60184
Suppress warnings
nyalldawson Oct 15, 2024
2f596e4
qgsgeometrycollection: Remove uneeded clearCache call in operator=
ptitjano Sep 5, 2024
93c1f1e
Mark method as const
nyalldawson Oct 15, 2024
ca0dd7c
qgscompoundcurve: Remove uneeded clearCache call in operator=
ptitjano Sep 5, 2024
70c5ae3
qgscurvepolygon: Remove uneeded clearCache call in operator=
ptitjano Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Returns a list of nodes of a specific ``type``

static QgsRasterCalcNode *parseRasterCalcString( const QString &str, QString &parserErrorMsg ) /Factory/;

QStringList referencedLayerNames( );
QStringList referencedLayerNames() const;
%Docstring
Returns a list of raster layer names that are referenced in the formula without the quotation marks.
It uses QgsRasterCalcNode.cleanRasterReferences
Expand All @@ -114,7 +114,7 @@ It uses QgsRasterCalcNode.cleanRasterReferences
since QGIS 3.22
%End

QStringList cleanRasterReferences();
QStringList cleanRasterReferences() const;
%Docstring
Returns a list of raster layer references that are addressed in the formula, without quotation marks.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ The optional ``providerKey`` string can be used to specify the key for the :py:c
virtual QgsAbstractDatabaseProviderConnection *databaseConnection() const;


static QIcon iconDataCollection();
%Docstring
Returns the standard browser data collection icon.

.. seealso:: :py:func:`iconDir`
%End

};


Expand Down
5 changes: 0 additions & 5 deletions python/PyQt6/core/auto_generated/browser/qgslayeritem.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ Returns the layer item type corresponding to a :py:class:`QgsMapLayer` ``layer``
QString uri() const;
%Docstring
Returns layer uri or empty string if layer cannot be created
%End

QString providerKey() const;
%Docstring
Returns provider key
%End

QStringList supportedCrs() const;
Expand Down
2 changes: 1 addition & 1 deletion python/PyQt6/core/auto_generated/qgslegendstyle.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Sets the text ``format`` used for rendering this legend component.
.. versionadded:: 3.30
%End

double margin( Side side );
double margin( Side side ) const;
%Docstring
Returns the margin (in mm) for the specified ``side`` of the component.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Generates a new RGBA value based on one input ``value``.
int *returnRedValue /Out/,
int *returnGreenValue /Out/,
int *returnBlueValue /Out/,
int *returnAlpha /Out/ );
int *returnAlpha /Out/ ) const;
%Docstring
Generates a new RGBA value based on an original RGBA value.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ Converts the category to a matching SLD rule, within the specified DOM document
%End

protected:

void swap( QgsRendererCategory &other );
};

typedef QList<QgsRendererCategory> QgsCategoryList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ class QgsCptCityArchive
static QMap< QString, QString > copyingInfo( const QString &fileName );
static QMap< QString, QString > description( const QString &fileName );

bool isEmpty();
bool isEmpty() const;
%Docstring
Returns ``True`` if archive is empty
%End
QString archiveName() const;
static void initArchives( bool loadAll = false );
static void initArchive( const QString &archiveName, const QString &archiveBaseDir );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ Returns the expression related to the end extremity value for width.
use dataDefinedProperty( :py:class:`QgsSymbolLayer`.PropertyLineEndWidthValue ) instead.
%End


void setWidthUnit( Qgis::RenderUnit strokeWidthUnit );
%Docstring
Sets the width unit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Create a new QgsMaskMarkerSymbolLayer

virtual void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size );


bool enabled() const;
%Docstring
Whether some masked symbol layers are defined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ Creates a DOM element representing the range in SLD format.
%End

protected:

void swap( QgsRendererRange &other );
};

typedef QList<QgsRendererRange> QgsRangeList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ Overridden to prepare base call and avoid crash due to specific QT versions
%End

protected:
void init();

void collapseExpandFixes();
%Docstring
Expand All @@ -126,6 +125,7 @@ Visual fixes for when group box is collapsed/expanded
void clearModifiers();



};


Expand Down Expand Up @@ -204,12 +204,10 @@ The configuration path to which it is saved is defined by
%End

protected:
void init();
virtual void showEvent( QShowEvent *event );

QString saveKey() const;


};

/************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Returns a list of nodes of a specific ``type``

static QgsRasterCalcNode *parseRasterCalcString( const QString &str, QString &parserErrorMsg ) /Factory/;

QStringList referencedLayerNames( );
QStringList referencedLayerNames() const;
%Docstring
Returns a list of raster layer names that are referenced in the formula without the quotation marks.
It uses QgsRasterCalcNode.cleanRasterReferences
Expand All @@ -114,7 +114,7 @@ It uses QgsRasterCalcNode.cleanRasterReferences
since QGIS 3.22
%End

QStringList cleanRasterReferences();
QStringList cleanRasterReferences() const;
%Docstring
Returns a list of raster layer references that are addressed in the formula, without quotation marks.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ The optional ``providerKey`` string can be used to specify the key for the :py:c
virtual QgsAbstractDatabaseProviderConnection *databaseConnection() const;


static QIcon iconDataCollection();
%Docstring
Returns the standard browser data collection icon.

.. seealso:: :py:func:`iconDir`
%End

};


Expand Down
5 changes: 0 additions & 5 deletions python/core/auto_generated/browser/qgslayeritem.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ Returns the layer item type corresponding to a :py:class:`QgsMapLayer` ``layer``
QString uri() const;
%Docstring
Returns layer uri or empty string if layer cannot be created
%End

QString providerKey() const;
%Docstring
Returns provider key
%End

QStringList supportedCrs() const;
Expand Down
2 changes: 1 addition & 1 deletion python/core/auto_generated/qgslegendstyle.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Sets the text ``format`` used for rendering this legend component.
.. versionadded:: 3.30
%End

double margin( Side side );
double margin( Side side ) const;
%Docstring
Returns the margin (in mm) for the specified ``side`` of the component.

Expand Down
2 changes: 1 addition & 1 deletion python/core/auto_generated/raster/qgsrastershader.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Generates a new RGBA value based on one input ``value``.
int *returnRedValue /Out/,
int *returnGreenValue /Out/,
int *returnBlueValue /Out/,
int *returnAlpha /Out/ );
int *returnAlpha /Out/ ) const;
%Docstring
Generates a new RGBA value based on an original RGBA value.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ Converts the category to a matching SLD rule, within the specified DOM document
%End

protected:

void swap( QgsRendererCategory &other );
};

typedef QList<QgsRendererCategory> QgsCategoryList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ class QgsCptCityArchive
static QMap< QString, QString > copyingInfo( const QString &fileName );
static QMap< QString, QString > description( const QString &fileName );

bool isEmpty();
bool isEmpty() const;
%Docstring
Returns ``True`` if archive is empty
%End
QString archiveName() const;
static void initArchives( bool loadAll = false );
static void initArchive( const QString &archiveName, const QString &archiveBaseDir );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ Returns the expression related to the end extremity value for width.
use dataDefinedProperty( :py:class:`QgsSymbolLayer`.PropertyLineEndWidthValue ) instead.
%End


void setWidthUnit( Qgis::RenderUnit strokeWidthUnit );
%Docstring
Sets the width unit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Create a new QgsMaskMarkerSymbolLayer

virtual void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size );


bool enabled() const;
%Docstring
Whether some masked symbol layers are defined
Expand Down
2 changes: 0 additions & 2 deletions python/core/auto_generated/symbology/qgsrendererrange.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ Creates a DOM element representing the range in SLD format.
%End

protected:

void swap( QgsRendererRange &other );
};

typedef QList<QgsRendererRange> QgsRangeList;
Expand Down
4 changes: 1 addition & 3 deletions python/gui/auto_generated/qgscollapsiblegroupbox.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ Overridden to prepare base call and avoid crash due to specific QT versions
%End

protected:
void init();

void collapseExpandFixes();
%Docstring
Expand All @@ -126,6 +125,7 @@ Visual fixes for when group box is collapsed/expanded
void clearModifiers();



};


Expand Down Expand Up @@ -204,12 +204,10 @@ The configuration path to which it is saved is defined by
%End

protected:
void init();
virtual void showEvent( QShowEvent *event );

QString saveKey() const;


};

/************************************************************************
Expand Down
2 changes: 2 additions & 0 deletions scripts/cppcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ cppcheck --library=qt.cfg --inline-suppr \
-DCMAKE_SOURCE_DIR="/foo/bar" \
-DQ_NOWARN_DEPRECATED_PUSH= \
-DQ_NOWARN_DEPRECATED_POP= \
-DQ_NOWARN_UNREACHABLE_PUSH= \
-DQ_NOWARN_UNREACHABLE_POP= \
-DQ_DECLARE_OPAQUE_POINTER= \
-DQGIS_PROTECT_QOBJECT_THREAD_ACCESS = \
-DQ_DECLARE_SQLDRIVER_PRIVATE = \
Expand Down
2 changes: 1 addition & 1 deletion src/3d/terrain/qgsflatterraingenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class _3D_EXPORT QgsFlatTerrainGenerator : public QgsTerrainGenerator
//! Sets CRS of the terrain
void setCrs( const QgsCoordinateReferenceSystem &crs );
//! Returns CRS of the terrain
QgsCoordinateReferenceSystem crs() const { return mCrs; }
QgsCoordinateReferenceSystem crs() const { return mCrs; } // cppcheck-suppress duplInheritedMember

private:

Expand Down
2 changes: 1 addition & 1 deletion src/3d/terrain/qgsonlineterraingenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class _3D_EXPORT QgsOnlineTerrainGenerator : public QgsTerrainGenerator
//! Sets CRS of the terrain
void setCrs( const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context );
//! Returns CRS of the terrain
QgsCoordinateReferenceSystem crs() const { return mCrs; }
QgsCoordinateReferenceSystem crs() const { return mCrs; } // cppcheck-suppress duplInheritedMember

//! Sets resolution of the generator (how many elevation samples on one side of a terrain tile)
void setResolution( int resolution ) { mResolution = resolution; updateGenerator(); }
Expand Down
8 changes: 4 additions & 4 deletions src/analysis/processing/qgsalgorithmconcavehull.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ class QgsConcaveHullAlgorithm : public QgsProcessingAlgorithm
void concaveHullQgis( std::unique_ptr< QgsFeatureSink > &sink, const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback );

std::unique_ptr< QgsProcessingFeatureSource > mSource;
double mPercentage;
bool mAllowHoles;
bool mSplitMultipart;
double mStep;
double mPercentage = 0;
bool mAllowHoles = false;
bool mSplitMultipart = false;
double mStep = 0;
};

///@endcond PRIVATE
Expand Down
8 changes: 2 additions & 6 deletions src/analysis/processing/qgsalgorithmdrape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,10 @@ bool QgsDrapeAlgorithmBase::prepareAlgorithm( const QVariantMap &parameters, Qgs
.arg( layer->bandCount() ) );
mRasterExtent = layer->extent();

std::unique_ptr< QgsRasterInterface > provider( layer->dataProvider()->clone() );
QgsRasterDataProvider *dp = dynamic_cast< QgsRasterDataProvider * >( provider.get() );
if ( !dp )
mRasterProvider.reset( layer->dataProvider()->clone() );
if ( !mRasterProvider )
throw QgsProcessingException( invalidRasterError( parameters, QStringLiteral( "RASTER" ) ) );

mRasterProvider.reset( dp );
provider.release();

return true;
}

Expand Down
6 changes: 3 additions & 3 deletions src/analysis/processing/qgsalgorithmvoronoipolygons.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class QgsVoronoiPolygonsAlgorithm : public QgsProcessingAlgorithm
QString voronoiWithoutAttributes( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback );

std::unique_ptr< QgsProcessingFeatureSource > mSource;
double mBuffer;
double mTolerance;
bool mCopyAttributes;
double mBuffer = 0;
double mTolerance = 0;
bool mCopyAttributes = false;
};

///@endcond PRIVATE
Expand Down
6 changes: 3 additions & 3 deletions src/analysis/processing/qgsalgorithmxyztiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ class QgsXyzTilesBaseAlgorithm : public QgsProcessingAlgorithm
QgsCoordinateTransform mSrc2Wgs;
QgsCoordinateTransform mWgs2Mercator;
QgsRectangle mWgs84Extent;
QgsProcessingFeedback *mFeedback;
QgsProcessingFeedback *mFeedback = nullptr;
long long mTotalTiles = 0;
long long mProcessedTiles = 0;
QgsCoordinateTransformContext mTransformContext;
QEventLoop *mEventLoop;
QEventLoop *mEventLoop = nullptr;
QList< MetaTile > mMetaTiles;
QMap< QgsMapRendererSequentialJob *, MetaTile > mRendererJobs;
};
Expand Down Expand Up @@ -158,7 +158,7 @@ class QgsXyzTilesDirectoryAlgorithm : public QgsXyzTilesBaseAlgorithm
void processMetaTile( QgsMapRendererSequentialJob *job ) override;

private:
bool mTms;
bool mTms = false;
QString mOutputDir;

};
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/raster/qgsrastercalcnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ QgsRasterCalcNode *QgsRasterCalcNode::parseRasterCalcString( const QString &str,
return localParseRasterCalcString( str, parserErrorMsg );
}

QStringList QgsRasterCalcNode::referencedLayerNames()
QStringList QgsRasterCalcNode::referencedLayerNames() const
{
QStringList referencedRasters;

Expand All @@ -439,7 +439,7 @@ QStringList QgsRasterCalcNode::referencedLayerNames()
return referencedRasters;
}

QStringList QgsRasterCalcNode::cleanRasterReferences()
QStringList QgsRasterCalcNode::cleanRasterReferences() const
{
QStringList rasterReferences;
const QList<const QgsRasterCalcNode *> rasterRefNodes = this->findNodes( QgsRasterCalcNode::Type::tRasterRef );
Expand Down
Loading
Loading