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

cppcheck fixes for queued LTR backports branch #59102

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
dca6509
Avoid some false-positive cppcheck functionConst warnings
nyalldawson Oct 15, 2024
0bb4c3c
Rename private method to sensible name
nyalldawson Oct 15, 2024
7688da8
Remove unused legacy pal class
nyalldawson Oct 15, 2024
7056565
Fix cppcheck 'function can be const' warnings
nyalldawson Oct 15, 2024
339c624
Const
nyalldawson Oct 15, 2024
9581fac
Add docs
nyalldawson Oct 15, 2024
2f20624
Define macros for cppcheck
nyalldawson Oct 15, 2024
e562b8b
Avoid some cppcheck false positives
nyalldawson Oct 15, 2024
bc05d70
Fix some (false positive) cppcheck uninitialized variable warnings
nyalldawson Oct 15, 2024
20e4b0b
Uninitialized member fixes
nyalldawson Oct 15, 2024
ac887ee
Remove duplicate methods defined in subclasses
nyalldawson Oct 15, 2024
151e655
Remove duplicate inherited members
nyalldawson Oct 15, 2024
7470ede
Fix ignored release value warning
nyalldawson Oct 15, 2024
3d6b3f6
Suppress some duplInheritedMember warnings
nyalldawson Oct 15, 2024
6a3e0ab
Avoid false-positive cppcheck missingMemberCopy warnings
nyalldawson Oct 15, 2024
407697a
Suppress cppcheck warning
nyalldawson Oct 15, 2024
8ab81c0
Remove broken swap methods, replace with standard assignment op
nyalldawson Oct 15, 2024
2e10110
Fix/suppress more duplInheritedMember warnings
nyalldawson Oct 15, 2024
cc16cc3
Fix assert with side effects warning
nyalldawson Oct 15, 2024
11482df
Fix out of bound access
nyalldawson Oct 15, 2024
8466306
Suppress some possibly valid cppcheck copy member warnings
nyalldawson Oct 15, 2024
9766bf8
Fix unused return value warning
nyalldawson Oct 15, 2024
d7fd4e8
Suppress more duplInheritedMember warnings
nyalldawson Oct 15, 2024
0320519
Fix nullptr connection
nyalldawson Oct 15, 2024
02d4f0f
Suppress warnings
nyalldawson Oct 15, 2024
02c9cb6
qgsgeometrycollection: Remove uneeded clearCache call in operator=
ptitjano Sep 5, 2024
2beea60
Mark method as const
nyalldawson Oct 15, 2024
c1eabbf
qgscompoundcurve: Remove uneeded clearCache call in operator=
ptitjano Sep 5, 2024
a71365c
qgscurvepolygon: Remove uneeded clearCache call in operator=
ptitjano Sep 5, 2024
b989a6b
Remove duplicate equality operator for QgsPointXY
nyalldawson Oct 15, 2024
6e66a18
Fix build
nyalldawson Oct 15, 2024
ece8b84
fix layout
3nids Oct 15, 2024
191b95f
sipify
3nids Oct 15, 2024
eac800a
const
3nids Oct 15, 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
3 changes: 1 addition & 2 deletions python/PyQt6/core/auto_generated/qgspointxy.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ Compares this point with another point with a fuzzy tolerance using distance com
.. versionadded:: 3.36
%End

bool operator==( const QgsPointXY &other ) /HoldGIL/;
bool operator==( const QgsPointXY &other ) const /HoldGIL/;

bool operator!=( const QgsPointXY &other ) const /HoldGIL/;

Expand Down Expand Up @@ -310,7 +310,6 @@ Multiply x and y by the given value




/************************************************************************
* This file has been generated automatically from *
* *
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
3 changes: 1 addition & 2 deletions python/core/auto_generated/qgspointxy.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Compares this point with another point with a fuzzy tolerance
.. versionadded:: 2.9
%End

bool operator==( const QgsPointXY &other ) /HoldGIL/;
bool operator==( const QgsPointXY &other ) const /HoldGIL/;

bool operator!=( const QgsPointXY &other ) const /HoldGIL/;

Expand Down Expand Up @@ -294,7 +294,6 @@ Multiply x and y by the given value




/************************************************************************
* This file has been generated automatically from *
* *
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
4 changes: 2 additions & 2 deletions src/analysis/processing/qgsalgorithmxyztiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ 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;
Expand Down Expand Up @@ -160,7 +160,7 @@ class QgsXyzTilesDirectoryAlgorithm : public QgsXyzTilesBaseAlgorithm
void processMetaTile( QgsMapRendererSequentialJob *job ) override;

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

};
Expand Down
Loading
Loading