Changeset 10965 in josm for trunk


Ignore:
Timestamp:
2016-09-05T23:50:16+02:00 (3 years ago)
Author:
Don-vip
Message:

sonar - squid:S1226 - Method parameters, caught exceptions and foreach variables should not be reassigned

Location:
trunk/src/org/openstreetmap/josm
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java

    r10762 r10965  
    201201        IDiskCacheAttributes ret;
    202202        removeStaleFiles(cachePath + File.separator + cacheName, USE_BLOCK_CACHE.get() ? "_INDEX_v2" : "_BLOCK_v2");
    203         cacheName = cacheName + (USE_BLOCK_CACHE.get() ? "_BLOCK_v2" : "_INDEX_v2");
     203        String newCacheName = cacheName + (USE_BLOCK_CACHE.get() ? "_BLOCK_v2" : "_INDEX_v2");
    204204
    205205        if (USE_BLOCK_CACHE.get()) {
     
    211211             * wants to reduce the file size, (s)he may just go to preferences and there it should be handled (by removing old file)
    212212             */
    213             File diskCacheFile = new File(cachePath + File.separator + cacheName + ".data");
     213            File diskCacheFile = new File(cachePath + File.separator + newCacheName + ".data");
    214214            if (diskCacheFile.exists()) {
    215215                blockAttr.setMaxKeySize((int) Math.max(maxDiskObjects, diskCacheFile.length()/1024));
     
    231231            ret.setDiskPath(cachePath);
    232232        }
    233         ret.setCacheName(cacheName);
     233        ret.setCacheName(newCacheName);
    234234
    235235        return ret;
  • trunk/src/org/openstreetmap/josm/data/projection/proj/ObliqueMercator.java

    r10938 r10965  
    414414        double up = (vp * cosgamma0 + sp * singamma0) / (0.5 * (qp + temp));
    415415        if (Math.abs(Math.abs(up) - 1.0) < EPSILON) {
    416             x = 0.0;
    417             y = up < 0.0 ? -Math.PI / 2.0 : Math.PI / 2.0;
     416            return new double[] {
     417                up < 0.0 ? -(Math.PI / 2.0) : (Math.PI / 2.0),
     418                0.0};
    418419        } else {
    419             y = Math.pow(e / Math.sqrt((1. + up) / (1. - up)), 1.0 / b);  //calculate t
    420             y = cphi2(y);
    421             x = -Math.atan2(sp * cosgamma0 - vp * singamma0, Math.cos(bra * u)) / b;
    422         }
    423         return new double[] {y, x};
     420            return new double[] {
     421                cphi2(Math.pow(e / Math.sqrt((1. + up) / (1. - up)), 1.0 / b)), //calculate t
     422                -Math.atan2(sp * cosgamma0 - vp * singamma0, Math.cos(bra * u)) / b};
     423        }
    424424    }
    425425
  • trunk/src/org/openstreetmap/josm/data/validation/routines/DomainValidator.java

    r10923 r10965  
    157157            return false;
    158158        }
    159         domain = unicodeToASCII(domain);
     159        String asciiDomain = unicodeToASCII(domain);
    160160        // hosts must be equally reachable via punycode and Unicode
    161161        // Unicode is never shorter than punycode, so check punycode
    162162        // if domain did not convert, then it will be caught by ASCII
    163163        // checks in the regexes below
    164         if (domain.length() > MAX_DOMAIN_LENGTH) {
     164        if (asciiDomain.length() > MAX_DOMAIN_LENGTH) {
    165165            return false;
    166166        }
    167         String[] groups = domainRegex.match(domain);
     167        String[] groups = domainRegex.match(asciiDomain);
    168168        if (groups != null && groups.length > 0) {
    169169            return isValidTld(groups[0]);
    170170        }
    171         return allowLocal && hostnameRegex.isValid(domain);
     171        return allowLocal && hostnameRegex.isValid(asciiDomain);
    172172    }
    173173
     
    183183            return false;
    184184        }
    185         domain = unicodeToASCII(domain);
     185        String asciiDomain = unicodeToASCII(domain);
    186186        // hosts must be equally reachable via punycode and Unicode
    187187        // Unicode is never shorter than punycode, so check punycode
    188188        // if domain did not convert, then it will be caught by ASCII
    189189        // checks in the regexes below
    190         if (domain.length() > MAX_DOMAIN_LENGTH) {
     190        if (asciiDomain.length() > MAX_DOMAIN_LENGTH) {
    191191            return false;
    192192        }
    193         String[] groups = domainRegex.match(domain);
     193        String[] groups = domainRegex.match(asciiDomain);
    194194        return (groups != null && groups.length > 0)
    195                 || hostnameRegex.isValid(domain);
     195                || hostnameRegex.isValid(asciiDomain);
    196196    }
    197197
     
    204204     */
    205205    public boolean isValidTld(String tld) {
    206         tld = unicodeToASCII(tld);
    207         if (allowLocal && isValidLocalTld(tld)) {
     206        String asciiTld = unicodeToASCII(tld);
     207        if (allowLocal && isValidLocalTld(asciiTld)) {
    208208            return true;
    209209        }
    210         return isValidInfrastructureTld(tld)
    211                 || isValidGenericTld(tld)
    212                 || isValidCountryCodeTld(tld);
     210        return isValidInfrastructureTld(asciiTld)
     211                || isValidGenericTld(asciiTld)
     212                || isValidCountryCodeTld(asciiTld);
    213213    }
    214214
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r10941 r10965  
    442442    public static void addLayerChangeListener(LayerChangeListener listener, boolean initialFire) {
    443443        if (listener != null) {
    444             initialFire = initialFire && (Main.isDisplayingMapView() || fireDeprecatedListenerOnAdd);
    445 
    446             LayerChangeAdapter adapter = new LayerChangeAdapter(listener, initialFire);
    447             Main.getLayerManager().addLayerChangeListener(adapter, initialFire);
    448             if (initialFire) {
     444            boolean doInitialFire = initialFire && (Main.isDisplayingMapView() || fireDeprecatedListenerOnAdd);
     445
     446            LayerChangeAdapter adapter = new LayerChangeAdapter(listener, doInitialFire);
     447            Main.getLayerManager().addLayerChangeListener(adapter, doInitialFire);
     448            if (doInitialFire) {
    449449                Main.getLayerManager().addAndFireActiveLayerChangeListener(adapter);
    450450            } else {
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r10925 r10965  
    550550     * Zoom to the given coordinate and scale.
    551551     *
    552      * @param newCenter The center x-value (easting) to zoom to.
    553      * @param newScale The scale to use.
     552     * @param center The center x-value (easting) to zoom to.
     553     * @param scale The scale to use.
    554554     * @param initial true if this call initializes the viewport.
    555555     */
    556     public void zoomTo(EastNorth newCenter, double newScale, boolean initial) {
     556    public void zoomTo(EastNorth center, double scale, boolean initial) {
    557557        Bounds b = getProjection().getWorldBoundsLatLon();
    558558        ProjectionBounds pb = getProjection().getWorldBoundsBoxEastNorth();
     559        double newScale = scale;
    559560        int width = getWidth();
    560561        int height = getHeight();
    561562
    562563        // make sure, the center of the screen is within projection bounds
    563         double east = newCenter.east();
    564         double north = newCenter.north();
     564        double east = center.east();
     565        double north = center.north();
    565566        east = Math.max(east, pb.minEast);
    566567        east = Math.min(east, pb.maxEast);
    567568        north = Math.max(north, pb.minNorth);
    568569        north = Math.min(north, pb.maxNorth);
    569         newCenter = new EastNorth(east, north);
     570        EastNorth newCenter = new EastNorth(east, north);
    570571
    571572        // don't zoom out too much, the world bounds should be at least
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java

    r10777 r10965  
    7171                firstGroupIdx = i;
    7272            }
    73             lastWct = wct;
     73            return wct;
    7474        }
    7575        return lastWct;
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/ColorfulImageProcessor.java

    r10757 r10965  
    7777
    7878        @Override
    79         public BufferedImage filter(BufferedImage src, BufferedImage dest) {
     79        public BufferedImage filter(BufferedImage src, BufferedImage dst) {
    8080            if (src.getWidth() == 0 || src.getHeight() == 0) {
    8181                return src;
    8282            }
    8383
     84            BufferedImage dest = dst;
    8485            if (dest == null) {
    8586                dest = createCompatibleDestImage(src, null);
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactory.java

    r10940 r10965  
    803803
    804804        protected static Method getMethod(String id) {
    805             id = id.replaceAll("-|_", "");
     805            String cleanId = id.replaceAll("-|_", "");
    806806            for (Method method : PseudoClasses.class.getDeclaredMethods()) {
    807807                // for backwards compatibility, consider :sameTags == :same-tags == :same_tags (#11150)
    808808                final String methodName = method.getName().replaceAll("-|_", "");
    809                 if (methodName.equalsIgnoreCase(id)) {
     809                if (methodName.equalsIgnoreCase(cleanId)) {
    810810                    return method;
    811811                }
  • trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java

    r10616 r10965  
    130130    }
    131131
    132     protected void scanLocalPluginRepository(ProgressMonitor monitor, File pluginsDirectory) {
     132    protected void scanLocalPluginRepository(ProgressMonitor progressMonitor, File pluginsDirectory) {
    133133        if (pluginsDirectory == null)
    134134            return;
    135         if (monitor == null)
    136             monitor = NullProgressMonitor.INSTANCE;
     135        ProgressMonitor monitor = progressMonitor != null ? progressMonitor : NullProgressMonitor.INSTANCE;
    137136        try {
    138137            monitor.beginTask("");
Note: See TracChangeset for help on using the changeset viewer.