Skip to content
Permalink
Browse files

Fix a bunch of suggestions from clang-tidy

And add a new CLANG_TIDY_EXE cmake option. If this is set to the
path to the clang_tidy executable then a bunch of clang-tidy
checks will be run during compilation.
  • Loading branch information
nyalldawson committed Feb 20, 2017
1 parent a0f655a commit 7daa4b591ed2962f9214a5c1fb3633bf3cc0f4b6
Showing with 364 additions and 544 deletions.
  1. +14 −0 CMakeLists.txt
  2. +16 −0 python/core/symbology-ng/qgsfillsymbollayer.sip
  3. +4 −0 python/core/symbology-ng/qgslinesymbollayer.sip
  4. +4 −0 python/core/symbology-ng/qgsvectorfieldsymbollayer.sip
  5. +7 −0 src/analysis/CMakeLists.txt
  6. +0 −8 src/analysis/interpolation/Point3D.cc
  7. +0 −1 src/analysis/interpolation/Point3D.h
  8. +0 −15 src/analysis/interpolation/Vector3D.cc
  9. +0 −3 src/analysis/interpolation/Vector3D.h
  10. +0 −5 src/analysis/interpolation/qgsinterpolator.cpp
  11. +1 −1 src/analysis/interpolation/qgsinterpolator.h
  12. +0 −5 src/analysis/network/qgsvectorlayerdirector.cpp
  13. +1 −1 src/analysis/network/qgsvectorlayerdirector.h
  14. +0 −5 src/analysis/raster/qgsderivativefilter.cpp
  15. +1 −1 src/analysis/raster/qgsderivativefilter.h
  16. +0 −5 src/analysis/raster/qgsninecellfilter.cpp
  17. +1 −1 src/analysis/raster/qgsninecellfilter.h
  18. +1 −1 src/analysis/raster/qgsrastermatrix.cpp
  19. +0 −6 src/analysis/raster/qgsruggednessfilter.cpp
  20. +1 −1 src/analysis/raster/qgsruggednessfilter.h
  21. +0 −5 src/analysis/raster/qgsslopefilter.cpp
  22. +1 −1 src/analysis/raster/qgsslopefilter.h
  23. +0 −5 src/analysis/raster/qgstotalcurvaturefilter.cpp
  24. +1 −1 src/analysis/raster/qgstotalcurvaturefilter.h
  25. +4 −4 src/analysis/vector/mersenne-twister.cpp
  26. +1 −1 src/analysis/vector/qgstransectsample.cpp
  27. +8 −0 src/core/CMakeLists.txt
  28. +0 −3 src/core/annotations/qgshtmlannotation.cpp
  29. +1 −1 src/core/annotations/qgshtmlannotation.h
  30. +1 −1 src/core/auth/qgsauthmethodregistry.cpp
  31. +6 −6 src/core/composer/qgsatlascomposition.cpp
  32. +0 −2 src/core/composer/qgscomposerarrow.cpp
  33. +1 −1 src/core/composer/qgscomposerattributetablev2.cpp
  34. +3 −3 src/core/composer/qgscomposerhtml.cpp
  35. +1 −3 src/core/composer/qgscomposeritem.cpp
  36. +1 −1 src/core/composer/qgscomposerlabel.cpp
  37. +1 −1 src/core/composer/qgscomposermap.cpp
  38. +1 −1 src/core/composer/qgscomposermap.h
  39. +1 −8 src/core/composer/qgscomposerpicture.cpp
  40. +1 −8 src/core/composer/qgscomposertablev2.cpp
  41. +1 −1 src/core/composer/qgscomposition.cpp
  42. +0 −8 src/core/diagram/qgsdiagram.cpp
  43. +1 −1 src/core/geometry/qgsabstractgeometry.h
  44. +20 −20 src/core/geometry/qgsgeometrymakevalid.cpp
  45. +2 −16 src/core/geometry/qgsgeometryutils.cpp
  46. +1 −1 src/core/geometry/qgsgeos.cpp
  47. +1 −1 src/core/layertree/qgslayertreemodel.cpp
  48. +2 −2 src/core/pal/feature.cpp
  49. +2 −9 src/core/pal/problem.cpp
  50. +1 −1 src/core/qgsattributetableconfig.cpp
  51. +0 −4 src/core/qgscacheindex.cpp
  52. +1 −1 src/core/qgscacheindex.h
  53. +0 −1 src/core/qgscolorramp.cpp
  54. +0 −5 src/core/qgscolorscheme.cpp
  55. +1 −1 src/core/qgscolorscheme.h
  56. +9 −9 src/core/qgscoordinatereferencesystem.cpp
  57. +4 −7 src/core/qgscoordinatetransform.cpp
  58. +2 −6 src/core/qgsdataitem.cpp
  59. +3 −3 src/core/qgsdataitemproviderregistry.cpp
  60. +1 −1 src/core/qgsdatetimestatisticalsummary.cpp
  61. +3 −3 src/core/qgseditformconfig.cpp
  62. +13 −18 src/core/qgsexpression.cpp
  63. +5 −5 src/core/qgsexpressioncontext.cpp
  64. +1 −1 src/core/qgsexpressioncontext.h
  65. +3 −3 src/core/qgsfeature.cpp
  66. +4 −16 src/core/qgsfeaturerequest.cpp
  67. +2 −2 src/core/qgsfield.cpp
  68. +1 −1 src/core/qgsfieldformatter.cpp
  69. +3 −3 src/core/qgsfields.cpp
  70. +0 −1 src/core/qgsfontutils.cpp
  71. +1 −1 src/core/qgslabelingengine.cpp
  72. +1 −1 src/core/qgslocalec.cpp
  73. +1 −1 src/core/qgsmapsettings.cpp
  74. +2 −2 src/core/qgsnetworkaccessmanager.cpp
  75. +1 −2 src/core/qgsnetworkcontentfetcher.cpp
  76. +6 −6 src/core/qgsogcutils.cpp
  77. +2 −8 src/core/qgspoint.cpp
  78. +4 −4 src/core/qgspointlocator.cpp
  79. +1 −1 src/core/qgsproject.cpp
  80. +1 −1 src/core/qgsproject.h
  81. +0 −4 src/core/qgsprojectfiletransform.cpp
  82. +1 −1 src/core/qgsprojectproperty.cpp
  83. +2 −2 src/core/qgsproperty.cpp
  84. +1 −1 src/core/qgsproviderregistry.cpp
  85. +0 −7 src/core/qgspythonrunner.cpp
  86. +1 −1 src/core/qgspythonrunner.h
  87. +6 −6 src/core/qgsspatialindex.cpp
  88. +2 −2 src/core/qgssqlstatement.cpp
  89. +1 −1 src/core/qgsstringstatisticalsummary.cpp
  90. +2 −2 src/core/qgsstringutils.cpp
  91. +1 −1 src/core/qgstaskmanager.cpp
  92. +1 −1 src/core/qgstextlabelfeature.cpp
  93. +12 −12 src/core/qgstextrenderer.cpp
  94. +4 −6 src/core/qgstracer.cpp
  95. +2 −1 src/core/qgstracer.h
  96. +4 −5 src/core/qgsvectorfilewriter.cpp
  97. +33 −36 src/core/qgsvectorlayer.cpp
  98. +1 −1 src/core/raster/qgscolorrampshader.cpp
  99. +10 −20 src/core/raster/qgspalettedrasterrenderer.cpp
  100. +6 −7 src/core/raster/qgsrasterblock.cpp
  101. +1 −2 src/core/raster/qgsrasterpipe.cpp
  102. +10 −20 src/core/raster/qgssinglebandgrayrenderer.cpp
  103. +1 −4 src/core/symbology-ng/qgscategorizedsymbolrenderer.cpp
  104. +2 −6 src/core/symbology-ng/qgscptcityarchive.cpp
  105. +6 −15 src/core/symbology-ng/qgsfillsymbollayer.cpp
  106. +3 −4 src/core/symbology-ng/qgsfillsymbollayer.h
  107. +1 −3 src/core/symbology-ng/qgsgraduatedsymbolrenderer.cpp
  108. +0 −1 src/core/symbology-ng/qgsheatmaprenderer.cpp
  109. +1 −3 src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp
  110. +5 −12 src/core/symbology-ng/qgslinesymbollayer.cpp
  111. +1 −3 src/core/symbology-ng/qgslinesymbollayer.h
  112. +5 −12 src/core/symbology-ng/qgsstyle.cpp
  113. +1 −1 src/core/symbology-ng/qgssvgcache.cpp
  114. +1 −1 src/core/symbology-ng/qgssymbol.cpp
  115. +1 −2 src/core/symbology-ng/qgssymbollayer.cpp
  116. +1 −7 src/core/symbology-ng/qgsvectorfieldsymbollayer.cpp
  117. +2 −3 src/core/symbology-ng/qgsvectorfieldsymbollayer.h
  118. +8 −0 src/gui/CMakeLists.txt
  119. +2 −2 src/gui/editorwidgets/core/qgseditorwidgetautoconf.cpp
  120. +1 −1 src/gui/qgisgui.cpp
  121. +1 −1 src/gui/qgsadvanceddigitizingdockwidget.cpp
  122. +3 −3 src/gui/qgsfiledownloader.cpp
  123. +3 −3 src/gui/qgsfiledownloader.h
  124. +1 −1 src/gui/qgsmapcanvas.cpp
  125. +1 −1 src/gui/qgsmapoverviewcanvas.cpp
  126. +2 −6 src/gui/qgsoptionsdialogbase.cpp
  127. +2 −3 src/gui/qgsoptionsdialogbase.h
  128. +1 −1 src/gui/qgsshortcutsmanager.cpp
  129. +1 −1 src/gui/qgsshortcutsmanager.h
  130. +6 −6 src/gui/symbology-ng/qgsstylemanagerdialog.cpp
  131. +0 −3 src/gui/symbology-ng/qgssymbollayerwidget.cpp
  132. +0 −1 src/gui/symbology-ng/qgssymbollayerwidget.h
  133. +1 −1 src/gui/symbology-ng/qgssymbolslistwidget.cpp
  134. +7 −0 src/server/CMakeLists.txt
  135. +1 −1 src/server/qgis_map_serv.cpp
