Skip to content

Commit db5dd85

Browse files
committed
Fix some more clang-tidy suggestions
1 parent e54bc9a commit db5dd85

37 files changed

+83
-80
lines changed

src/core/composer/qgscomposernodesitem.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "qgssymbol.h"
2222
#include "qgsmapsettings.h"
2323
#include <limits>
24-
#include <math.h>
24+
#include <cmath>
2525

2626
QgsComposerNodesItem::QgsComposerNodesItem( const QString& tagName,
2727
QgsComposition* c )

src/core/composer/qgscomposition.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2038,8 +2038,8 @@ QPointF QgsComposition::snapPointToGrid( QPointF scenePoint ) const
20382038
double yPage = scenePoint.y() - yOffset; //y-coordinate relative to current page
20392039

20402040
//snap x coordinate
2041-
int xRatio = static_cast< int >(( scenePoint.x() - mSnapGridOffsetX ) / mSnapGridResolution + 0.5 );
2042-
int yRatio = static_cast< int >(( yPage - mSnapGridOffsetY ) / mSnapGridResolution + 0.5 );
2041+
int xRatio = static_cast< int >(( scenePoint.x() - mSnapGridOffsetX ) / mSnapGridResolution + 0.5 ); //NOLINT
2042+
int yRatio = static_cast< int >(( yPage - mSnapGridOffsetY ) / mSnapGridResolution + 0.5 ); //NOLINT
20432043

20442044
double xSnapped = xRatio * mSnapGridResolution + mSnapGridOffsetX;
20452045
double ySnapped = yRatio * mSnapGridResolution + mSnapGridOffsetY + yOffset;

src/core/geometry/qgsinternalgeometryengine.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ QgsGeometry QgsInternalGeometryEngine::poleOfInaccessibility( double precision ,
210210
0, polygon ) );
211211
if ( bboxCell->d > bestCell->d )
212212
{
213-
bestCell.reset( bboxCell.release() );
213+
bestCell = std::move( bboxCell );
214214
}
215215

