Changeset 8849 in josm for trunk/src


Ignore:
Timestamp:
2015-10-10T14:30:12+02:00 (9 years ago)
Author:
Don-vip
Message:

sonar - squid:S1643 - Strings should not be concatenated using '+' in a loop
sonar - squid:S1640 - Maps with keys that are enum values should be replaced with EnumMap

Location:
trunk/src/org/openstreetmap/josm
Files:
5 edited

Legend:

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

    r8848 r8849  
    162162        harmonizedKeys.clear();
    163163
    164         String errorSources = "";
     164        StringBuilder errorSources = new StringBuilder();
    165165        for (String source : Main.pref.getCollection(PREF_SOURCES, DEFAULT_SOURCES)) {
    166166            try (
     
    239239                }
    240240            } catch (IOException e) {
    241                 errorSources += source + '\n';
    242             }
    243         }
    244 
    245         if (!errorSources.isEmpty())
     241                errorSources.append(source).append('\n');
     242            }
     243        }
     244
     245        if (errorSources.length() > 0)
    246246            throw new IOException(tr("Could not access data file(s):\n{0}", errorSources));
    247247    }
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialog.java

    r8840 r8849  
    363363    private static final class StatisticsInfo {
    364364        public int numTags;
    365         public Map<OsmPrimitiveType, Integer> sourceInfo;
    366         public Map<OsmPrimitiveType, Integer> targetInfo;
     365        public final Map<OsmPrimitiveType, Integer> sourceInfo;
     366        public final Map<OsmPrimitiveType, Integer> targetInfo;
    367367
    368368        private StatisticsInfo() {
    369             sourceInfo = new HashMap<>();
    370             targetInfo = new HashMap<>();
     369            sourceInfo = new EnumMap<>(OsmPrimitiveType.class);
     370            targetInfo = new EnumMap<>(OsmPrimitiveType.class);
    371371        }
    372372    }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/LabelCompositionStrategy.java

    r8846 r8849  
    263263
    264264        private String getPrimitiveName(OsmPrimitive n) {
    265             String name = null;
     265            StringBuilder name = new StringBuilder();
    266266            if (!n.hasKeys()) return null;
    267267            for (String rn : nameTags) {
    268                 name = n.get(rn);
    269                 if (name != null) {
     268                String val = n.get(rn);
     269                if (val != null) {
     270                    name.append(val);
    270271                    break;
    271272                }
     
    274275                String comp = n.get(rn);
    275276                if (comp != null) {
    276                     if (name == null) {
    277                         name = comp;
     277                    if (name.length() == 0) {
     278                        name.append(comp);
    278279                    } else {
    279                         name += " (" + comp + ')';
     280                        name.append(" (").append(comp).append(')');
    280281                    }
    281282                    break;
    282283                }
    283284            }
    284             return name;
     285            return name.toString();
    285286        }
    286287
  • trunk/src/org/openstreetmap/josm/io/GpxExporter.java

    r8846 r8849  
    318318                if (answer != JOptionPane.OK_OPTION || l.getSelectedIndex() == -1)
    319319                    return;
    320                 String license = "";
     320                StringBuilder license = new StringBuilder();
    321321                for (int i : l.getSelectedIndices()) {
    322322                    if (i == 2) {
    323                         license = "public domain";
     323                        license = new StringBuilder("public domain");
    324324                        break;
    325325                    }
    326                     license += license.isEmpty() ? URLS[i] : ", "+URLS[i];
     326                    if (license.length() > 0) {
     327                        license.append(", ");
     328                    }
     329                    license.append(URLS[i]);
    327330                }
    328                 copyright.setText(license);
     331                copyright.setText(license.toString());
    329332                copyright.setCaretPosition(0);
    330333            }
  • trunk/src/org/openstreetmap/josm/tools/WikiReader.java

    r8846 r8849  
    120120        boolean transl = false;
    121121        boolean skip = false;
    122         String b = "";
    123         String full = "";
     122        StringBuilder b = new StringBuilder();
     123        StringBuilder full = new StringBuilder();
    124124        for (String line = in.readLine(); line != null; line = in.readLine()) {
    125             full += line;
     125            full.append(line);
    126126            if (line.contains("<div id=\"searchable\">")) {
    127127                inside = true;
     
    142142                // add a border="0" attribute to images, otherwise the internal help browser
    143143                // will render a thick  border around images inside an <a> element
    144                 b += line.replaceAll("<img ", "<img border=\"0\" ")
     144                b.append(line.replaceAll("<img ", "<img border=\"0\" ")
    145145                         .replaceAll("<span class=\"icon\">.</span>", "")
    146146                         .replaceAll("href=\"/", "href=\"" + baseurl + '/')
    147                          .replaceAll(" />", ">")
    148                          + '\n';
     147                         .replaceAll(" />", ">"))
     148                         .append('\n');
    149149            } else if (transl && line.contains("</div>")) {
    150150                transl = false;
     
    157157        || b.indexOf(" does not exist. You can create it here.</p>") >= 0)
    158158            return "";
    159         if (b.isEmpty())
     159        if (b.length() == 0)
    160160            b = full;
    161161        return "<html><base href=\""+url.toExternalForm() +"\"> " + b + "</html>";
Note: See TracChangeset for help on using the changeset viewer.