@@ -671,6 +671,20 @@ INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
# that may be in the same install prefix
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/src/core ${CMAKE_BINARY_DIR}/src/gui)

####################################################
# clang-tidy
FIND_PROGRAM(
CLANG_TIDY_EXE
NAMES "clang-tidy"
DOC "Path to clang-tidy executable"
)
IF(NOT CLANG_TIDY_EXE)
MESSAGE(STATUS "clang-tidy not found.")
ELSE(NOT CLANG_TIDY_EXE)
MESSAGE(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
SET(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-checks=*,-clang-analyzer-alpha.*,-cppcoreguidelines*,-readability-implicit-bool-cast,-llvm-include-order,-cert-err58-cpp,-modernize-pass-by-value,-google-readability-braces-around-statements,-modernize-use-auto,-modernize-loop-convert,-readability-else-after-return,-readability-braces-around-statements,-google-runtime-references,-readability-named-parameter,-google-default-arguments,-google-readability-todo,-readability-inconsistent-declaration-parameter-name,-cert-flp30-c,-google-readability-casting,-clang-analyzer-security.FloatLoopCounter,-google-runtime-int,-modernize-use-using,-google-explicit-constructor,-google-build-using-namespace,-cert-err34-c,-clang-analyzer-core.CallAndMessage,-google-readability-function-size,-modernize-make-shared,-modernize-use-nullptr,-clang-analyzer-cplusplus.NewDeleteLeaks,-clang-analyzer-core.NonNullParamChecker,performance-unnecessary-copy-initialization,-readability-simplify-boolean-expr,-modernize-raw-string-literal,-performance-unnecessary-copy-initialization")
ENDIF(NOT CLANG_TIDY_EXE)

#############################################################
# create qgsversion.h
IF (EXISTS ${CMAKE_SOURCE_DIR}/.git/index)
@@ -487,6 +487,10 @@ class QgsImageFillSymbolLayer: QgsFillSymbolLayer
protected:

virtual void applyDataDefinedSettings( QgsSymbolRenderContext& context );

private:

QgsImageFillSymbolLayer( const QgsImageFillSymbolLayer& other );
};

/** \ingroup core
@@ -844,6 +848,10 @@ class QgsLinePatternFillSymbolLayer: QgsImageFillSymbolLayer

QSet<QString> usedAttributes( const QgsRenderContext& context ) const;

private:

QgsLinePatternFillSymbolLayer( const QgsLinePatternFillSymbolLayer& other );

};

class QgsPointPatternFillSymbolLayer : QgsImageFillSymbolLayer
@@ -945,6 +953,10 @@ class QgsPointPatternFillSymbolLayer : QgsImageFillSymbolLayer

protected:
void applyDataDefinedSettings( QgsSymbolRenderContext& context );

private:

QgsPointPatternFillSymbolLayer( const QgsPointPatternFillSymbolLayer& other );
};

class QgsCentroidFillSymbolLayer : QgsFillSymbolLayer
@@ -1001,4 +1013,8 @@ class QgsCentroidFillSymbolLayer : QgsFillSymbolLayer
/** Returns whether a point is drawn for all parts or only on the biggest part of multi-part features.
* @note added in 2.16 */
bool pointOnAllParts() const;

private:

QgsCentroidFillSymbolLayer( const QgsCentroidFillSymbolLayer& other );
};
@@ -283,4 +283,8 @@ class QgsMarkerLineSymbolLayer : QgsLineSymbolLayer
void renderPolylineVertex( const QPolygonF& points, QgsSymbolRenderContext& context, Placement placement = Vertex );
void renderPolylineCentral( const QPolygonF& points, QgsSymbolRenderContext& context );
double markerAngle( const QPolygonF& points, bool isRing, int vertex );

