Ignore:
Timestamp:
2017-04-15T01:38:46+02:00 (7 years ago)
Author:
Don-vip
Message:

sonar - squid:S1192 - String literals should not be duplicated

File:
1 edited

Legend:

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

    r11807 r11913  
    22package org.openstreetmap.josm.data.validation.tests;
    33
     4import static org.openstreetmap.josm.data.validation.tests.CrossingWays.HIGHWAY;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56
     
    7778        if (n.isUsable()) {
    7879            if (!n.hasTag("crossing", "no")
    79              && !(n.hasKey("crossing") && (n.hasTag("highway", "crossing") || n.hasTag("highway", "traffic_signals")))
     80             && !(n.hasKey("crossing") && (n.hasTag(HIGHWAY, "crossing")
     81                                        || n.hasTag(HIGHWAY, "traffic_signals")))
    8082             && n.isReferredByWays(2)) {
    8183                testMissingPedestrianCrossing(n);
     
    9294    public void visit(Way w) {
    9395        if (w.isUsable()) {
    94             if (w.isClosed() && w.hasTag("highway", CLASSIFIED_HIGHWAYS) && w.hasTag("junction", "roundabout")) {
     96            if (w.isClosed() && w.hasTag(HIGHWAY, CLASSIFIED_HIGHWAYS) && w.hasTag("junction", "roundabout")) {
    9597                // TODO: find out how to handle splitted roundabouts (see #12841)
    9698                testWrongRoundabout(w);
     
    110112        for (Node n : new HashSet<>(w.getNodes())) {
    111113            for (Way h : Utils.filteredCollection(n.getReferrers(), Way.class)) {
    112                 String value = h.get("highway");
     114                String value = h.get(HIGHWAY);
    113115                if (h != w && value != null && !value.endsWith("_link")) {
    114116                    List<Way> list = map.get(value);
     
    130132                if (list.size() > 2 || oneway1 == null || oneway2 == null || !oneway1 || !oneway2) {
    131133                    // Error when the highway tags do not match
    132                     String value = w.get("highway");
     134                    String value = w.get(HIGHWAY);
    133135                    if (!value.equals(s)) {
    134136                        errors.add(TestError.builder(this, Severity.WARNING, WRONG_ROUNDABOUT_HIGHWAY)
    135137                                .message(tr("Incorrect roundabout (highway: {0} instead of {1})", value, s))
    136138                                .primitives(w)
    137                                 .fix(() -> new ChangePropertyCommand(w, "highway", s))
     139                                .fix(() -> new ChangePropertyCommand(w, HIGHWAY, s))
    138140                                .build());
    139141                    }
     
    145147
    146148    public static boolean isHighwayLinkOkay(final Way way) {
    147         final String highway = way.get("highway");
     149        final String highway = way.get(HIGHWAY);
    148150        if (highway == null || !highway.endsWith("_link")
    149151                || !IN_DOWNLOADED_AREA.test(way.getNode(0)) || !IN_DOWNLOADED_AREA.test(way.getNode(way.getNodesCount()-1))) {
     
    164166
    165167        return Utils.filteredCollection(referrers, Way.class).stream().anyMatch(
    166                 otherWay -> !way.equals(otherWay) && otherWay.hasTag("highway", highway, highway.replaceAll("_link$", "")));
     168                otherWay -> !way.equals(otherWay) && otherWay.hasTag(HIGHWAY, highway, highway.replaceAll("_link$", "")));
    167169    }
    168170
     
    185187
    186188        for (Way w : OsmPrimitive.getFilteredList(n.getReferrers(), Way.class)) {
    187             String highway = w.get("highway");
     189            String highway = w.get(HIGHWAY);
    188190            if (highway != null) {
    189191                if ("footway".equals(highway) || "path".equals(highway)) {
Note: See TracChangeset for help on using the changeset viewer.