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

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

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java

    r8870 r9062  
    162162        }
    163163
    164         // now we can start doing things to OSM data
    165         Collection<Command> cmds = new LinkedList<>();
    166         EastNorth center = null;
     164        EastNorth center;
    167165
    168166        if (nodes.size() == 2) {
     
    201199        int[] count = distributeNodes(angles,
    202200                numberOfNodesInCircle >= nodes.size() ? numberOfNodesInCircle - nodes.size() : 0);
     201
     202        // now we can start doing things to OSM data
     203        Collection<Command> cmds = new LinkedList<>();
    203204
    204205        // build a way for the circle
  • trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java

    r8870 r9062  
    141141
    142142        final Collection<Way> selectedWays = Main.main.getCurrentDataSet().getSelectedWays();
    143         final Collection<Relation> selectedRelations = Main.main.getCurrentDataSet().getSelectedRelations();
    144143
    145144        if (selectedWays.isEmpty()) {
     
    154153        }
    155154
     155        final Collection<Relation> selectedRelations = Main.main.getCurrentDataSet().getSelectedRelations();
    156156        final Relation multipolygonRelation = update
    157157                ? getSelectedMultipolygonRelation(selectedWays, selectedRelations)
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r8955 r9062  
    768768    private List<WayInPolygon> markWayInsideSide(List<Way> parts, boolean isInner) {
    769769
    770         List<WayInPolygon> result = new ArrayList<>();
    771 
    772770        //prepare next map
    773771        Map<Way, Way> nextWayMap = new HashMap<>();
     
    854852        Way curWay = topWay;
    855853        boolean curWayInsideToTheRight = wayClockwise ^ isInner;
     854        List<WayInPolygon> result = new ArrayList<>();
    856855
    857856        //iterate till full circle is reached
  • trunk/src/org/openstreetmap/josm/actions/JumpToAction.java

    r8670 r9062  
    9797
    9898        double dist = mv.getDist100Pixel();
    99         double zoomFactor = 1/dist;
    100 
    10199        zm.setText(Long.toString(Math.round(dist*100)/100));
    102100        updateUrl(true);
     
    161159        }
    162160
     161        double zoomFactor = 1/dist;
    163162        mv.zoomToFactor(mv.getProjection().latlon2eastNorth(ll), zoomFactor * zoomLvl);
    164163    }
  • trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java

    r8919 r9062  
    314314        try {
    315315            TagCollection nodeTags = TagCollection.unionOfAllPrimitives(nodes);
    316             List<Command> resultion = CombinePrimitiveResolverDialog.launchIfNecessary(nodeTags, nodes, Collections.singleton(targetNode));
    317             List<Command> cmds = new LinkedList<>();
    318316
    319317            // the nodes we will have to delete
     
    324322            // fix the ways referring to at least one of the merged nodes
    325323            //
    326             Collection<Way> waysToDelete = new HashSet<>();
    327             List<Command> wayFixCommands = fixParentWays(
    328                     nodesToDelete,
    329                     targetNode);
     324            List<Command> wayFixCommands = fixParentWays(nodesToDelete, targetNode);
    330325            if (wayFixCommands == null) {
    331326                return null;
    332327            }
    333             cmds.addAll(wayFixCommands);
     328            List<Command> cmds = new LinkedList<>(wayFixCommands);
    334329
    335330            // build the commands
     
    343338                }
    344339            }
    345             cmds.addAll(resultion);
     340            cmds.addAll(CombinePrimitiveResolverDialog.launchIfNecessary(nodeTags, nodes, Collections.singleton(targetNode)));
    346341            if (!nodesToDelete.isEmpty()) {
    347342                cmds.add(new DeleteCommand(nodesToDelete));
    348             }
    349             if (!waysToDelete.isEmpty()) {
    350                 cmds.add(new DeleteCommand(waysToDelete));
    351343            }
    352344            return new SequenceCommand(/* for correct i18n of plural forms - see #9110 */
  • trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java

    r8510 r9062  
    189189     */
    190190    public void openUrl(boolean newLayer, final String url) {
    191         PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download Data"));
    192191        Collection<DownloadTask> tasks = findDownloadTasks(url, false);
    193192
     
    198197            return;
    199198        }
     199
     200        PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download Data"));
    200201
    201202        for (final DownloadTask task : tasks) {
     
    207208            }
    208209        }
    209 
    210210    }
    211211
  • trunk/src/org/openstreetmap/josm/actions/SelectNonBranchingWaySequences.java

    r8780 r9062  
    136136     */
    137137    public void extend(DataSet data) {
    138         Collection<OsmPrimitive> currentSelection;
    139         Collection<OsmPrimitive> selection;
    140         boolean selectionChanged = false;
    141         Way way;
    142 
    143138        if (!canExtend())
    144139            return;
    145140
    146         currentSelection = data.getSelected();
     141        Collection<OsmPrimitive> currentSelection = data.getSelected();
    147142
    148         way = findWay(currentSelection);
     143        Way way = findWay(currentSelection);
    149144
    150145        if (way == null)
    151146            return;
    152147
    153         selection = new LinkedList<>();
     148        boolean selectionChanged = false;
     149        Collection<OsmPrimitive> selection = new LinkedList<>();
    154150        for (OsmPrimitive primitive : currentSelection) {
    155151            selection.add(primitive);
  • trunk/src/org/openstreetmap/josm/actions/SessionSaveAsAction.java

    r8919 r9062  
    230230
    231231        protected final Component build() {
    232             JPanel p = new JPanel(new GridBagLayout());
    233232            JPanel ip = new JPanel(new GridBagLayout());
    234233            for (Layer layer : layers) {
     
    249248            JScrollPane sp = new JScrollPane(ip);
    250249            sp.setBorder(BorderFactory.createEmptyBorder());
     250            JPanel p = new JPanel(new GridBagLayout());
    251251            p.add(sp, GBC.eol().fill());
    252252            final JTabbedPane tabs = new JTabbedPane();
  • trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java

    r8990 r9062  
    137137        List<Node> selectedNodes = OsmPrimitive.getFilteredList(selection, Node.class);
    138138        List<Way> selectedWays = OsmPrimitive.getFilteredList(selection, Way.class);
    139         List<Relation> selectedRelations =
    140             OsmPrimitive.getFilteredList(selection, Relation.class);
    141139        List<Way> applicableWays = getApplicableWays(selectedWays, selectedNodes);
    142140
     
    191189        final List<List<Node>> wayChunks = buildSplitChunks(selectedWay, selectedNodes);
    192190        if (wayChunks != null) {
     191            List<Relation> selectedRelations =
     192                    OsmPrimitive.getFilteredList(selection, Relation.class);
    193193            final List<OsmPrimitive> sel = new ArrayList<>(selectedWays.size() + selectedRelations.size());
    194194            sel.addAll(selectedWays);
  • trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java

    r8856 r9062  
    101101            }
    102102        }
    103         UploadHullBuilder builder = new UploadHullBuilder();
    104         UploadSelectionDialog dialog = new UploadSelectionDialog();
    105103        Collection<OsmPrimitive> modifiedCandidates = getModifiedPrimitives(getEditLayer().data.getAllSelected());
    106104        Collection<OsmPrimitive> deletedCandidates = getDeletedPrimitives(getEditLayer().data);
     
    114112            return;
    115113        }
     114        UploadSelectionDialog dialog = new UploadSelectionDialog();
    116115        dialog.populate(
    117116                modifiedCandidates,
     
    121120        if (dialog.isCanceled())
    122121            return;
    123         Collection<OsmPrimitive> toUpload = builder.build(dialog.getSelectedPrimitives());
     122        Collection<OsmPrimitive> toUpload = new UploadHullBuilder().build(dialog.getSelectedPrimitives());
    124123        if (toUpload.isEmpty()) {
    125124            JOptionPane.showMessageDialog(
  • trunk/src/org/openstreetmap/josm/actions/mapmode/AddNoteAction.java

    r8308 r9062  
    6868        }
    6969        Main.map.selectMapMode(Main.map.mapModeSelect);
    70         LatLon latlon = Main.map.mapView.getLatLon(e.getPoint().x, e.getPoint().y);
    7170
    7271        NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Create new note"), tr("Create note"));
     
    7978        String input = dialog.getInputText();
    8079        if (input != null && !input.isEmpty()) {
     80            LatLon latlon = Main.map.mapView.getLatLon(e.getPoint().x, e.getPoint().y);
    8181            noteData.createNote(latlon, input);
    8282        } else {
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r9059 r9062  
    394394        DataSet ds = getCurrentDataSet();
    395395        Collection<OsmPrimitive> selection = new ArrayList<>(ds.getSelected());
    396         Collection<Command> cmds = new LinkedList<>();
    397         Collection<OsmPrimitive> newSelection = new LinkedList<>(ds.getSelected());
    398 
    399         List<Way> reuseWays = new ArrayList<>(),
    400                 replacedWays = new ArrayList<>();
     396
    401397        boolean newNode = false;
    402398        Node n = null;
     
    451447            snapHelper.unsetFixedMode();
    452448        }
     449
     450        Collection<Command> cmds = new LinkedList<>();
     451        Collection<OsmPrimitive> newSelection = new LinkedList<>(ds.getSelected());
     452        List<Way> reuseWays = new ArrayList<>();
     453        List<Way> replacedWays = new ArrayList<>();
    453454
    454455        if (newNode) {
     
    769770     */
    770771    private void computeHelperLine() {
    771         MapView mv = Main.map.mapView;
    772772        if (mousePos == null) {
    773773            // Don't draw the line.
     
    779779        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
    780780
     781        MapView mv = Main.map.mapView;
    781782        Node currentMouseNode = null;
    782783        mouseOnExistingNode = null;
     
    12711272        public void actionPerformed(ActionEvent e) {
    12721273            Main.main.undoRedo.undo();
    1273             Node n = null;
    12741274            Command lastCmd = Main.main.undoRedo.commands.peekLast();
    12751275            if (lastCmd == null) return;
     1276            Node n = null;
    12761277            for (OsmPrimitive p: lastCmd.getParticipatingPrimitives()) {
    12771278                if (p instanceof Node) {
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java

    r8870 r9062  
    393393        mouseHasBeenDragged = true;
    394394
    395         Point p = e.getPoint();
    396395        if (mode == Mode.normal) {
    397396            // Should we ensure that the copyTags modifiers are still valid?
     
    407406
    408407        // Calculate distance to the reference line
     408        Point p = e.getPoint();
    409409        EastNorth enp = mv.getEastNorth((int) p.getX(), (int) p.getY());
    410410        EastNorth nearestPointOnRefLine = Geometry.closestPointToLine(referenceSegment.getFirstNode().getEastNorth(),
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r8985 r9062  
    11021102         */
    11031103        private Collection<OsmPrimitive> cyclePrims() {
    1104             OsmPrimitive nxt = null;
    1105 
    11061104            if (cycleList.size() <= 1) {
    11071105                // no real cycling, just return one-element collection with nearest primitive in it
     
    11121110            DataSet ds = getCurrentDataSet();
    11131111            OsmPrimitive first = cycleList.iterator().next(), foundInDS = null;
    1114             nxt = first;
     1112            OsmPrimitive nxt = first;
    11151113
    11161114            if (cyclePrims && shift) {
Note: See TracChangeset for help on using the changeset viewer.