Ignore:
Timestamp:
2015-10-10T21:01:42+02:00 (4 years ago)
Author:
Don-vip
Message:

sonar - Unused private method should be removed
sonar - Unused protected methods should be removed
sonar - Sections of code should not be "commented out"
sonar - Empty statements should be removed
sonar - squid:S1172 - Unused method parameters should be removed
sonar - squid:S1481 - Unused local variables should be removed

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

Legend:

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

    r8851 r8855  
    539539        }
    540540
    541         protected Node getStartNode() {
    542             Set<Node> nodes = getNodes();
    543             for (Node n: nodes) {
    544                 if (successors.get(n) != null && successors.get(n).size() == 1)
    545                     return n;
    546             }
    547             return null;
    548         }
    549 
    550541        protected Set<Node> getTerminalNodes() {
    551542            Set<Node> ret = new LinkedHashSet<>();
  • trunk/src/org/openstreetmap/josm/actions/MapRectifierWMSmenuAction.java

    r8846 r8855  
    217217            }
    218218
    219             // and display an error message. The while (true) ensures that the dialog pops up again
     219            // and display an error message. The while loop ensures that the dialog pops up again
    220220            JOptionPane.showMessageDialog(Main.parent,
    221221                    tr("Couldn''t match the entered link or id to the selected service. Please try again."),
  • trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java

    r8850 r8855  
    455455                    v = EN.diff(v, segment);
    456456                } else throw new IllegalStateException();
    457                 /**
    458                  * When summing up the length of the sum vector should increase.
    459                  * However, it is possible to construct ways, such that this assertion fails.
    460                  * So only uncomment this for testing
    461                  **/
    462                 //                if (segDirections[i].ordinal() % 2 == 0) {
    463                 //                    if (EN.abs(h) < lh) throw new AssertionError();
    464                 //                    lh = EN.abs(h);
    465                 //                } else {
    466                 //                    if (EN.abs(v) < lv) throw new AssertionError();
    467                 //                    lv = EN.abs(v);
    468                 //                }
    469457            }
    470458            // rotate the vertical vector by 90 degrees (clockwise) and add it to the horizontal vector
    471459            segSum = EN.sum(h, new EastNorth(v.north(), -v.east()));
    472             //            if (EN.abs(segSum) < lh) throw new AssertionError();
    473460            this.heading = EN.polar(new EastNorth(0., 0.), segSum);
    474461        }
  • trunk/src/org/openstreetmap/josm/actions/PasteTagsAction.java

    r8846 r8855  
    5656        private final Collection<PrimitiveData> source;
    5757        private final Collection<OsmPrimitive> target;
    58         private final List<Tag> commands = new ArrayList<>();
     58        private final List<Tag> tags = new ArrayList<>();
    5959
    6060        public TagPaster(Collection<PrimitiveData> source, Collection<OsmPrimitive> target) {
     
    109109        }
    110110
    111         protected void buildChangeCommand(Collection<? extends OsmPrimitive> selection, TagCollection tc) {
     111        protected void buildTags(TagCollection tc) {
    112112            for (String key : tc.getKeys()) {
    113                 commands.add(new Tag(key, tc.getValues(key).iterator().next()));
     113                tags.add(new Tag(key, tc.getValues(key).iterator().next()));
    114114            }
    115115        }
     
    161161                if (dialog.isCanceled())
    162162                    return;
    163                 buildChangeCommand(target, dialog.getResolution());
     163                buildTags(dialog.getResolution());
    164164            } else {
    165165                // no conflicts in the source tags to resolve. Just apply the tags
    166166                // to the target primitives
    167167                //
    168                 buildChangeCommand(target, tc);
     168                buildTags(tc);
    169169            }
    170170        }
     
    185185         * Replies true if this a heterogeneous source can be pasted without conflict to targets
    186186         *
    187          * @param targets the collection of target primitives
    188187         * @return true if this a heterogeneous source can be pasted without conflicts to targets
    189188         */
    190         protected boolean canPasteFromHeterogeneousSourceWithoutConflict(Collection<OsmPrimitive> targets) {
     189        protected boolean canPasteFromHeterogeneousSourceWithoutConflict() {
    191190            for (OsmPrimitiveType type : OsmPrimitiveType.dataValues()) {
    192191                if (hasTargetPrimitives(type.getOsmClass())) {
     
    200199
    201200        /**
    202          * Pastes the tags in the current selection of the paste buffer to a set of target
    203          * primitives.
     201         * Pastes the tags in the current selection of the paste buffer to a set of target primitives.
    204202         */
    205203        protected void pasteFromHeterogeneousSource() {
    206             if (canPasteFromHeterogeneousSourceWithoutConflict(target)) {
     204            if (canPasteFromHeterogeneousSourceWithoutConflict()) {
    207205                for (OsmPrimitiveType type : OsmPrimitiveType.dataValues()) {
    208206                    if (hasSourceTagsByType(type) && hasTargetPrimitives(type.getOsmClass())) {
    209                         buildChangeCommand(target, getSourceTagsByType(type));
     207                        buildTags(getSourceTagsByType(type));
    210208                    }
    211209                }
     
    224222                for (OsmPrimitiveType type : OsmPrimitiveType.dataValues()) {
    225223                    if (hasSourceTagsByType(type) && hasTargetPrimitives(type.getOsmClass())) {
    226                         buildChangeCommand(OsmPrimitive.getFilteredList(target, type.getOsmClass()), dialog.getResolution(type));
     224                        buildTags(dialog.getResolution(type));
    227225                    }
    228226                }
     
    231229
    232230        public List<Tag> execute() {
    233             commands.clear();
     231            tags.clear();
    234232            if (isHeteogeneousSource()) {
    235233                pasteFromHeterogeneousSource();
     
    237235                pasteFromHomogeneousSource();
    238236            }
    239             return commands;
     237            return tags;
    240238        }
    241239
  • trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java

    r8443 r8855  
    127127    }
    128128
    129     protected int getNumWaysInSelection() {
    130         if (getCurrentDataSet() == null) return 0;
    131         int ret = 0;
    132         for (OsmPrimitive primitive : getCurrentDataSet().getSelected()) {
    133             if (primitive instanceof Way) {
    134                 ret++;
    135             }
    136         }
    137         return ret;
    138     }
    139 
    140129    @Override
    141130    protected void updateEnabledState() {
  • trunk/src/org/openstreetmap/josm/actions/SearchNotesDownloadAction.java

    r8624 r8855  
    8181        try {
    8282            final long id = Long.parseLong(searchTerm);
    83             new DownloadNotesTask().download(false, id, null);
     83            new DownloadNotesTask().download(id, null);
    8484            return;
    8585        } catch (NumberFormatException ignore) {
  • trunk/src/org/openstreetmap/josm/actions/ValidateAction.java

    r8836 r8855  
    4848    @Override
    4949    public void actionPerformed(ActionEvent ev) {
    50         doValidate(ev, true);
     50        doValidate(true);
    5151    }
    5252
     
    5858     * revalidated
    5959     *
    60      * @param ev The event
    6160     * @param getSelectedItems If selected or last selected items must be validated
    6261     */
    63     public void doValidate(ActionEvent ev, boolean getSelectedItems) {
     62    public void doValidate(boolean getSelectedItems) {
    6463        if (Main.map == null || !Main.map.isVisible())
    6564            return;
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTask.java

    r8836 r8855  
    3838    private DownloadTask downloadTask;
    3939
    40     public Future<?> download(boolean newLayer, long id, ProgressMonitor progressMonitor) {
     40    public Future<?> download(long id, ProgressMonitor progressMonitor) {
    4141        final String url = OsmApi.getOsmApi().getBaseUrl() + "notes/" + id;
    4242        downloadTask = new DownloadRawUrlTask(new OsmServerLocationReader(url), progressMonitor);
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesUrlIdTask.java

    r8624 r8855  
    1818        final Matcher matcher = Pattern.compile(URL_ID_PATTERN).matcher(url);
    1919        if (matcher.matches()) {
    20             return download(newLayer, Long.parseLong(matcher.group(2)), null);
     20            return download(Long.parseLong(matcher.group(2)), null);
    2121        } else {
    2222            throw new IllegalStateException("Failed to parse note id from " + url);
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r8850 r8855  
    236236        Main.map.keyDetector.addModifierListener(this);
    237237        ignoreNextKeyRelease = true;
    238         // would like to but haven't got mouse position yet:
    239         // computeHelperLine(false, false, false);
    240238    }
    241239
  • trunk/src/org/openstreetmap/josm/actions/mapmode/MapMode.java

    r8510 r8855  
    2121 * is another.
    2222 *
    23  * MapModes should register/deregister all necessary listeners on the map's view
    24  * control.
     23 * MapModes should register/deregister all necessary listeners on the map's view control.
    2524 */
    2625public abstract class MapMode extends JosmAction implements MouseListener, MouseMotionListener {
     
    3231    /**
    3332     * Constructor for mapmodes without an menu
     33     * @param mapFrame unused but kept for plugin compatibility. Can be {@code null}
    3434     */
    3535    public MapMode(String name, String iconName, String tooltip, Shortcut shortcut, MapFrame mapFrame, Cursor cursor) {
     
    4141    /**
    4242     * Constructor for mapmodes with an menu (no shortcut will be registered)
     43     * @param mapFrame unused but kept for plugin compatibility. Can be {@code null}
    4344     */
    4445    public MapMode(String name, String iconName, String tooltip, MapFrame mapFrame, Cursor cursor) {
     
    8485    }
    8586
    86     // By default, all tools will work with all layers. Can be overwritten to require
    87     // a special type of layer
     87    /**
     88     * Determines if layer {@code l} is supported by this map mode.
     89     * By default, all tools will work with all layers.
     90     * Can be overwritten to require a special type of layer
     91     * @param l layer
     92     * @return {@code true} if the layer is supported by this map mode
     93     */
    8894    public boolean layerIsSupported(Layer l) {
    89         return true;
     95        return l != null;
    9096    }
    9197
Note: See TracChangeset for help on using the changeset viewer.