Ignore:
Timestamp:
2017-01-12T01:24:40+01:00 (7 years ago)
Author:
Don-vip
Message:

sonar - fb-contrib:SEO_SUBOPTIMAL_EXPRESSION_ORDER - Performance - Method orders expressions in a conditional in a sub optimal way

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r11367 r11452  
    616616            double den = 100 * getScale();
    617617            double scaleMin = 0.01 * den / dm / 100;
    618             if (!Double.isInfinite(scaleMin) && newScale < scaleMin) {
     618            if (newScale < scaleMin && !Double.isInfinite(scaleMin)) {
    619619                newScale = scaleMin;
    620620            }
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapControler.java

    r11386 r11452  
    130130    @Override
    131131    public void mouseDragged(MouseEvent e) {
    132         if ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == MouseEvent.BUTTON1_DOWN_MASK &&
    133                 !(Main.isPlatformOsx() && e.getModifiersEx() == MAC_MOUSE_BUTTON3_MASK) && iStartSelectionPoint != null) {
     132        if (iStartSelectionPoint != null && (e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == MouseEvent.BUTTON1_DOWN_MASK
     133                && !(Main.isPlatformOsx() && e.getModifiersEx() == MAC_MOUSE_BUTTON3_MASK)) {
    134134            iEndSelectionPoint = e.getPoint();
    135135            iSlippyMapChooser.setSelection(iStartSelectionPoint, iEndSelectionPoint);
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecision.java

    r10378 r11452  
    8383        RelationMemberConflictDecision that = (RelationMemberConflictDecision) obj;
    8484        return pos == that.pos &&
    85                 Objects.equals(relation, that.relation) &&
    86                 Objects.equals(originalPrimitive, that.originalPrimitive) &&
    87                 Objects.equals(role, that.role) &&
    88                 decision == that.decision;
     85               decision == that.decision &&
     86               Objects.equals(relation, that.relation) &&
     87               Objects.equals(originalPrimitive, that.originalPrimitive) &&
     88               Objects.equals(role, that.role);
    8989    }
    9090
  • trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java

    r11357 r11452  
    246246            for (int i = 0; i < n; ++i) {
    247247                final ToggleDialog dlg = allDialogs.get(i);
    248                 if (dlg.isDialogInDefaultView() && dlg != triggeredBy) {
     248                if (dlg != triggeredBy && dlg.isDialogInDefaultView()) {
    249249                    final int ha = dlg.getSize().height;                              // current
    250250                    final int h0 = ha * r / sumA;                                     // proportional shrinking
     
    261261            for (int i = 0; i < n; ++i) {
    262262                final ToggleDialog dlg = allDialogs.get(i);
    263                 if (dlg.isDialogInDefaultView() && dlg != triggeredBy) {
     263                if (dlg != triggeredBy && dlg.isDialogInDefaultView()) {
    264264                    final int ha = dlg.getHeight();
    265265                    final int h0 = ha * r / sumA;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/FilterTableModel.java

    r10627 r11452  
    118118        }
    119119
    120         if (Main.isDisplayingMapView() && changed) {
     120        if (changed && Main.isDisplayingMapView()) {
    121121            Main.map.mapView.repaint();
    122122            Main.map.filterDialog.updateDialogHeader();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java

    r11177 r11452  
    159159                txtMappaint.append(tr("The 2 selected objects have different style caches."));
    160160            }
    161             if (sc1.equals(sc2) && sc1 != sc2) {
     161            if (sc1 != sc2 && sc1.equals(sc2)) {
    162162                txtMappaint.append(tr("Warning: The 2 selected objects have equal, but not identical style caches."));
    163163            }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/MinimapDialog.java

    r10784 r11452  
    5555    @Override
    5656    public void zoomChanged() {
    57         if (Main.isDisplayingMapView() && !skipEvents) {
     57        if (!skipEvents && Main.isDisplayingMapView()) {
    5858            MapView mv = Main.map.mapView;
    5959            final Bounds currentBounds = new Bounds(
  • trunk/src/org/openstreetmap/josm/gui/dialogs/layer/LayerListTransferHandler.java

    r10762 r11452  
    9696            boolean isSameLayerManager = tableModel.getLayerManager() == layers.getManager();
    9797
    98             if (support.getDropAction() == MOVE && isSameLayerManager) {
     98            if (isSameLayerManager && support.getDropAction() == MOVE) {
    9999                for (Layer layer : layers.getLayers()) {
    100100                    boolean wasBeforeInsert = layers.getManager().getLayers().indexOf(layer) <= dropLocation;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r11386 r11452  
    12071207                         *  content lengths, so we have to be fuzzy.. (this is UGLY, recode if u know better)
    12081208                         */
    1209                         if (conn.getContentLength() != -1 && osize > -1 && Math.abs(conn.getContentLength() - osize) > 200) {
     1209                        if (osize > -1 && conn.getContentLength() != -1 && Math.abs(conn.getContentLength() - osize) > 200) {
    12101210                            Main.info("{0} is a mediawiki redirect", u);
    12111211                            conn.disconnect();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java

    r10965 r11452  
    9898            }
    9999
    100             if (!RelationSortUtils.isOneway(m) && lastWct != null) {
     100            if (lastWct != null && !RelationSortUtils.isOneway(m)) {
    101101                wct.direction = determineDirection(i-1, lastWct.direction, i);
    102102                wct.linkPrev = wct.direction != NONE;
     
    307307                        return FORWARD;
    308308                }
    309                 if (n == RelationNodeMap.lastOnewayNode(m) && reversed) {
     309                if (reversed && n == RelationNodeMap.lastOnewayNode(m)) {
    310310                    if (RelationSortUtils.isBackward(m))
    311311                        return FORWARD;
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java

    r11366 r11452  
    643643        Collection<String> history = Main.pref.getCollection(historyKey, def);
    644644        int age = (int) (System.currentTimeMillis() / 1000 - Main.pref.getInteger(BasicUploadSettingsPanel.HISTORY_LAST_USED_KEY, 0));
    645         if (age < Main.pref.getLong(BasicUploadSettingsPanel.HISTORY_MAX_AGE_KEY, TimeUnit.HOURS.toMillis(4))
    646                 && history != null && !history.isEmpty()) {
     645        if (history != null && age < Main.pref.getLong(BasicUploadSettingsPanel.HISTORY_MAX_AGE_KEY, TimeUnit.HOURS.toMillis(4))
     646                && !history.isEmpty()) {
    647647            return history.iterator().next();
    648648        } else {
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r11381 r11452  
    15841584            List<Tile> newlyMissedTiles = new LinkedList<>();
    15851585            for (Tile missed : missedTiles) {
    1586                 if ("no-tile".equals(missed.getValue("tile-info")) && zoomOffset > 0) {
     1586                if (zoomOffset > 0 && "no-tile".equals(missed.getValue("tile-info"))) {
    15871587                    // Don't try to paint from higher zoom levels when tile is overzoomed
    15881588                    newlyMissedTiles.add(missed);
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r11288 r11452  
    10711071            }
    10721072
    1073             if (e.isTagged() && e.getExifCoor() == null && !tagged) {
     1073            if (!tagged && e.isTagged() && e.getExifCoor() == null) {
    10741074                continue;
    10751075            }
     
    12021202            }
    12031203
    1204             if (curImg.tmp.getPos() == null && prevWp != null) {
     1204            if (prevWp != null && curImg.tmp.getPos() == null) {
    12051205                // The values of timeDiff are between 0 and 1, it is not seconds but a dimensionless variable
    12061206                double timeDiff = (double) (imgTime - prevWpTime) / interval;
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java

    r10763 r11452  
    306306            imageChanged = currentEntry != entry;
    307307
    308             if (centerView && Main.isDisplayingMapView() && entry != null && entry.getPos() != null) {
     308            if (centerView && entry != null && Main.isDisplayingMapView() && entry.getPos() != null) {
    309309                Main.map.mapView.zoomTo(entry.getPos());
    310310            }
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java

    r11451 r11452  
    175175        SystemOfMeasurement som = SystemOfMeasurement.getSystemOfMeasurement();
    176176        velocityScale.addTitle(tr("Velocity, {0}", som.speedName));
    177         if (Main.isDisplayingMapView() && oldSoM != null && newSoM != null) {
     177        if (oldSoM != null && newSoM != null && Main.isDisplayingMapView()) {
    178178            Main.map.mapView.repaint();
    179179        }
     
    11671167     */
    11681168    private void checkCache() {
    1169         if ((computeCacheMaxLineLengthUsed != maxLineLength) || (!neutralColor.equals(computeCacheColorUsed))
    1170                 || (computeCacheColored != colored) || (computeCacheColorTracksTune != colorTracksTune)
     1169        if ((computeCacheMaxLineLengthUsed != maxLineLength)
     1170                || (computeCacheColored != colored)
     1171                || (computeCacheColorTracksTune != colorTracksTune)
    11711172                || (computeCacheColorDynamic != colorModeDynamic)
    11721173                || (computeCacheHeatMapDrawColorTableIdx != heatMapDrawColorTableIdx)
     1174                || (!neutralColor.equals(computeCacheColorUsed))
    11731175      ) {
    11741176            computeCacheMaxLineLengthUsed = maxLineLength;
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java

    r11366 r11452  
    166166
    167167        // (a) try explicit timestamped waypoints - unless suppressed
    168         if (Main.pref.getBoolean("marker.audiofromexplicitwaypoints", true) && hasWaypoints) {
     168        if (hasWaypoints && Main.pref.getBoolean("marker.audiofromexplicitwaypoints", true)) {
    169169            for (WayPoint w : layer.data.waypoints) {
    170170                if (w.time > firstTime) {
     
    177177
    178178        // (b) try explicit waypoints without timestamps - unless suppressed
    179         if (Main.pref.getBoolean("marker.audiofromuntimedwaypoints", true) && hasWaypoints) {
     179        if (hasWaypoints && Main.pref.getBoolean("marker.audiofromuntimedwaypoints", true)) {
    180180            for (WayPoint w : layer.data.waypoints) {
    181181                if (waypoints.contains(w)) {
     
    197197
    198198        // (c) use explicitly named track points, again unless suppressed
    199         if ((Main.pref.getBoolean("marker.audiofromnamedtrackpoints", false)) && layer.data.tracks != null
     199        if (layer.data.tracks != null && Main.pref.getBoolean("marker.audiofromnamedtrackpoints", false)
    200200                && !layer.data.tracks.isEmpty()) {
    201201            for (GpxTrack track : layer.data.tracks) {
     
    211211
    212212        // (d) use timestamp of file as location on track
    213         if ((Main.pref.getBoolean("marker.audiofromwavtimestamps", false)) && hasTracks) {
     213        if (hasTracks && Main.pref.getBoolean("marker.audiofromwavtimestamps", false)) {
    214214            double lastModified = wavFile.lastModified() / 1000.0; // lastModified is in
    215215            // milliseconds
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/BoxTextElement.java

    r10600 r11452  
    282282        if (!super.equals(obj)) return false;
    283283        BoxTextElement that = (BoxTextElement) obj;
    284         return Objects.equals(text, that.text) &&
    285                 Objects.equals(boxProvider, that.boxProvider) &&
    286                 Objects.equals(box, that.box) &&
    287                 hAlign == that.hAlign &&
    288                 vAlign == that.vAlign;
     284        return hAlign == that.hAlign &&
     285               vAlign == that.vAlign &&
     286               Objects.equals(text, that.text) &&
     287               Objects.equals(boxProvider, that.boxProvider) &&
     288               Objects.equals(box, that.box);
    289289    }
    290290
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineElement.java

    r11090 r11452  
    160160            return false;
    161161        final LineElement other = (LineElement) obj;
    162         return Objects.equals(line, other.line) &&
    163             Objects.equals(color, other.color) &&
    164             Objects.equals(dashesLine, other.dashesLine) &&
    165             Objects.equals(dashesBackground, other.dashesBackground) &&
    166             offset == other.offset &&
    167             realWidth == other.realWidth &&
    168             wayDirectionArrows == other.wayDirectionArrows;
     162        return offset == other.offset &&
     163               realWidth == other.realWidth &&
     164               wayDirectionArrows == other.wayDirectionArrows &&
     165               Objects.equals(line, other.line) &&
     166               Objects.equals(color, other.color) &&
     167               Objects.equals(dashesLine, other.dashesLine) &&
     168               Objects.equals(dashesBackground, other.dashesBackground);
    169169    }
    170170
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/RepeatImageElement.java

    r11148 r11452  
    9696        if (!super.equals(obj)) return false;
    9797        RepeatImageElement that = (RepeatImageElement) obj;
    98         return Float.compare(that.offset, offset) == 0 &&
    99                 Float.compare(that.spacing, spacing) == 0 &&
    100                 Float.compare(that.phase, phase) == 0 &&
    101                 Objects.equals(pattern, that.pattern) &&
    102                 align == that.align;
     98        return align == that.align &&
     99               Float.compare(that.offset, offset) == 0 &&
     100               Float.compare(that.spacing, spacing) == 0 &&
     101               Float.compare(that.phase, phase) == 0 &&
     102               Objects.equals(pattern, that.pattern);
    103103    }
    104104
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/StyleElement.java

    r10238 r11452  
    199199        if (o == null || getClass() != o.getClass()) return false;
    200200        StyleElement that = (StyleElement) o;
    201         return Float.compare(that.majorZIndex, majorZIndex) == 0 &&
    202                 Float.compare(that.zIndex, zIndex) == 0 &&
    203                 Float.compare(that.objectZIndex, objectZIndex) == 0 &&
    204                 isModifier == that.isModifier;
     201        return isModifier == that.isModifier &&
     202               Float.compare(that.majorZIndex, majorZIndex) == 0 &&
     203               Float.compare(that.zIndex, zIndex) == 0 &&
     204               Float.compare(that.objectZIndex, objectZIndex) == 0;
    205205    }
    206206
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionManager.java

    r11384 r11452  
    9494            }
    9595            final UserInputTag other = (UserInputTag) obj;
    96             return Objects.equals(this.key, other.key)
    97                 && Objects.equals(this.value, other.value)
    98                 && this.defaultKey == other.defaultKey;
     96            return this.defaultKey == other.defaultKey
     97                && Objects.equals(this.key, other.key)
     98                && Objects.equals(this.value, other.value);
    9999        }
    100100    }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Check.java

    r9665 r11452  
    9292    public void addCommands(List<Tag> changedTags) {
    9393        // if the user hasn't changed anything, don't create a command.
    94         if (check.getState() == initialState && def == null) return;
     94        if (def == null && check.getState() == initialState) return;
    9595
    9696        // otherwise change things according to the selected value.
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Combo.java

    r11017 r11452  
    8585            // all items were unset (and so is default)
    8686            originalValue = lhm.get("");
    87             if ("force".equals(use_last_as_default) && LAST_VALUES.containsKey(key) && !presetInitiallyMatches) {
     87            if (!presetInitiallyMatches && "force".equals(use_last_as_default) && LAST_VALUES.containsKey(key)) {
    8888                combobox.setSelectedItem(lhm.get(LAST_VALUES.get(key)));
    8989            } else {
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java

    r11381 r11452  
    492492        }
    493493
    494         if (Main.pref.getBoolean("taggingpreset.sortvalues", true) && values_sort) {
     494        if (values_sort && Main.pref.getBoolean("taggingpreset.sortvalues", true)) {
    495495            Collections.sort(entries);
    496496        }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Text.java

    r11017 r11452  
    8888            } else if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) {
    8989                // selected osm primitives are untagged or filling default values feature is enabled
    90                 if (!"false".equals(use_last_as_default) && LAST_VALUES.containsKey(key) && !presetInitiallyMatches) {
     90                if (!presetInitiallyMatches && !"false".equals(use_last_as_default) && LAST_VALUES.containsKey(key)) {
    9191                    textField.setText(LAST_VALUES.get(key));
    9292                } else {
  • trunk/src/org/openstreetmap/josm/gui/widgets/JMultilineLabel.java

    r9463 r11452  
    6666
    6767    /**
    68      * Tries to determine a suitable height for the given contents and return
    69      * that dimension.
     68     * Tries to determine a suitable height for the given contents and return that dimension.
    7069     */
    7170    @Override
    7271    public Dimension getPreferredSize() {
    73         // Without this check it will result in an infinite loop calling
    74         // getPreferredSize. Remember the old bounds and only recalculate if
    75         // the size actually changed.
    76         if (this.getBounds().equals(oldbounds) && oldPreferred != null) {
     72        // Without this check it will result in an infinite loop calling getPreferredSize.
     73        // Remember the old bounds and only recalculate if the size actually changed.
     74        if (oldPreferred != null && this.getBounds().equals(oldbounds)) {
    7775            return oldPreferred;
    7876        }
Note: See TracChangeset for help on using the changeset viewer.