Ignore:
Timestamp:
2015-11-25T01:21:14+01:00 (9 years ago)
Author:
Don-vip
Message:

Sonar - squid:S1941 - Variables should not be declared before they are relevant

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

Legend:

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

    r9059 r9062  
    352352        double a2 = p4.getY() - p3.getY();
    353353        double b2 = p3.getX() - p4.getX();
    354         double c2 = (p4.getX() - p1.getX()) * (p3.getY() - p1.getY()) - (p3.getX() - p1.getX()) * (p4.getY() - p1.getY());
    355354
    356355        // Solve the equations
     
    358357        if (det == 0)
    359358            return null; // Lines are parallel
     359
     360        double c2 = (p4.getX() - p1.getX()) * (p3.getY() - p1.getY()) - (p3.getX() - p1.getX()) * (p4.getY() - p1.getY());
    360361
    361362        return new EastNorth(b1 * c2 / det + p1.getX(), -a1 * c2 / det + p1.getY());
     
    573574            return false;
    574575
     576        //iterate each side of the polygon, start with the last segment
     577        Node oldPoint = polygonNodes.get(polygonNodes.size() - 1);
     578
     579        if (!oldPoint.isLatLonKnown()) {
     580            return false;
     581        }
     582
    575583        boolean inside = false;
    576584        Node p1, p2;
    577 
    578         //iterate each side of the polygon, start with the last segment
    579         Node oldPoint = polygonNodes.get(polygonNodes.size() - 1);
    580 
    581         if (!oldPoint.isLatLonKnown()) {
    582             return false;
    583         }
    584585
    585586        for (Node newPoint : polygonNodes) {
     
    708709     */
    709710    public static boolean isClockwise(List<Node> nodes) {
    710         double area2 = 0.;
    711711        int nodesCount = nodes.size();
    712712        if (nodesCount < 3 || nodes.get(0) != nodes.get(nodesCount - 1)) {
    713713            throw new IllegalArgumentException("Way must be closed to check orientation.");
    714714        }
     715        double area2 = 0.;
    715716
    716717        for (int node = 1; node <= /*sic! consider last-first as well*/ nodesCount; node++) {
  • trunk/src/org/openstreetmap/josm/tools/I18n.java

    r8989 r9062  
    583583                    }
    584584                    String[] enstrings = new String[ennum];
    585                     String[] trstrings = new String[trnum];
    586585                    for (int i = 0; i < ennum; ++i) {
    587586                        int val = ens.read(enlen);
     
    597596                        enstrings[i] = new String(str, 0, val, StandardCharsets.UTF_8);
    598597                    }
     598                    String[] trstrings = new String[trnum];
    599599                    for (int i = 0; i < trnum; ++i) {
    600600                        int val = trs.read(trlen);
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r8992 r9062  
    836836        Matcher m = dataUrlPattern.matcher(url);
    837837        if (m.matches()) {
    838             String mediatype = m.group(1);
    839838            String base64 = m.group(2);
    840839            String data = m.group(3);
     
    850849                }
    851850            }
     851            String mediatype = m.group(1);
    852852            if ("image/svg+xml".equals(mediatype)) {
    853853                String s = new String(bytes, StandardCharsets.UTF_8);
  • trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java

    r8846 r9062  
    9393        }
    9494        int zoom;
    95         double lat, lon;
    9695        try {
    9796            zoom = Integer.parseInt(parts[0]);
     
    10099            return null;
    101100        }
     101        double lat, lon;
    102102        try {
    103103            lat = Double.parseDouble(parts[1]);
  • trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java

    r8924 r9062  
    6767     */
    6868    public static WindowGeometry centerInWindow(Component reference, Dimension extent) {
    69         Window parentWindow = null;
    7069        while (reference != null && !(reference instanceof Window)) {
    7170            reference = reference.getParent();
     
    7372        if (reference == null)
    7473            return new WindowGeometry(new Point(0, 0), extent);
    75         parentWindow = (Window) reference;
     74        Window parentWindow = (Window) reference;
    7675        Point topLeft = new Point(
    7776                Math.max(0, (parentWindow.getSize().width - extent.width) /2),
  • trunk/src/org/openstreetmap/josm/tools/date/PrimaryDateParser.java

    r8870 r9062  
    4141
    4242    private static boolean isDateInShortStandardFormat(String date) {
    43         char[] dateChars;
    4443        // We can only parse the date if it is in a very specific format.
    4544        // eg. 2007-09-23T08:25:43Z
     
    4948        }
    5049
    51         dateChars = date.toCharArray();
     50        char[] dateChars = date.toCharArray();
    5251
    5352        // Make sure any fixed characters are in the correct place.
     
    108107
    109108    private static boolean isDateInLongStandardFormat(String date) {
    110         char[] dateChars;
    111109        // We can only parse the date if it is in a very specific format.
    112110        // eg. 2007-09-23T08:25:43.000Z
     
    116114        }
    117115
    118         dateChars = date.toCharArray();
     116        char[] dateChars = date.toCharArray();
    119117
    120118        // Make sure any fixed characters are in the correct place.
Note: See TracChangeset for help on using the changeset viewer.