[geos-commits] [SCM] GEOS branch master updated. e1982464794e489eccd5732d23ad19da6f054a6c
git at osgeo.org
git at osgeo.org
Thu Oct 1 15:39:41 PDT 2020
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".
The branch, master has been updated
via e1982464794e489eccd5732d23ad19da6f054a6c (commit)
via 67defdfd5ffa2d1141992213b9630fb782d1a885 (commit)
via be391bde3774b0d97590497079f827dbee9f76b7 (commit)
via 6e5f477a4017097248379591a72c1d9adde49b88 (commit)
via f90a44dff629786bc2f6ce9c7c676a1024c27800 (commit)
from 79e011013e7223f822832e39473048320e35f6f2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e1982464794e489eccd5732d23ad19da6f054a6c
Author: Even Rouault <even.rouault at spatialys.com>
Date: Sat Jun 27 22:16:46 2020 +0200
.azure-pipelines.yml: add a job to run tools/cppcheck.sh
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 2d4d4e9..bbf5d62 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -258,3 +258,14 @@ stages:
ctest -V --output-on-failure -C $BUILD_TYPE
displayName: 'Build C++20'
condition: contains(variables['CXXSTD'], '20')
+
+ - job: Code_quality_checks
+ pool:
+ vmImage: 'ubuntu-18.04'
+ steps:
+ - script: |
+ set -e
+ sudo -E apt-get update
+ sudo -E apt-get -yq --no-install-suggests --no-install-recommends install cppcheck
+ ./tools/cppcheck.sh
+ displayName: 'cppcheck'
commit 67defdfd5ffa2d1141992213b9630fb782d1a885
Author: Even Rouault <even.rouault at spatialys.com>
Date: Sat Jun 27 22:16:33 2020 +0200
Add tools/cppcheck.sh
diff --git a/tools/cppcheck.sh b/tools/cppcheck.sh
new file mode 100755
index 0000000..8fc4025
--- /dev/null
+++ b/tools/cppcheck.sh
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+set -eu
+
+SCRIPT_DIR=$(dirname "$0")
+case $SCRIPT_DIR in
+ "/"*)
+ ;;
+ ".")
+ SCRIPT_DIR=$(pwd)
+ ;;
+ *)
+ SCRIPT_DIR=$(pwd)/$(dirname "$0")
+ ;;
+esac
+
+LOG_FILE=/tmp/cppcheck_geos.txt
+
+rm -f ${LOG_FILE}
+echo "Checking ${SCRIPT_DIR}/../src ..."
+
+cppcheck --inline-suppr \
+ --template='{file}:{line},{severity},{id},{message}' \
+ --enable=all --inconclusive --std=c++11 \
+ -j $(nproc) \
+ ${SCRIPT_DIR}/../src \
+ >>${LOG_FILE} 2>&1 &
+
+PID=$!
+while kill -0 $PID 2>/dev/null; do
+ printf "."
+ sleep 1
+done
+echo " done"
+if ! wait $PID; then
+ echo "cppcheck failed"
+ exit 1
+fi
+
+ret_code=0
+
+cat ${LOG_FILE} | grep -v -e "syntaxError," -e "cppcheckError," > ${LOG_FILE}.tmp
+mv ${LOG_FILE}.tmp ${LOG_FILE}
+
+for category in "style" "performance" "portability"; do
+ if grep "${category}," ${LOG_FILE} >/dev/null; then
+ echo "INFO: Issues in '${category}' category found, but not considered as making script to fail:"
+ grep "${category}," ${LOG_FILE} | grep -v -e "clarifyCalculation," -e "duplicateExpressionTernary," -e "redundantCondition," -e "unusedPrivateFunction," -e "postfixOperator,"
+ echo ""
+ fi
+done
+
+# unusedPrivateFunction not reliable enough in cppcheck 1.72 of Ubuntu 16.04
+if test "$(cppcheck --version)" = "Cppcheck 1.72"; then
+ UNUSED_PRIVATE_FUNCTION=""
+else
+ UNUSED_PRIVATE_FUNCTION="unusedPrivateFunction"
+fi
+
+for category in "error" "warning" "clarifyCalculation" "duplicateExpressionTernary" "redundantCondition" "postfixOperator" "${UNUSED_PRIVATE_FUNCTION}"; do
+ if test "${category}" != ""; then
+ if grep "${category}," ${LOG_FILE} >/dev/null; then
+ echo "ERROR: Issues in '${category}' category found:"
+ grep "${category}," ${LOG_FILE}
+ echo ""
+ echo "${category} check failed !"
+ ret_code=1
+ fi
+ fi
+done
+
+if [ ${ret_code} = 0 ]; then
+ echo "cppcheck succeeded"
+fi
+
+exit ${ret_code}
commit be391bde3774b0d97590497079f827dbee9f76b7
Author: Even Rouault <even.rouault at spatialys.com>
Date: Sat Jun 27 22:12:14 2020 +0200
Fix cppcheck warnings related to postfixOperator
diff --git a/src/geomgraph/EdgeIntersectionList.cpp b/src/geomgraph/EdgeIntersectionList.cpp
index d38eaa7..9b89e64 100644
--- a/src/geomgraph/EdgeIntersectionList.cpp
+++ b/src/geomgraph/EdgeIntersectionList.cpp
@@ -115,7 +115,7 @@ EdgeIntersectionList::addSplitEdges(std::vector<Edge*>* edgeList)
Edge* newEdge = createSplitEdge(eiPrev, ei);
edgeList->push_back(newEdge);
eiPrev = ei;
- it++;
+ ++it;
}
}
diff --git a/src/geomgraph/NodeMap.cpp b/src/geomgraph/NodeMap.cpp
index c74ecd6..6a6800c 100644
--- a/src/geomgraph/NodeMap.cpp
+++ b/src/geomgraph/NodeMap.cpp
@@ -49,9 +49,8 @@ NodeMap::NodeMap(const NodeFactory& newNodeFact)
NodeMap::~NodeMap()
{
- NodeMap::const_iterator it = nodeMap.begin();
- for(; it != nodeMap.end(); it++) {
- delete it->second;
+ for(auto& it: nodeMap) {
+ delete it.second;
}
}
@@ -143,9 +142,8 @@ NodeMap::find(const Coordinate& coord) const
void
NodeMap::getBoundaryNodes(int geomIndex, vector<Node*>& bdyNodes) const
{
- NodeMap::const_iterator it = nodeMap.begin();
- for(; it != nodeMap.end(); it++) {
- Node* node = it->second;
+ for(auto& it: nodeMap) {
+ Node* node = it.second;
if(node->getLabel().getLocation(geomIndex) == Location::BOUNDARY) {
bdyNodes.push_back(node);
}
@@ -156,9 +154,8 @@ string
NodeMap::print() const
{
string out = "";
- NodeMap::const_iterator it = nodeMap.begin();
- for(; it != nodeMap.end(); it++) {
- Node* node = it->second;
+ for(auto& it: nodeMap) {
+ Node* node = it.second;
out += node->print();
}
return out;
diff --git a/src/geomgraph/PlanarGraph.cpp b/src/geomgraph/PlanarGraph.cpp
index 48ac0b3..5cc06c6 100644
--- a/src/geomgraph/PlanarGraph.cpp
+++ b/src/geomgraph/PlanarGraph.cpp
@@ -164,7 +164,7 @@ PlanarGraph::getNodes(vector<Node*>& values)
while(it != nodes->nodeMap.end()) {
assert(it->second);
values.push_back(it->second);
- it++;
+ ++it;
}
}
@@ -233,9 +233,8 @@ PlanarGraph::linkResultDirectedEdges()
#if GEOS_DEBUG
cerr << "PlanarGraph::linkResultDirectedEdges called" << endl;
#endif
- NodeMap::iterator nodeit = nodes->nodeMap.begin();
- for(; nodeit != nodes->nodeMap.end(); nodeit++) {
- Node* node = nodeit->second;
+ for(auto& nodeIt: nodes->nodeMap) {
+ Node* node = nodeIt.second;
assert(node);
EdgeEndStar* ees = node->getEdges();
@@ -258,9 +257,8 @@ PlanarGraph::linkAllDirectedEdges()
#if GEOS_DEBUG
cerr << "PlanarGraph::linkAllDirectedEdges called" << endl;
#endif
- NodeMap::iterator nodeit = nodes->nodeMap.begin();
- for(; nodeit != nodes->nodeMap.end(); nodeit++) {
- Node* node = nodeit->second;
+ for(auto& nodeIt: nodes->nodeMap) {
+ Node* node = nodeIt.second;
assert(node);
EdgeEndStar* ees = node->getEdges();
diff --git a/src/geomgraph/index/SegmentIntersector.cpp b/src/geomgraph/index/SegmentIntersector.cpp
index b369046..88b4f39 100644
--- a/src/geomgraph/index/SegmentIntersector.cpp
+++ b/src/geomgraph/index/SegmentIntersector.cpp
@@ -163,8 +163,7 @@ SegmentIntersector::isBoundaryPoint(LineIntersector* p_li,
return false;
}
- for(std::vector<Node*>::iterator i = tstBdyNodes->begin(); i < tstBdyNodes->end(); i++) {
- Node* node = *i;
+ for(const Node* node: *tstBdyNodes) {
const Coordinate& pt = node->getCoordinate();
if(p_li->isIntersection(pt)) {
return true;
diff --git a/src/index/strtree/AbstractSTRtree.cpp b/src/index/strtree/AbstractSTRtree.cpp
index fd04cad..ca4722c 100644
--- a/src/index/strtree/AbstractSTRtree.cpp
+++ b/src/index/strtree/AbstractSTRtree.cpp
@@ -72,13 +72,8 @@ AbstractSTRtree::createParentBoundables(BoundableList* childBoundables,
std::unique_ptr< BoundableList > sortedChildBoundables(sortBoundables(childBoundables));
- for(BoundableList::iterator i = sortedChildBoundables->begin(),
- e = sortedChildBoundables->end();
- i != e; i++)
- //for(std::size_t i=0, scbsize=sortedChildBoundables->size(); i<scbsize; ++i)
+ for(Boundable* childBoundable: *sortedChildBoundables)
{
- Boundable* childBoundable = *i; // (*sortedChildBoundables)[i];
-
AbstractNode* last = lastNode(parentBoundables.get());
if(last->getChildBoundables()->size() == nodeCapacity) {
last = createNode(newLevel);
@@ -160,9 +155,7 @@ AbstractSTRtree::query(const void* searchBounds, const AbstractNode& node,
const BoundableList& boundables = *(node.getChildBoundables());
- for(BoundableList::const_iterator i = boundables.begin(), e = boundables.end();
- i != e; i++) {
- const Boundable* childBoundable = *i;
+ for(const Boundable* childBoundable: boundables) {
if(!getIntersectsOp()->intersects(childBoundable->getBounds(), searchBounds)) {
continue;
}
diff --git a/src/noding/SegmentNodeList.cpp b/src/noding/SegmentNodeList.cpp
index 283084a..9ebb740 100644
--- a/src/noding/SegmentNodeList.cpp
+++ b/src/noding/SegmentNodeList.cpp
@@ -190,7 +190,7 @@ SegmentNodeList::addSplitEdges(std::vector<SegmentString*>& edgeList)
iterator it = begin();
SegmentNode* eiPrev = *it;
assert(eiPrev);
- it++;
+ ++it;
for(iterator itEnd = end(); it != itEnd; ++it) {
SegmentNode* ei = *it;
assert(ei);
@@ -327,12 +327,7 @@ operator<< (std::ostream& os, const SegmentNodeList& nlist)
{
os << "Intersections: (" << nlist.nodeMap.size() << "):" << std::endl;
- std::set<SegmentNode*, SegmentNodeLT>::const_iterator
- it = nlist.nodeMap.begin(),
- itEnd = nlist.nodeMap.end();
-
- for(; it != itEnd; it++) {
- SegmentNode* ei = *it;
+ for(const SegmentNode* ei: nlist.nodeMap) {
os << " " << *ei;
}
return os;
diff --git a/src/operation/IsSimpleOp.cpp b/src/operation/IsSimpleOp.cpp
index 5f32254..c91a1a8 100644
--- a/src/operation/IsSimpleOp.cpp
+++ b/src/operation/IsSimpleOp.cpp
@@ -203,8 +203,7 @@ bool
IsSimpleOp::hasNonEndpointIntersection(GeometryGraph& graph)
{
vector<Edge*>* edges = graph.getEdges();
- for(vector<Edge*>::iterator i = edges->begin(); i < edges->end(); i++) {
- Edge* e = *i;
+ for(Edge* e: *edges) {
auto maxSegmentIndex = e->getMaximumSegmentIndex();
EdgeIntersectionList& eiL = e->getEdgeIntersectionList();
for(const EdgeIntersection& ei : eiL) {
@@ -290,8 +289,7 @@ IsSimpleOp::hasClosedEndpointIntersection(GeometryGraph& graph)
{
map<const Coordinate*, EndpointInfo*, CoordinateLessThen> endPoints;
vector<Edge*>* edges = graph.getEdges();
- for(vector<Edge*>::iterator i = edges->begin(); i < edges->end(); i++) {
- Edge* e = *i;
+ for(Edge* e: *edges) {
//int maxSegmentIndex=e->getMaximumSegmentIndex();
bool isClosed = e->isClosed();
const Coordinate* p0 = &e->getCoordinate(0);
diff --git a/src/operation/relate/EdgeEndBuilder.cpp b/src/operation/relate/EdgeEndBuilder.cpp
index af0c9bd..546a72e 100644
--- a/src/operation/relate/EdgeEndBuilder.cpp
+++ b/src/operation/relate/EdgeEndBuilder.cpp
@@ -65,14 +65,14 @@ EdgeEndBuilder::computeEdgeEnds(Edge* edge, std::vector<EdgeEnd*>* l)
const EdgeIntersection* eiCurr = nullptr;
const EdgeIntersection* eiNext = &*it;
- it++;
+ ++it;
do {
eiPrev = eiCurr;
eiCurr = eiNext;
eiNext = nullptr;
if(it != eiList.end()) {
eiNext = &*it;
- it++;
+ ++it;
}
if(eiCurr != nullptr) {
createEdgeEndForPrev(edge, l, eiCurr, eiPrev);
diff --git a/src/operation/relate/EdgeEndBundle.cpp b/src/operation/relate/EdgeEndBundle.cpp
index 5f95145..0c163c3 100644
--- a/src/operation/relate/EdgeEndBundle.cpp
+++ b/src/operation/relate/EdgeEndBundle.cpp
@@ -81,9 +81,7 @@ EdgeEndBundle::computeLabel(
// the label must be an area label
bool isArea = false;
- for(vector<EdgeEnd*>::iterator it = edgeEnds.begin(), itEnd = edgeEnds.end();
- it != itEnd; it++) {
- EdgeEnd* e = *it;
+ for(EdgeEnd* e: edgeEnds) {
if(e->getLabel().isArea()) {
isArea = true;
}
@@ -111,8 +109,7 @@ EdgeEndBundle::computeLabelOn(int geomIndex, const algorithm::BoundaryNodeRule&
int boundaryCount = 0;
bool foundInterior = false;
- for(vector<EdgeEnd*>::iterator it = edgeEnds.begin(); it < edgeEnds.end(); it++) {
- EdgeEnd* e = *it;
+ for(EdgeEnd* e: edgeEnds) {
Location loc = e->getLabel().getLocation(geomIndex);
if(loc == Location::BOUNDARY) {
boundaryCount++;
@@ -160,8 +157,7 @@ EdgeEndBundle::computeLabelSides(int geomIndex)
void
EdgeEndBundle::computeLabelSide(int geomIndex, int side)
{
- for(vector<EdgeEnd*>::iterator it = edgeEnds.begin(); it < edgeEnds.end(); it++) {
- EdgeEnd* e = *it;
+ for(EdgeEnd* e: edgeEnds) {
if(e->getLabel().isArea()) {
Location loc = e->getLabel().getLocation(geomIndex, side);
if(loc == Location::INTERIOR) {
diff --git a/src/operation/relate/RelateComputer.cpp b/src/operation/relate/RelateComputer.cpp
index 2c8d149..2f60953 100644
--- a/src/operation/relate/RelateComputer.cpp
+++ b/src/operation/relate/RelateComputer.cpp
@@ -234,8 +234,7 @@ RelateComputer::computeIM()
void
RelateComputer::insertEdgeEnds(std::vector<EdgeEnd*>* ee)
{
- for(std::vector<EdgeEnd*>::iterator i = ee->begin(); i < ee->end(); i++) {
- EdgeEnd* e = *i;
+ for(EdgeEnd* e: *ee) {
nodes.add(e);
}
}
@@ -311,10 +310,8 @@ void
RelateComputer::copyNodesAndLabels(int argIndex)
{
const NodeMap* nm = (*arg)[argIndex]->getNodeMap();
- NodeMap::const_iterator nodeIt = nm->begin(), nodeEnd = nm->end();
-
- for(; nodeIt != nodeEnd; nodeIt++) {
- Node* graphNode = nodeIt->second;
+ for(const auto& it: *nm) {
+ const Node* graphNode = it.second;
Node* newNode = nodes.addNode(graphNode->getCoordinate());
newNode->setLabel(argIndex,
graphNode->getLabel().getLocation(argIndex));
@@ -335,8 +332,7 @@ void
RelateComputer::computeIntersectionNodes(int argIndex)
{
std::vector<Edge*>* edges = (*arg)[argIndex]->getEdges();
- for(std::vector<Edge*>::iterator i = edges->begin(); i < edges->end(); i++) {
- Edge* e = *i;
+ for(Edge* e: *edges) {
Location eLoc = e->getLabel().getLocation(argIndex);
EdgeIntersectionList& eiL = e->getEdgeIntersectionList();
for(const EdgeIntersection & ei : eiL) {
@@ -364,8 +360,7 @@ void
RelateComputer::labelIntersectionNodes(int argIndex)
{
std::vector<Edge*>* edges = (*arg)[argIndex]->getEdges();
- for(std::vector<Edge*>::iterator i = edges->begin(); i < edges->end(); i++) {
- Edge* e = *i;
+ for(Edge* e: *edges) {
Location eLoc = e->getLabel().getLocation(argIndex);
EdgeIntersectionList& eiL = e->getEdgeIntersectionList();
@@ -439,8 +434,7 @@ void
RelateComputer::labelIsolatedEdges(int thisIndex, int targetIndex)
{
std::vector<Edge*>* edges = (*arg)[thisIndex]->getEdges();
- for(std::vector<Edge*>::iterator i = edges->begin(); i < edges->end(); i++) {
- Edge* e = *i;
+ for(Edge* e: *edges) {
if(e->isIsolated()) {
labelIsolatedEdge(e, targetIndex, (*arg)[targetIndex]->getGeometry());
isolatedEdges.push_back(e);
@@ -470,9 +464,8 @@ RelateComputer::labelIsolatedEdge(Edge* e, int targetIndex, const Geometry* targ
void
RelateComputer::labelIsolatedNodes()
{
- NodeMap::iterator nodeIt = nodes.begin(), nodeEnd = nodes.end();
- for(; nodeIt != nodeEnd; nodeIt++) {
- Node* n = nodeIt->second;
+ for(const auto& it: nodes) {
+ Node* n = it.second;
const Label& label = n->getLabel();
// isolated nodes should always have at least one geometry in their label
assert(label.getGeometryCount() > 0); // node with empty label found
diff --git a/src/operation/relate/RelateNodeGraph.cpp b/src/operation/relate/RelateNodeGraph.cpp
index f3bb52e..20b79a6 100644
--- a/src/operation/relate/RelateNodeGraph.cpp
+++ b/src/operation/relate/RelateNodeGraph.cpp
@@ -132,8 +132,7 @@ RelateNodeGraph::copyNodesAndLabels(GeometryGraph* geomGraph, int argIndex)
void
RelateNodeGraph::insertEdgeEnds(vector<EdgeEnd*>* ee)
{
- for(vector<EdgeEnd*>::iterator i = ee->begin(); i < ee->end(); i++) {
- EdgeEnd* e = *i;
+ for(EdgeEnd* e: *ee) {
nodes->add(e);
}
}
diff --git a/src/simplify/TopologyPreservingSimplifier.cpp b/src/simplify/TopologyPreservingSimplifier.cpp
index 61885aa..c987ba3 100644
--- a/src/simplify/TopologyPreservingSimplifier.cpp
+++ b/src/simplify/TopologyPreservingSimplifier.cpp
@@ -101,18 +101,12 @@ public:
return *this;
}
- // postfix++
- void
- operator++(int)
- {
- _iter++;
- }
-
// ++suffix
- void
+ LinesMapValueIterator&
operator++()
{
++_iter;
+ return *this;
}
// inequality operator
commit 6e5f477a4017097248379591a72c1d9adde49b88
Author: Even Rouault <even.rouault at spatialys.com>
Date: Fri Sep 4 08:48:26 2020 +0200
operator<< on MaximalEdgeRing: remove useless nullptr check
diff --git a/src/operation/overlayng/MaximalEdgeRing.cpp b/src/operation/overlayng/MaximalEdgeRing.cpp
index cba6577..6182d7b 100644
--- a/src/operation/overlayng/MaximalEdgeRing.cpp
+++ b/src/operation/overlayng/MaximalEdgeRing.cpp
@@ -207,8 +207,6 @@ operator<<(std::ostream& os, const MaximalEdgeRing& mer)
OverlayEdge* edge = mer.startEdge;
do {
coords.add(edge->orig());
- if (edge == nullptr)
- break;
if (edge->nextResultMax() == nullptr)
break;
edge = edge->nextResultMax();
commit f90a44dff629786bc2f6ce9c7c676a1024c27800
Author: Even Rouault <even.rouault at spatialys.com>
Date: Sat Jun 27 21:46:25 2020 +0200
TaggedLineStringSimplifier.cpp: avoid importing whole std namespace to avoid cppcheck confusing the class' remove method with std::remove
diff --git a/src/simplify/TaggedLineStringSimplifier.cpp b/src/simplify/TaggedLineStringSimplifier.cpp
index f778cc9..e3c87e4 100644
--- a/src/simplify/TaggedLineStringSimplifier.cpp
+++ b/src/simplify/TaggedLineStringSimplifier.cpp
@@ -40,7 +40,9 @@
#endif
using namespace geos::geom;
-using namespace std;
+using std::pair;
+using std::unique_ptr;
+using std::vector;
namespace geos {
namespace simplify { // geos::simplify
-----------------------------------------------------------------------
Summary of changes:
.azure-pipelines.yml | 11 ++++
src/geomgraph/EdgeIntersectionList.cpp | 2 +-
src/geomgraph/NodeMap.cpp | 15 +++---
src/geomgraph/PlanarGraph.cpp | 12 ++---
src/geomgraph/index/SegmentIntersector.cpp | 3 +-
src/index/strtree/AbstractSTRtree.cpp | 11 +---
src/noding/SegmentNodeList.cpp | 9 +---
src/operation/IsSimpleOp.cpp | 6 +--
src/operation/overlayng/MaximalEdgeRing.cpp | 2 -
src/operation/relate/EdgeEndBuilder.cpp | 4 +-
src/operation/relate/EdgeEndBundle.cpp | 10 ++--
src/operation/relate/RelateComputer.cpp | 23 +++-----
src/operation/relate/RelateNodeGraph.cpp | 3 +-
src/simplify/TaggedLineStringSimplifier.cpp | 4 +-
src/simplify/TopologyPreservingSimplifier.cpp | 10 +---
tools/cppcheck.sh | 76 +++++++++++++++++++++++++++
16 files changed, 125 insertions(+), 76 deletions(-)
create mode 100755 tools/cppcheck.sh
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list