Changeset 11108 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2016-10-09T03:29:20+02:00 (8 years ago)
Author:
Don-vip
Message:

sonar - squid:S3518 - Zero should not be a possible denominator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java

    r10795 r11108  
    104104        if (size == 0)
    105105            throw new IllegalArgumentException("empty list");
     106        if (size == 1) // to avoid division by 0 in mode 2
     107            return candidates.get(0);
    106108
    107109        switch (Main.pref.getInteger("merge-nodes.mode", 0)) {
    108110        case 0:
    109             Node targetNode = candidates.get(size - 1);
    110             for (final Node n : candidates) { // pick last one
    111                 targetNode = n;
    112             }
    113             return targetNode;
     111            return candidates.get(size - 1);
    114112        case 1:
    115113            double east1 = 0, north1 = 0;
    116114            for (final Node n : candidates) {
    117                 east1 += n.getEastNorth().east();
    118                 north1 += n.getEastNorth().north();
     115                EastNorth en = n.getEastNorth();
     116                east1 += en.east();
     117                north1 += en.north();
    119118            }
    120119
Note: See TracChangeset for help on using the changeset viewer.