Skip to content

Commit

Permalink
Fix some more clang-tidy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 20, 2017
1 parent e54bc9a commit db5dd85
Show file tree
Hide file tree
Showing 37 changed files with 83 additions and 80 deletions.
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposernodesitem.cpp
Expand Up @@ -21,7 +21,7 @@
#include "qgssymbol.h"
#include "qgsmapsettings.h"
#include <limits>
#include <math.h>
#include <cmath>

QgsComposerNodesItem::QgsComposerNodesItem( const QString& tagName,
QgsComposition* c )
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposition.cpp
Expand Up @@ -2038,8 +2038,8 @@ QPointF QgsComposition::snapPointToGrid( QPointF scenePoint ) const
double yPage = scenePoint.y() - yOffset; //y-coordinate relative to current page

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

double xSnapped = xRatio * mSnapGridResolution + mSnapGridOffsetX;
double ySnapped = yRatio * mSnapGridResolution + mSnapGridOffsetY + yOffset;
Expand Down
6 changes: 3 additions & 3 deletions src/core/geometry/qgsinternalgeometryengine.cpp
Expand Up @@ -210,10 +210,10 @@ QgsGeometry QgsInternalGeometryEngine::poleOfInaccessibility( double precision ,
0, polygon ) );
if ( bboxCell->d > bestCell->d )
{
bestCell.reset( bboxCell.release() );
bestCell = std::move( bboxCell );
}

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

// do not drill down further if there's no chance of a better solution
Expand Down
2 changes: 1 addition & 1 deletion src/core/gps/qextserialport/posix_qextserialport.cpp
@@ -1,7 +1,7 @@


#include <fcntl.h>
#include <stdio.h>
#include <cstdio>
#include "qextserialport.h"
#include <QMutexLocker>
#include <QDebug>
Expand Down
2 changes: 1 addition & 1 deletion src/core/gps/qextserialport/qextserialport.cpp
@@ -1,6 +1,6 @@


#include <stdio.h>
#include <cstdio>
#include "qextserialport.h"

