Changeset 11241 in josm


Ignore:
Timestamp:
2016-11-12T15:36:05+01:00 (3 years ago)
Author:
Don-vip
Message:

sonar - fix warnings

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java

    r11227 r11241  
    8181    public static final int RINGS_SHARE_NODES = 1617;
    8282
     83    private static final int FOUND_INSIDE = 1;
     84    private static final int FOUND_OUTSIDE = 2;
     85
    8386    private final Set<String> keysCheckedByAnotherTest = new HashSet<>();
    8487
     
    8992        super(tr("Multipolygon"),
    9093                tr("This test checks if multipolygons are valid."));
    91     }
    92 
    93     @Override
    94     public void initialize() {
    9594    }
    9695
     
    137136            checkOuterWay(r);
    138137            boolean hasRepeatedMembers = checkRepeatedWayMembers(r);
    139             if (!hasRepeatedMembers) {
    140                 // Rest of checks is only for complete multipolygon
    141                 if (!r.hasIncompleteMembers()) {
    142                     Multipolygon polygon = new Multipolygon(r);
    143                     checkStyleConsistency(r, polygon);
    144                     checkGeometryAndRoles(r, polygon);
    145                 }
     138            // Rest of checks is only for complete multipolygon
     139            if (!hasRepeatedMembers && !r.hasIncompleteMembers()) {
     140                Multipolygon polygon = new Multipolygon(r);
     141                checkStyleConsistency(r, polygon);
     142                checkGeometryAndRoles(r, polygon);
    146143            }
    147144        }
     
    285282                    PolyData pd2 = allPolygons.get(j);
    286283                    if (!checkProblemMap(crossingPolyMap, pd1, pd2)) {
    287                         checkPolygonsForSharedNodes(r, pd1, pd2, sharedNodes, wayMap);
     284                        checkPolygonsForSharedNodes(r, pd1, pd2, sharedNodes);
    288285                    }
    289286                }
     
    310307     * @return List of nodes were ways intersect
    311308     */
    312     private Set<Node> findIntersectionNodes(Relation r) {
     309    private static Set<Node> findIntersectionNodes(Relation r) {
    313310        Set<Node> intersectionNodes = new HashSet<>();
    314311        Map<Node, List<Way>> nodeMap = new HashMap<>();
     
    344341    }
    345342
    346     private void checkPolygonsForSharedNodes(Relation r, PolyData pd1, PolyData pd2, Set<Node> allSharedNodes,
    347             Map<Long, RelationMember> wayMap) {
     343    private void checkPolygonsForSharedNodes(Relation r, PolyData pd1, PolyData pd2, Set<Node> allSharedNodes) {
    348344        Set<Node> sharedByPolygons = new HashSet<>(allSharedNodes);
    349345        sharedByPolygons.retainAll(pd1.getNodes());
     
    391387    }
    392388
    393     private ExtPolygonIntersection checkOverlapAtSharedNodes(Set<Node> shared, PolyData pd1, PolyData pd2) {
     389    private static ExtPolygonIntersection checkOverlapAtSharedNodes(Set<Node> shared, PolyData pd1, PolyData pd2) {
    394390        // Idea: if two polygons share one or more nodes they can either just touch or share segments or intersect.
    395391        // The insideness test is complex, so we try to reduce the number of these tests.
    396392        // There is no need to check all nodes, we only have to check the node following a shared node.
    397393
    398         final int FOUND_INSIDE = 1;
    399         final int FOUND_OUTSIDE = 2;
    400394        int[] flags = new int[2];
    401395        for (int loop = 0; loop < flags.length; loop++) {
     
    447441     */
    448442    private static class PolygonLevel {
    449         public final int level; // nesting level, even for outer, odd for inner polygons.
    450         public final PolyData outerWay;
     443        final int level; // nesting level, even for outer, odd for inner polygons.
     444        final PolyData outerWay;
    451445
    452446        PolygonLevel(PolyData pd, int level) {
     
    504498    private static boolean checkIfNodeIsInsidePolygon(Node n, PolyData p) {
    505499        EastNorth en = n.getEastNorth();
    506         return (en != null && p.get().contains(en.getX(), en.getY()));
     500        return en != null && p.get().contains(en.getX(), en.getY());
    507501    }
    508502
     
    530524
    531525            for (Way w : r.getMemberPrimitives(Way.class)) {
    532                 findIntersectingWay(w, r, cellSegments, problemWays, loop == 1);
     526                findIntersectingWay(w, cellSegments, problemWays, loop == 1);
    533527            }
    534528
     
    587581     * Find ways which are crossing without sharing a node.
    588582     * @param w way that is member of the relation
    589      * @param r the relation (used for error messages)
    590583     * @param cellSegments map with already collected way segments
    591584     * @param crossingWays list to collect crossing ways
    592585     * @param findSharedWaySegments true: find shared way segments instead of crossings
    593586     */
    594     private void findIntersectingWay(Way w, Relation r, Map<Point2D, List<WaySegment>> cellSegments,
     587    private static void findIntersectingWay(Way w, Map<Point2D, List<WaySegment>> cellSegments,
    595588            Map<List<Way>, List<WaySegment>> crossingWays, boolean findSharedWaySegments) {
    596589        int nodesSize = w.getNodesCount();
     
    637630     * @return true if the combination of polygons is found in the map
    638631     */
    639     private boolean checkProblemMap(Map<PolyData, List<PolyData>> problemPolyMap, PolyData pd1, PolyData pd2) {
     632    private static boolean checkProblemMap(Map<PolyData, List<PolyData>> problemPolyMap, PolyData pd1, PolyData pd2) {
    640633        List<PolyData> crossingWithFirst = problemPolyMap.get(pd1);
    641         if (crossingWithFirst != null) {
    642             if (crossingWithFirst.contains(pd2))
    643                 return true;
     634        if (crossingWithFirst != null && crossingWithFirst.contains(pd2)) {
     635            return true;
    644636        }
    645637        List<PolyData> crossingWith2nd = problemPolyMap.get(pd2);
    646         return (crossingWith2nd != null && crossingWith2nd.contains(pd1));
     638        return crossingWith2nd != null && crossingWith2nd.contains(pd1);
    647639    }
    648640
     
    795787        }
    796788
    797         public List<PolygonLevel> findOuterWays(List<PolyData> allPolygons) {
     789        List<PolygonLevel> findOuterWays(List<PolyData> allPolygons) {
    798790            return findOuterWaysRecursive(0, allPolygons);
    799791        }
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r11218 r11241  
    284284        }
    285285
    286         public void replace(Shortcut newShortcut) {
     286        void replace(Shortcut newShortcut) {
    287287            final Optional<Shortcut> existing = findShortcutByKeyOrShortText(-1, NONE, newShortcut.shortText);
    288288            if (existing.isPresent()) {
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MultipolygonTestTest.java

    r11227 r11241  
    4949    /**
    5050     * Non-regression test for bug #10469.
     51     * @throws Exception if an exception occurs
    5152     */
    5253    @Test
    53     public void testTicket10469() {
     54    public void testTicket10469() throws Exception {
    5455        MULTIPOLYGON_TEST.initialize();
    5556        MULTIPOLYGON_TEST.startTest(null);
  • trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java

    r10758 r11241  
    1010
    1111import org.junit.Assert;
     12import org.junit.Rule;
    1213import org.junit.Test;
    1314import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    2021     * Use default, basic test rules.
    2122     */
     23    @Rule
    2224    public JOSMTestRules rules = new JOSMTestRules();
    2325
Note: See TracChangeset for help on using the changeset viewer.