private:

QgsMarkerLineSymbolLayer( const QgsMarkerLineSymbolLayer& other );
};
@@ -85,4 +85,8 @@ class QgsVectorFieldSymbolLayer : QgsMarkerSymbolLayer
const QgsMapUnitScale& distanceMapUnitScale() const;

QRectF bounds( QPointF point, QgsSymbolRenderContext& context );

private:

QgsVectorFieldSymbolLayer( const QgsVectorFieldSymbolLayer& other );
};
@@ -217,6 +217,13 @@ ENDIF (NOT ANDROID)

TARGET_LINK_LIBRARIES(qgis_analysis qgis_core)

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

# install

@@ -17,14 +17,6 @@
#include "Point3D.h"
#include "qgslogger.h"

Point3D& Point3D::operator=( const Point3D & p )
{
mX = p.mX;
mY = p.mY;
mZ = p.mZ;
return ( *this );
}

bool Point3D::operator==( const Point3D& p ) const
{
return ( mX == p.getX() && mY == p.getY() && mZ == p.getZ() );
@@ -36,7 +36,6 @@ class ANALYSIS_EXPORT Point3D
//! Constructor with the x-, y- and z-coordinate as arguments
Point3D( double x, double y, double z );
Point3D( const Point3D& p );
Point3D& operator=( const Point3D& p );
bool operator==( const Point3D& p ) const;
bool operator!=( const Point3D& p ) const;
//! Calculates the three-dimensional distance to another point
@@ -29,21 +29,6 @@ void Vector3D::standardise()
setZ( getZ() / length );
}