/*!
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsexpression.cpp
Expand Up @@ -24,7 +24,7 @@
#include <QUuid>
#include <QMutex>

#include <math.h>
#include <cmath>
#include <limits>

#include "qgsdistancearea.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgspallabeling.cpp
Expand Up @@ -1474,7 +1474,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
return;
}

int divNum = static_cast< int >(( static_cast< double >( mFeaturesToLabel ) / maxNumLabels ) + 0.5 );
int divNum = static_cast< int >(( static_cast< double >( mFeaturesToLabel ) / maxNumLabels ) + 0.5 ); // NOLINT
if ( divNum && ( mFeatsRegPal == static_cast< int >( mFeatsSendingToPal / divNum ) ) )
{
mFeatsSendingToPal += 1;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsproject.cpp
Expand Up @@ -698,7 +698,7 @@ bool QgsProject::addLayer( const QDomElement &layerElem, QList<QDomNode> &broken
return false;
}

Q_CHECK_PTR( mapLayer );
Q_CHECK_PTR( mapLayer ); // NOLINT

// have the layer restore state that is stored in Dom node
if ( mapLayer->readLayerXml( layerElem, pathResolver() ) && mapLayer->isValid() )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgssqlstatement.cpp
Expand Up @@ -16,7 +16,7 @@

#include "qgssqlstatement.h"

#include <math.h>
#include <cmath>
#include <limits>

static const QRegExp IDENTIFIER_RE( "^[A-Za-z_\x80-\xff][A-Za-z0-9_\x80-\xff]*$" );
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgstextrenderer.cpp
Expand Up @@ -1614,7 +1614,7 @@ bool QgsTextFormat::containsAdvancedEffects() const

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

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

// TODO: add labeling gui option to adjust blurBufferClippingScale to minimize pixels, or
// to ensure shadow isn't clipped too tight. (Or, find a better method of buffering)
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgstracer.cpp
Expand Up @@ -285,7 +285,7 @@ int point2edge( const QgsTracerGraph& g, const QgsPoint& pt, int& lineVertexAfte
double dist = closestSegment( e.coords, pt, vertexAfter, epsilon );
if ( dist == 0 )
{
lineVertexAfter = vertexAfter;
lineVertexAfter = vertexAfter; //NOLINT
return i;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterfilewriter.cpp
Expand Up @@ -972,7 +972,7 @@ void QgsRasterFileWriter::globalOutputParameters( const QgsRectangle& extent, in
//calculate nRows automatically for providers without exact resolution
if ( nRows < 0 )
{
nRows = static_cast< double >( nCols ) / extent.width() * extent.height() + 0.5;
nRows = static_cast< double >( nCols ) / extent.width() * extent.height() + 0.5; //NOLINT
}
geoTransform[0] = extent.xMinimum();
geoTransform[1] = pixelSize;
Expand Down
3 changes: 1 addition & 2 deletions src/core/symbology-ng/qgssymbollayerutils.cpp
Expand Up @@ -3757,18 +3757,17 @@ QList<double> QgsSymbolLayerUtils::prettyBreaks( double minimum, double maximum,
int divisions = classes;
double h = highBias;
double cell;
int U;
bool small = false;
double dx = maximum - minimum;

if ( qgsDoubleNear( dx, 0.0 ) && qgsDoubleNear( maximum, 0.0 ) )
{
cell = 1.0;
small = true;
U = 1;
}
else
{
int U = 1;
cell = qMax( qAbs( minimum ), qAbs( maximum ) );
if ( adjustBias >= 1.5 * h + 0.5 )
{
Expand Down
1 change: 0 additions & 1 deletion src/gui/qgsgradientstopeditor.cpp
Expand Up @@ -307,7 +307,6 @@ int QgsGradientStopEditor::findClosestStop( int x, int threshold ) const
if (( threshold < 0 || currentDiff < threshold ) && currentDiff < closestDiff )
{
closestStop = mGradient.count() - 1;
closestDiff = currentDiff;
}

return closestStop;
Expand Down
8 changes: 8 additions & 0 deletions src/providers/delimitedtext/CMakeLists.txt
Expand Up @@ -41,6 +41,14 @@ TARGET_LINK_LIBRARIES(delimitedtextprovider
qgis_gui
)

# clang-tidy
IF(CLANG_TIDY_EXE)
SET_TARGET_PROPERTIES(
delimitedtextprovider PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
)
ENDIF(CLANG_TIDY_EXE)

########################################################
# Install

Expand Down
8 changes: 8 additions & 0 deletions src/providers/gdal/CMakeLists.txt
Expand Up @@ -31,6 +31,14 @@ TARGET_LINK_LIBRARIES (gdalprovider
qgis_gui
)

# clang-tidy
IF(CLANG_TIDY_EXE)
SET_TARGET_PROPERTIES(
gdalprovider PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
)
ENDIF(CLANG_TIDY_EXE)

INSTALL(TARGETS gdalprovider
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
Expand Down
7 changes: 3 additions & 4 deletions src/providers/gdal/qgsgdalprovider.cpp
Expand Up @@ -636,7 +636,6 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
}

qgsFree( tmpBlock );
return;
}

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

QgsRasterPyramid myRasterPyramid;
myRasterPyramid.level = myDivisor;
myRasterPyramid.xDim = ( int )( 0.5 + ( myWidth / ( double )myDivisor ) );
myRasterPyramid.yDim = ( int )( 0.5 + ( myHeight / ( double )myDivisor ) );
myRasterPyramid.xDim = ( int )( 0.5 + ( myWidth / ( double )myDivisor ) ); // NOLINT
myRasterPyramid.yDim = ( int )( 0.5 + ( myHeight / ( double )myDivisor ) ); // NOLINT
myRasterPyramid.exists = false;

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

Q_CHECK_PTR( myGdalDriver );
Q_CHECK_PTR( myGdalDriver ); // NOLINT

if ( !myGdalDriver )
{
Expand Down
2 changes: 1 addition & 1 deletion src/providers/gdal/qgsgdalproviderbase.cpp
Expand Up @@ -280,7 +280,7 @@ CPLErr QgsGdalProviderBase::gdalRasterIO( GDALRasterBandH hBand, GDALRWFlag eRWF
{
GDALRasterIOExtraArg extra;
INIT_RASTERIO_EXTRA_ARG( extra );
if ( 0 && feedback ) // disabled!
if ( false && feedback ) // disabled!
{
// Currently the cancelation is disabled... When RasterIO call is canceled,
// GDAL returns CE_Failure with error code = 0 (CPLE_None), however one would
Expand Down
8 changes: 8 additions & 0 deletions src/providers/memory/CMakeLists.txt
Expand Up @@ -18,6 +18,14 @@ TARGET_LINK_LIBRARIES(memoryprovider
qgis_core
)

# clang-tidy
IF(CLANG_TIDY_EXE)
SET_TARGET_PROPERTIES(
memoryprovider PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
)
ENDIF(CLANG_TIDY_EXE)


INSTALL (TARGETS memoryprovider
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
Expand Down
8 changes: 8 additions & 0 deletions src/providers/ogr/CMakeLists.txt
Expand Up @@ -32,6 +32,14 @@ IF (MSVC)
SET(TARGET_LINK_LIBRARIES ${TARGET_LINK_LIBRARIE} odbc32 odbccp32)
ENDIF (MSVC)

# clang-tidy
IF(CLANG_TIDY_EXE)
SET_TARGET_PROPERTIES(
ogrprovider PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
)
ENDIF(CLANG_TIDY_EXE)

INSTALL (TARGETS ogrprovider
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
Expand Down
9 changes: 0 additions & 9 deletions src/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -55,11 +55,6 @@ QgsOgrLayerItem::QgsOgrLayerItem( QgsDataItem* parent,
}
}

QgsOgrLayerItem::~QgsOgrLayerItem()
{
}


bool QgsOgrLayerItem::setCrs( const QgsCoordinateReferenceSystem& crs )
{
if ( !( mCapabilities & SetCrs ) )
Expand Down Expand Up @@ -180,10 +175,6 @@ QgsOgrDataCollectionItem::QgsOgrDataCollectionItem( QgsDataItem* parent, QString
{
}

QgsOgrDataCollectionItem::~QgsOgrDataCollectionItem()
{
}

QVector<QgsDataItem*> QgsOgrDataCollectionItem::createChildren()
{
QVector<QgsDataItem*> children;
Expand Down
2 changes: 0 additions & 2 deletions src/providers/ogr/qgsogrdataitems.h
Expand Up @@ -24,7 +24,6 @@ class QgsOgrLayerItem : public QgsLayerItem
Q_OBJECT
public:
QgsOgrLayerItem( QgsDataItem* parent, QString name, QString path, QString uri, LayerType layerType );
~QgsOgrLayerItem();

bool setCrs( const QgsCoordinateReferenceSystem& crs ) override;

Expand All @@ -37,7 +36,6 @@ class QgsOgrDataCollectionItem : public QgsDataCollectionItem
Q_OBJECT
public:
QgsOgrDataCollectionItem( QgsDataItem* parent, QString name, QString path );
~QgsOgrDataCollectionItem();

QVector<QgsDataItem*> createChildren() override;
};
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -2056,7 +2056,7 @@ QString createFilters( const QString& type )
{
driver = OGRGetDriver( i );

Q_CHECK_PTR( driver );
Q_CHECK_PTR( driver ); // NOLINT

if ( !driver )
{
Expand Down
7 changes: 7 additions & 0 deletions src/providers/postgres/CMakeLists.txt
Expand Up @@ -72,6 +72,13 @@ TARGET_LINK_LIBRARIES (postgresprovider
qgis_gui
)

# clang-tidy
IF(CLANG_TIDY_EXE)
SET_TARGET_PROPERTIES(
postgresprovider PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
)
ENDIF(CLANG_TIDY_EXE)

########################################################
# Install
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgscolumntypethread.cpp
Expand Up @@ -22,7 +22,7 @@ email : jef at norbit dot de
#include <QMetaType>
#include <climits>

QgsGeomColumnTypeThread::QgsGeomColumnTypeThread( QString name, bool useEstimatedMetaData, bool allowGeometrylessTables )
QgsGeomColumnTypeThread::QgsGeomColumnTypeThread( const QString& name, bool useEstimatedMetaData, bool allowGeometrylessTables )
: QThread()
, mConn( nullptr )
, mName( name )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgscolumntypethread.h
Expand Up @@ -28,7 +28,7 @@ class QgsGeomColumnTypeThread : public QThread
{
Q_OBJECT
public:
QgsGeomColumnTypeThread( QString connName, bool useEstimatedMetaData, bool allowGeometrylessTables );
QgsGeomColumnTypeThread( const QString& connName, bool useEstimatedMetaData, bool allowGeometrylessTables );

// These functions get the layer types and pass that information out
// by emitting the setLayerType() signal.
Expand Down
4 changes: 0 additions & 4 deletions src/providers/postgres/qgspgnewconnection.cpp
Expand Up @@ -178,10 +178,6 @@ void QgsPgNewConnection::on_cb_geometryColumnsOnly_clicked()

//! End Autoconnected SLOTS *

QgsPgNewConnection::~QgsPgNewConnection()
{
}

void QgsPgNewConnection::testConnection()
{
QgsDataSourceUri uri;
Expand Down
1 change: 0 additions & 1 deletion src/providers/postgres/qgspgnewconnection.h
Expand Up @@ -32,7 +32,6 @@ class QgsPgNewConnection : public QDialog, private Ui::QgsPgNewConnectionBase
//! Constructor
QgsPgNewConnection( QWidget *parent = nullptr, const QString& connName = QString::null, Qt::WindowFlags fl = QgisGui::ModalDialogFlags );

~QgsPgNewConnection();
//! Tests the connection using the parameters supplied
void testConnection();
public slots:
Expand Down
4 changes: 0 additions & 4 deletions src/providers/postgres/qgspgtablemodel.cpp
Expand Up @@ -40,10 +40,6 @@ QgsPgTableModel::QgsPgTableModel()
setHorizontalHeaderLabels( headerLabels );
}

QgsPgTableModel::~QgsPgTableModel()
{
}

void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty& layerProperty )
{
QgsDebugMsg( layerProperty.toString() );
Expand Down
1 change: 0 additions & 1 deletion src/providers/postgres/qgspgtablemodel.h
Expand Up @@ -31,7 +31,6 @@ class QgsPgTableModel : public QStandardItemModel
Q_OBJECT
public:
QgsPgTableModel();
~QgsPgTableModel();

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

0 comments on commit db5dd85

Please sign in to comment.