Ignore:
Timestamp:
2016-10-07T10:20:53+02:00 (8 years ago)
Author:
Don-vip
Message:

sonar - squid:S1141 - Try-catch blocks should not be nested

Location:
trunk/src/org/openstreetmap/josm/data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r11054 r11087  
    18531853            try {
    18541854                for (final OsmPrimitive osm : input) {
    1855                     try {
    1856                         if (osm.isDrawable()) {
    1857                             osm.accept(this);
    1858                         }
    1859                     } catch (RuntimeException e) {
    1860                         throw BugReport.intercept(e).put("osm", osm);
    1861                     }
     1855                    acceptDrawable(osm);
    18621856                }
    18631857                return output;
     
    18661860            } finally {
    18671861                MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().unlock();
     1862            }
     1863        }
     1864
     1865        private void acceptDrawable(final OsmPrimitive osm) {
     1866            try {
     1867                if (osm.isDrawable()) {
     1868                    osm.accept(this);
     1869                }
     1870            } catch (RuntimeException e) {
     1871                throw BugReport.intercept(e).put("osm", osm);
    18681872            }
    18691873        }
     
    19661970
    19671971            for (StyleRecord record : allStyleElems) {
    1968                 try {
    1969                     record.paintPrimitive(paintSettings, this);
    1970                 } catch (RuntimeException e) {
    1971                     throw BugReport.intercept(e).put("record", record);
    1972                 }
     1972                paintRecord(record);
    19731973            }
    19741974
     
    19871987        }
    19881988    }
     1989
     1990    private void paintRecord(StyleRecord record) {
     1991        try {
     1992            record.paintPrimitive(paintSettings, this);
     1993        } catch (RuntimeException e) {
     1994            throw BugReport.intercept(e).put("record", record);
     1995        }
     1996    }
    19891997}
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r11083 r11087  
    311311                        if (ai.key.startsWith("throw")) {
    312312                            try {
    313                                 final Severity severity = Severity.valueOf(ai.key.substring("throw".length()).toUpperCase(Locale.ENGLISH));
    314                                 check.errors.put(ai, severity);
     313                                check.errors.put(ai, Severity.valueOf(ai.key.substring("throw".length()).toUpperCase(Locale.ENGLISH)));
    315314                            } catch (IllegalArgumentException e) {
    316315                                Main.warn(e, "Unsupported "+ai.key+" instruction. Allowed instructions are "+POSSIBLE_THROWS+'.');
     
    753752                addMapCSS(i);
    754753                if (Main.pref.getBoolean("validator.auto_reload_local_rules", true) && source.isLocal()) {
    755                     try {
    756                         Main.fileWatcher.registerValidatorRule(source);
    757                     } catch (IOException e) {
    758                         Main.error(e);
    759                     }
     754                    Main.fileWatcher.registerValidatorRule(source);
    760755                }
    761756            } catch (IOException ex) {
Note: See TracChangeset for help on using the changeset viewer.