216-
while ( cellQueue.size() > 0 )
216+
while ( !cellQueue.empty() )
217217
{
218218
// pick the most promising cell from the queue
219219
std::unique_ptr< Cell > cell( cellQueue.top() );
@@ -223,7 +223,7 @@ QgsGeometry QgsInternalGeometryEngine::poleOfInaccessibility( double precision ,
223223
// update the best cell if we found a better one
224224
if ( currentCell->d > bestCell->d )
225225
{
226-
bestCell.reset( cell.release() );
226+
bestCell = std::move( cell );
227227
}
228228

229229
// do not drill down further if there's no chance of a better solution

src/core/gps/qextserialport/posix_qextserialport.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
#include <fcntl.h>
4-
#include <stdio.h>
4+
#include <cstdio>
55
#include "qextserialport.h"
66
#include <QMutexLocker>
77
#include <QDebug>

src/core/gps/qextserialport/qextserialport.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
#include <stdio.h>
3+
#include <cstdio>
44
#include "qextserialport.h"
55

66
/*!

src/core/qgsexpression.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <QUuid>
2525
#include <QMutex>
2626

27-
#include <math.h>
27+
#include <cmath>
2828
#include <limits>
2929

3030
#include "qgsdistancearea.h"

src/core/qgspallabeling.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
14741474
return;
14751475
}
14761476

1477-
int divNum = static_cast< int >(( static_cast< double >( mFeaturesToLabel ) / maxNumLabels ) + 0.5 );
1477+
int divNum = static_cast< int >(( static_cast< double >( mFeaturesToLabel ) / maxNumLabels ) + 0.5 ); // NOLINT
14781478
if ( divNum && ( mFeatsRegPal == static_cast< int >( mFeatsSendingToPal / divNum ) ) )
14791479
{
14801480
mFeatsSendingToPal += 1;

src/core/qgsproject.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ bool QgsProject::addLayer( const QDomElement &layerElem, QList<QDomNode> &broken
698698
return false;
699699
}
700700

701-
Q_CHECK_PTR( mapLayer );
701+
Q_CHECK_PTR( mapLayer ); // NOLINT
702702

703703
// have the layer restore state that is stored in Dom node
704704
if ( mapLayer->readLayerXml( layerElem, pathResolver() ) && mapLayer->isValid() )

src/core/qgssqlstatement.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include "qgssqlstatement.h"
1818

19-
#include <math.h>
19+
#include <cmath>
2020
#include <limits>
2121

2222
static const QRegExp IDENTIFIER_RE( "^[A-Za-z_\x80-\xff][A-Za-z0-9_\x80-\xff]*$" );

src/core/qgstextrenderer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ bool QgsTextFormat::containsAdvancedEffects() const
16141614

16151615
int QgsTextRenderer::sizeToPixel( double size, const QgsRenderContext& c, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale& mapUnitScale )
16161616
{
1617-
return static_cast< int >( c.convertToPainterUnits( size, unit, mapUnitScale ) + 0.5 );
1617+
return static_cast< int >( c.convertToPainterUnits( size, unit, mapUnitScale ) + 0.5 ); //NOLINT
16181618
}
16191619

16201620
void QgsTextRenderer::drawText( const QRectF& rect, double rotation, QgsTextRenderer::HAlignment alignment, const QStringList& textLines, QgsRenderContext& context, const QgsTextFormat& format, bool drawAsOutlines )
@@ -2248,7 +2248,7 @@ void QgsTextRenderer::drawShadow( QgsRenderContext& context, const QgsTextRender
22482248
bool mapUnits = shadow.blurRadiusUnit() == QgsUnitTypes::RenderMapUnits;
22492249
double radius = context.convertToPainterUnits( shadow.blurRadius(), shadow.blurRadiusUnit(), shadow.blurRadiusMapUnitScale() );
22502250
radius /= ( mapUnits ? context.scaleFactor() / component.dpiRatio : 1 );
2251-
radius = static_cast< int >( radius + 0.5 );
2251+
radius = static_cast< int >( radius + 0.5 ); //NOLINT
22522252

22532253
// TODO: add labeling gui option to adjust blurBufferClippingScale to minimize pixels, or
22542254
// to ensure shadow isn't clipped too tight. (Or, find a better method of buffering)

src/core/qgstracer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ int point2edge( const QgsTracerGraph& g, const QgsPoint& pt, int& lineVertexAfte
285285
double dist = closestSegment( e.coords, pt, vertexAfter, epsilon );
286286
if ( dist == 0 )
287287
{
288-
lineVertexAfter = vertexAfter;
288+
lineVertexAfter = vertexAfter; //NOLINT
289289
return i;
290290
}
291291
}

src/core/raster/qgsrasterfilewriter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ void QgsRasterFileWriter::globalOutputParameters( const QgsRectangle& extent, in
972972
//calculate nRows automatically for providers without exact resolution
973973
if ( nRows < 0 )
974974
{
975-
nRows = static_cast< double >( nCols ) / extent.width() * extent.height() + 0.5;
975+
nRows = static_cast< double >( nCols ) / extent.width() * extent.height() + 0.5; //NOLINT
976976
}
977977
geoTransform[0] = extent.xMinimum();
978978
geoTransform[1] = pixelSize;

src/core/symbology-ng/qgssymbollayerutils.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -3757,18 +3757,17 @@ QList<double> QgsSymbolLayerUtils::prettyBreaks( double minimum, double maximum,
37573757
int divisions = classes;
37583758
double h = highBias;
37593759
double cell;
3760-
int U;
37613760
bool small = false;
37623761
double dx = maximum - minimum;
37633762

37643763
if ( qgsDoubleNear( dx, 0.0 ) && qgsDoubleNear( maximum, 0.0 ) )
37653764
{
37663765
cell = 1.0;
37673766
small = true;
3768-
U = 1;
37693767
}
37703768
else
37713769
{
3770+
int U = 1;
37723771
cell = qMax( qAbs( minimum ), qAbs( maximum ) );
37733772
if ( adjustBias >= 1.5 * h + 0.5 )
37743773
{

src/gui/qgsgradientstopeditor.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ int QgsGradientStopEditor::findClosestStop( int x, int threshold ) const
307307
if (( threshold < 0 || currentDiff < threshold ) && currentDiff < closestDiff )
308308
{
309309
closestStop = mGradient.count() - 1;
310-
closestDiff = currentDiff;
311310
}
312311

313312
return closestStop;

src/providers/delimitedtext/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ TARGET_LINK_LIBRARIES(delimitedtextprovider
4141
qgis_gui
4242
)
4343

44+
# clang-tidy
45+
IF(CLANG_TIDY_EXE)
46+
SET_TARGET_PROPERTIES(
47+
delimitedtextprovider PROPERTIES
48+
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
49+
)
50+
ENDIF(CLANG_TIDY_EXE)
51+
4452
########################################################
4553
# Install
4654

src/providers/gdal/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ TARGET_LINK_LIBRARIES (gdalprovider
3131
qgis_gui
3232
)
3333

34+
# clang-tidy
35+
IF(CLANG_TIDY_EXE)
36+
SET_TARGET_PROPERTIES(
37+
gdalprovider PROPERTIES
38+
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
39+
)
40+
ENDIF(CLANG_TIDY_EXE)
41+
3442
INSTALL(TARGETS gdalprovider
3543
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
3644
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})

src/providers/gdal/qgsgdalprovider.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,6 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
636636
}
637637

638638
qgsFree( tmpBlock );
639-
return;
640639
}
641640

642641
//void * QgsGdalProvider::readBlock( int bandNo, QgsRectangle const & extent, int width, int height )
@@ -1769,8 +1768,8 @@ QList<QgsRasterPyramid> QgsGdalProvider::buildPyramidList( QList<int> overviewLi
17691768

17701769
QgsRasterPyramid myRasterPyramid;
17711770
myRasterPyramid.level = myDivisor;
1772-
myRasterPyramid.xDim = ( int )( 0.5 + ( myWidth / ( double )myDivisor ) );
1773-
myRasterPyramid.yDim = ( int )( 0.5 + ( myHeight / ( double )myDivisor ) );
1771+
myRasterPyramid.xDim = ( int )( 0.5 + ( myWidth / ( double )myDivisor ) ); // NOLINT
1772+
myRasterPyramid.yDim = ( int )( 0.5 + ( myHeight / ( double )myDivisor ) ); // NOLINT
17741773
myRasterPyramid.exists = false;
17751774

17761775
QgsDebugMsg( QString( "Pyramid %1 xDim %2 yDim %3" ).arg( myRasterPyramid.level ).arg( myRasterPyramid.xDim ).arg( myRasterPyramid.yDim ) );
@@ -1938,7 +1937,7 @@ void buildSupportedRasterFileFilterAndExtensions( QString & theFileFiltersString
19381937
{
19391938
myGdalDriver = GDALGetDriver( i );
19401939

1941-
Q_CHECK_PTR( myGdalDriver );
1940+
Q_CHECK_PTR( myGdalDriver ); // NOLINT
19421941

19431942
if ( !myGdalDriver )
19441943
{

src/providers/gdal/qgsgdalproviderbase.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ CPLErr QgsGdalProviderBase::gdalRasterIO( GDALRasterBandH hBand, GDALRWFlag eRWF
280280
{
281281
GDALRasterIOExtraArg extra;
282282
INIT_RASTERIO_EXTRA_ARG( extra );
283-
if ( 0 && feedback ) // disabled!
283+
if ( false && feedback ) // disabled!
284284
{
285285
// Currently the cancelation is disabled... When RasterIO call is canceled,
286286
// GDAL returns CE_Failure with error code = 0 (CPLE_None), however one would

src/providers/memory/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ TARGET_LINK_LIBRARIES(memoryprovider
1818
qgis_core
1919
)
2020

21+
# clang-tidy
22+
IF(CLANG_TIDY_EXE)
23+
SET_TARGET_PROPERTIES(
24+
memoryprovider PROPERTIES
25+
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
26+
)
27+
ENDIF(CLANG_TIDY_EXE)
28+
2129

2230
INSTALL (TARGETS memoryprovider
2331
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}

src/providers/ogr/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ IF (MSVC)
3232
SET(TARGET_LINK_LIBRARIES ${TARGET_LINK_LIBRARIE} odbc32 odbccp32)
3333
ENDIF (MSVC)
3434

35+
# clang-tidy
36+
IF(CLANG_TIDY_EXE)
37+
SET_TARGET_PROPERTIES(
38+
ogrprovider PROPERTIES
39+
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
40+
)
41+
ENDIF(CLANG_TIDY_EXE)
42+
3543
INSTALL (TARGETS ogrprovider
3644
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
3745
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})

src/providers/ogr/qgsogrdataitems.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ QgsOgrLayerItem::QgsOgrLayerItem( QgsDataItem* parent,
5555
}
5656
}
5757

58-
QgsOgrLayerItem::~QgsOgrLayerItem()
59-
{
60-
}
61-
62-
6358
bool QgsOgrLayerItem::setCrs( const QgsCoordinateReferenceSystem& crs )
6459
{
6560
if ( !( mCapabilities & SetCrs ) )
@@ -180,10 +175,6 @@ QgsOgrDataCollectionItem::QgsOgrDataCollectionItem( QgsDataItem* parent, QString
180175
{
181176
}
182177

183-
QgsOgrDataCollectionItem::~QgsOgrDataCollectionItem()
184-
{
185-
}
186-
187178
QVector<QgsDataItem*> QgsOgrDataCollectionItem::createChildren()
188179
{
189180
QVector<QgsDataItem*> children;

src/providers/ogr/qgsogrdataitems.h

-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class QgsOgrLayerItem : public QgsLayerItem
2424
Q_OBJECT
2525
public:
2626
QgsOgrLayerItem( QgsDataItem* parent, QString name, QString path, QString uri, LayerType layerType );
27-
~QgsOgrLayerItem();
2827

2928
bool setCrs( const QgsCoordinateReferenceSystem& crs ) override;
3029

@@ -37,7 +36,6 @@ class QgsOgrDataCollectionItem : public QgsDataCollectionItem
3736
Q_OBJECT
3837
public:
3938
QgsOgrDataCollectionItem( QgsDataItem* parent, QString name, QString path );
40-
~QgsOgrDataCollectionItem();
4139

4240
QVector<QgsDataItem*> createChildren() override;
4341
};

src/providers/ogr/qgsogrprovider.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2056,7 +2056,7 @@ QString createFilters( const QString& type )
20562056
{
20572057
driver = OGRGetDriver( i );
20582058

2059-
Q_CHECK_PTR( driver );
2059+
Q_CHECK_PTR( driver ); // NOLINT
20602060

20612061
if ( !driver )
20622062
{

src/providers/postgres/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ TARGET_LINK_LIBRARIES (postgresprovider
7272
qgis_gui
7373
)
7474

75+
# clang-tidy
76+
IF(CLANG_TIDY_EXE)
77+
SET_TARGET_PROPERTIES(
78+
postgresprovider PROPERTIES
79+
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
80+
)
81+
ENDIF(CLANG_TIDY_EXE)
7582

7683
########################################################
7784
# Install

src/providers/postgres/qgscolumntypethread.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ email : jef at norbit dot de
2222
#include <QMetaType>
2323
#include <climits>
2424

25-
QgsGeomColumnTypeThread::QgsGeomColumnTypeThread( QString name, bool useEstimatedMetaData, bool allowGeometrylessTables )
25+
QgsGeomColumnTypeThread::QgsGeomColumnTypeThread( const QString& name, bool useEstimatedMetaData, bool allowGeometrylessTables )
2626
: QThread()
2727
, mConn( nullptr )
2828
, mName( name )

src/providers/postgres/qgscolumntypethread.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class QgsGeomColumnTypeThread : public QThread
2828
{
2929
Q_OBJECT
3030
public:
31-
QgsGeomColumnTypeThread( QString connName, bool useEstimatedMetaData, bool allowGeometrylessTables );
31+
QgsGeomColumnTypeThread( const QString& connName, bool useEstimatedMetaData, bool allowGeometrylessTables );
3232

3333
// These functions get the layer types and pass that information out
3434
// by emitting the setLayerType() signal.

src/providers/postgres/qgspgnewconnection.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,6 @@ void QgsPgNewConnection::on_cb_geometryColumnsOnly_clicked()
178178

179179
//! End Autoconnected SLOTS *
180180

181-
QgsPgNewConnection::~QgsPgNewConnection()
182-
{
183-
}
184-
185181
void QgsPgNewConnection::testConnection()
186182
{
187183
QgsDataSourceUri uri;

src/providers/postgres/qgspgnewconnection.h

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class QgsPgNewConnection : public QDialog, private Ui::QgsPgNewConnectionBase
3232
//! Constructor
3333
QgsPgNewConnection( QWidget *parent = nullptr, const QString& connName = QString::null, Qt::WindowFlags fl = QgisGui::ModalDialogFlags );
3434

35-
~QgsPgNewConnection();
3635
//! Tests the connection using the parameters supplied
3736
void testConnection();
3837
public slots:

src/providers/postgres/qgspgtablemodel.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ QgsPgTableModel::QgsPgTableModel()
4040
setHorizontalHeaderLabels( headerLabels );
4141
}
4242

43-
QgsPgTableModel::~QgsPgTableModel()
44-
{
45-
}
46-
4743
void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty& layerProperty )
4844
{
4945
QgsDebugMsg( layerProperty.toString() );

src/providers/postgres/qgspgtablemodel.h

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class QgsPgTableModel : public QStandardItemModel
3131
Q_OBJECT
3232
public:
3333
QgsPgTableModel();
34-
~QgsPgTableModel();
3534

3635
//! Adds entry for one database table to the model
3736
void addTableEntry( const QgsPostgresLayerProperty& property );

0 commit comments

Comments
 (0)