Ignore:
Timestamp:
2014-04-29T02:38:59+02:00 (9 years ago)
Author:
Don-vip
Message:

sonar - Variables should not be declared and then immediately returned or thrown

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r7005 r7024  
    5050    public static String explainOsmApiInitializationException(OsmApiInitializationException e) {
    5151        Main.error(e);
    52         String msg = tr(
     52        return tr(
    5353                "<html>Failed to initialize communication with the OSM server {0}.<br>"
    5454                + "Check the server URL in your preferences and your internet connection.",
    5555                Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL));
    56         return msg;
    5756    }
    5857
     
    6564    public static String explainMissingOAuthAccessTokenException(MissingOAuthAccessTokenException e) {
    6665        Main.error(e);
    67         String msg = tr(
     66        return tr(
    6867                "<html>Failed to authenticate at the OSM server ''{0}''.<br>"
    6968                + "You are using OAuth to authenticate but currently there is no<br>"
     
    7372                Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL)
    7473        );
    75         return msg;
    7674    }
    7775
     
    411409     */
    412410    public static String explainChangesetClosedException(ChangesetClosedException e) {
    413         String msg;
    414411        SimpleDateFormat dateFormat = new SimpleDateFormat();
    415         msg = tr(
     412        Main.error(e);
     413        return tr(
    416414                "<html>Failed to upload to changeset <strong>{0}</strong><br>"
    417415                +"because it has already been closed on {1}.",
     
    419417                e.getClosedOn() == null ? "?" : dateFormat.format(e.getClosedOn())
    420418        );
    421         Main.error(e);
    422         return msg;
    423419    }
    424420
     
    454450        }
    455451
    456         String message = tr("<html>Failed to open a connection to the remote server<br>" + "''{0}''<br>"
     452        return tr("<html>Failed to open a connection to the remote server<br>" + "''{0}''<br>"
    457453                + "for security reasons. This is most likely because you are running<br>"
    458454                + "in an applet and because you did not load your applet from ''{1}''.", apiUrl, host);
    459         return message;
    460455    }
    461456
     
    467462     * @param e the exception
    468463     */
    469 
    470464    public static String explainNestedSocketException(OsmTransferException e) {
    471         String apiUrl = e.getUrl();
    472         String message = tr("<html>Failed to open a connection to the remote server<br>" + "''{0}''.<br>"
    473                 + "Please check your internet connection.", apiUrl);
    474         Main.error(e);
    475         return message;
     465        Main.error(e);
     466        return tr("<html>Failed to open a connection to the remote server<br>" + "''{0}''.<br>"
     467                + "Please check your internet connection.", e.getUrl());
    476468    }
    477469
     
    483475     * @param e the exception
    484476     */
    485 
    486477    public static String explainNestedIOException(OsmTransferException e) {
    487478        IOException ioe = getNestedException(e, IOException.class);
    488         String apiUrl = e.getUrl();
    489         String message = tr("<html>Failed to upload data to or download data from<br>" + "''{0}''<br>"
     479        Main.error(e);
     480        return tr("<html>Failed to upload data to or download data from<br>" + "''{0}''<br>"
    490481                + "due to a problem with transferring data.<br>"
    491                 + "Details (untranslated): {1}</html>", apiUrl, ioe
     482                + "Details (untranslated): {1}</html>", e.getUrl(), ioe
    492483                .getMessage());
    493         Main.error(e);
    494         return message;
    495484    }
    496485
     
    503492    public static String explainNestedIllegalDataException(OsmTransferException e) {
    504493        IllegalDataException ide = getNestedException(e, IllegalDataException.class);
    505         String message = tr("<html>Failed to download data. "
     494        Main.error(e);
     495        return tr("<html>Failed to download data. "
    506496                + "Its format is either unsupported, ill-formed, and/or inconsistent.<br>"
    507497                + "<br>Details (untranslated): {0}</html>", ide.getMessage());
    508         Main.error(e);
    509         return message;
    510498    }
    511499
     
    516504     * @param e the exception
    517505     */
    518 
    519506    public static String explainInternalServerError(OsmTransferException e) {
    520         String apiUrl = e.getUrl();
    521         String message = tr("<html>The OSM server<br>" + "''{0}''<br>" + "reported an internal server error.<br>"
    522                 + "This is most likely a temporary problem. Please try again later.", apiUrl);
    523         Main.error(e);
    524         return message;
     507        Main.error(e);
     508        return tr("<html>The OSM server<br>" + "''{0}''<br>" + "reported an internal server error.<br>"
     509                + "This is most likely a temporary problem. Please try again later.", e.getUrl());
    525510    }
    526511
     
    543528            message += tr("<br>Error message(untranslated): {0}", e.getErrorHeader());
    544529        }
    545         message = "<html>" + message + "</html>";
    546         Main.error(e);
    547         return message;
     530        Main.error(e);
     531        return "<html>" + message + "</html>";
    548532    }
    549533
     
    555539     */
    556540    public static String explainBandwidthLimitExceeded(OsmApiException e) {
     541        Main.error(e);
    557542        // TODO: Write a proper error message
    558         String message = explainGenericOsmApiException(e);
    559         Main.error(e);
    560         return message;
    561     }
    562 
     543        return explainGenericOsmApiException(e);
     544    }
    563545
    564546    /**
     
    574556                + "it. Please carefully check the server''s address ''{0}'' for typos."
    575557                , apiUrl);
    576         message = "<html>" + message + "</html>";
    577         Main.error(e);
    578         return message;
     558        Main.error(e);
     559        return "<html>" + message + "</html>";
    579560    }
    580561
     
    596577        }
    597578
    598         String message = tr("<html>Failed to open a connection to the remote server<br>" + "''{0}''.<br>"
     579        Main.error(e);
     580        return tr("<html>Failed to open a connection to the remote server<br>" + "''{0}''.<br>"
    599581                + "Host name ''{1}'' could not be resolved. <br>"
    600582                + "Please check the API URL in your preferences and your internet connection.", apiUrl, host);
    601         Main.error(e);
    602         return message;
    603583    }
    604584
     
    669649     */
    670650    public static String explainGoneForUnknownPrimitive(OsmApiException e) {
    671         String msg = tr(
     651        return tr(
    672652                "<html>The server reports that an object is deleted.<br>"
    673653                + "<strong>Uploading failed</strong> if you tried to update or delete this object.<br> "
     
    676656                + "The error message is:<br>" + "{0}"
    677657                + "</html>", escapeReservedCharactersHTML(e.getMessage()));
    678         return msg;
    679 
    680658    }
    681659
     
    686664     */
    687665    public static String explainException(Exception e) {
    688         String msg = "";
     666        Main.error(e);
    689667        if (e instanceof OsmTransferException) {
    690             msg = explainOsmTransferException((OsmTransferException) e);
     668            return explainOsmTransferException((OsmTransferException) e);
    691669        } else {
    692             msg = explainGeneric(e);
    693         }
    694         Main.error(e);
    695         return msg;
     670            return explainGeneric(e);
     671        }
    696672    }
    697673
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r7012 r7024  
    804804            img = overlay(img, ImageProvider.get("cursor/modifier/" + overlay), OverlayPosition.SOUTHEAST);
    805805        }
    806         Cursor c = Toolkit.getDefaultToolkit().createCustomCursor(img.getImage(),
     806        return Toolkit.getDefaultToolkit().createCustomCursor(img.getImage(),
    807807                "crosshair".equals(name) ? new Point(10, 10) : new Point(3, 2), "Cursor");
    808         return c;
    809808    }
    810809
Note: See TracChangeset for help on using the changeset viewer.