Vector3D::Vector3D( const Vector3D& v )
: mX( v.mX )
, mY( v.mY )
, mZ( v.mZ )
{
}

Vector3D& Vector3D::operator=( const Vector3D & v )
{
mX = v.mX;
mY = v.mY;
mZ = v.mZ;
return ( *this );
}

bool Vector3D::operator==( const Vector3D& v ) const
{
return ( mX == v.getX() && mY == v.getY() && mZ == v.getZ() );
@@ -41,10 +41,7 @@ class ANALYSIS_EXPORT Vector3D
Vector3D( double x, double y, double z );
//! Default constructor
Vector3D();
//! Copy constructor
Vector3D( const Vector3D& v );

Vector3D& operator=( const Vector3D& v );
bool operator==( const Vector3D& v ) const;
bool operator!=( const Vector3D& v ) const;
//! Returns the x-component of the vector
@@ -35,11 +35,6 @@ QgsInterpolator::QgsInterpolator()

}

QgsInterpolator::~QgsInterpolator()
{

}

int QgsInterpolator::cacheBaseData()
{
if ( mLayerData.size() < 1 )
@@ -57,7 +57,7 @@ class ANALYSIS_EXPORT QgsInterpolator

QgsInterpolator( const QList<LayerData>& layerData );

virtual ~QgsInterpolator();
virtual ~QgsInterpolator() = default;

/** Calculates interpolation value for map coordinates x, y
@param x x-coordinate (in map units)
@@ -118,11 +118,6 @@ QgsVectorLayerDirector::QgsVectorLayerDirector( QgsVectorLayer *myLayer,
mBothDirectionValue = bothDirectionValue;
}

QgsVectorLayerDirector::~QgsVectorLayerDirector()
{

}

QString QgsVectorLayerDirector::name() const
{
return QStringLiteral( "Vector line" );
@@ -65,7 +65,7 @@ class ANALYSIS_EXPORT QgsVectorLayerDirector : public QgsGraphDirector
const Direction defaultDirection
);

virtual ~QgsVectorLayerDirector();
virtual ~QgsVectorLayerDirector() = default;

/*
* MANDATORY DIRECTOR PROPERTY DECLARATION
@@ -23,11 +23,6 @@ QgsDerivativeFilter::QgsDerivativeFilter( const QString& inputFile, const QStrin

}

QgsDerivativeFilter::~QgsDerivativeFilter()
{

}

float QgsDerivativeFilter::calcFirstDerX( float* x11, float* x21, float* x31, float* x12, float* x22, float* x32, float* x13, float* x23, float* x33 )
{
//the basic formula would be simple, but we need to test for nodata values...
@@ -27,7 +27,7 @@ class ANALYSIS_EXPORT QgsDerivativeFilter : public QgsNineCellFilter
{
public:
QgsDerivativeFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
virtual ~QgsDerivativeFilter();
virtual ~QgsDerivativeFilter() = default;
//to be implemented by subclasses
virtual float processNineCellWindow( float* x11, float* x21, float* x31,
float* x12, float* x22, float* x32,
@@ -43,11 +43,6 @@ QgsNineCellFilter::QgsNineCellFilter()
{
}

QgsNineCellFilter::~QgsNineCellFilter()
{

}

int QgsNineCellFilter::processRaster( QProgressDialog* p )
{
GDALAllRegister();
@@ -34,7 +34,7 @@ class ANALYSIS_EXPORT QgsNineCellFilter
public:
//! Constructor that takes input file, output file and output format (GDAL string)
QgsNineCellFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
virtual ~QgsNineCellFilter();
virtual ~QgsNineCellFilter() = default;

/** Starts the calculation, reads from mInputFile and stores the result in mOutputFile
@param p progress dialog that receives update and that is checked for abort. 0 if no progress bar is needed.
@@ -16,7 +16,7 @@
***************************************************************************/

#include "qgsrastermatrix.h"
#include <string.h>
#include <cstring>
#include <qmath.h>

QgsRasterMatrix::QgsRasterMatrix()
@@ -27,12 +27,6 @@ QgsRuggednessFilter::QgsRuggednessFilter(): QgsNineCellFilter( QLatin1String( ""

}


QgsRuggednessFilter::~QgsRuggednessFilter()
{

}

float QgsRuggednessFilter::processNineCellWindow( float* x11, float* x21, float* x31,
float* x12, float* x22, float* x32, float* x13, float* x23, float* x33 )
{
@@ -28,7 +28,7 @@ class ANALYSIS_EXPORT QgsRuggednessFilter: public QgsNineCellFilter
{
public:
QgsRuggednessFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
~QgsRuggednessFilter();
~QgsRuggednessFilter() = default;

protected:

@@ -23,11 +23,6 @@ QgsSlopeFilter::QgsSlopeFilter( const QString& inputFile, const QString& outputF

}

QgsSlopeFilter::~QgsSlopeFilter()
{

}

float QgsSlopeFilter::processNineCellWindow( float* x11, float* x21, float* x31,
float* x12, float* x22, float* x32, float* x13, float* x23, float* x33 )
{
@@ -27,7 +27,7 @@ class ANALYSIS_EXPORT QgsSlopeFilter: public QgsDerivativeFilter
{
public:
QgsSlopeFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
~QgsSlopeFilter();
~QgsSlopeFilter() = default;

/** Calculates output value from nine input values. The input values and the output value can be equal to the
nodata value if not present or outside of the border. Must be implemented by subclasses*/
@@ -23,11 +23,6 @@ QgsTotalCurvatureFilter::QgsTotalCurvatureFilter( const QString& inputFile, cons

}

QgsTotalCurvatureFilter::~QgsTotalCurvatureFilter()
{

}

float QgsTotalCurvatureFilter::processNineCellWindow( float* x11, float* x21, float* x31, float* x12,
float* x22, float* x32, float* x13, float* x23, float* x33 )
{
@@ -27,7 +27,7 @@ class ANALYSIS_EXPORT QgsTotalCurvatureFilter: public QgsNineCellFilter
{
public:
QgsTotalCurvatureFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
~QgsTotalCurvatureFilter();
~QgsTotalCurvatureFilter() = default;

protected:

@@ -20,7 +20,7 @@
* 2015-02-17
*/

#include <stdio.h>
#include <cstdio>
#include "mersenne-twister.h"

/*
@@ -35,9 +35,9 @@ static const unsigned DIFF = SIZE - PERIOD;
static uint32_t MT[SIZE];
static unsigned index = 0;

#define M32(x) (0x80000000 & x) // 32nd Most Significant Bit
#define L31(x) (0x7FFFFFFF & x) // 31 Least Significant Bits
#define ODD(x) (x & 1) // Check if number is odd
#define M32(x) (0x80000000 & (x)) // 32nd Most Significant Bit
#define L31(x) (0x7FFFFFFF & (x)) // 31 Least Significant Bits
#define ODD(x) ((x) & 1) // Check if number is odd

#define UNROLL(expr) \
y = M32(MT[i]) | L31(MT[i+1]); \
@@ -22,7 +22,7 @@
#include <QProgressDialog>
#include <QFileInfo>
#ifndef _MSC_VER
#include <stdint.h>
#include <cstdint>
#endif
#include "mersenne-twister.h"
#include <limits>
@@ -1060,6 +1060,14 @@ IF (Qt5Positioning_FOUND)
)
ENDIF (Qt5Positioning_FOUND)

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

# install

INSTALL(TARGETS qgis_core
@@ -47,9 +47,6 @@ QgsHtmlAnnotation::QgsHtmlAnnotation( QObject* parent )
connect( mWebPage->mainFrame(), &QWebFrame::javaScriptWindowObjectCleared, this, &QgsHtmlAnnotation::javascript );
}

QgsHtmlAnnotation::~QgsHtmlAnnotation()
{}

void QgsHtmlAnnotation::setSourceFile( const QString& htmlFile )
{
QFile file( htmlFile );
@@ -42,7 +42,7 @@ class CORE_EXPORT QgsHtmlAnnotation: public QgsAnnotation
*/
QgsHtmlAnnotation( QObject* parent = nullptr );

~QgsHtmlAnnotation();
~QgsHtmlAnnotation() = default;

QSizeF minimumFrameSize() const override;

@@ -338,7 +338,7 @@ QFunctionPointer QgsAuthMethodRegistry::function( QString const & authMethodKey,
else
{
QgsDebugMsg( "Cannot load library: " + myLib.errorString() );
return 0;
return nullptr;
}
}

0 comments on commit 7daa4b5

Please sign in to comment.
You can’t perform that action at this time.