Ignore:
Timestamp:
2017-05-30T15:12:36+02:00 (3 years ago)
Author:
Don-vip
Message:

sonar - squid:S3878 - Arrays should not be created for varargs parameters

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

Legend:

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

    r12223 r12279  
    257257                Main.parent,
    258258                tr("Outdated Java version"),
    259                 new String[]{tr("OK"), tr("Update Java"), tr("Cancel")});
     259                tr("OK"), tr("Update Java"), tr("Cancel"));
    260260        // Check if the dialog has not already been permanently hidden by user
    261261        if (!ed.toggleEnable("askUpdateJava"+updVersion).toggleCheckState()) {
    262             ed.setButtonIcons(new String[]{"ok", "java", "cancel"}).setCancelButton(3);
     262            ed.setButtonIcons("ok", "java", "cancel").setCancelButton(3);
    263263            ed.setMinimumSize(new Dimension(480, 300));
    264264            ed.setIcon(JOptionPane.WARNING_MESSAGE);
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java

    r12268 r12279  
    130130            Class<?> eawtFullScreenUtilities = Class.forName("com.apple.eawt.FullScreenUtilities");
    131131            eawtFullScreenUtilities.getDeclaredMethod("setWindowCanFullScreen",
    132                     new Class[]{Window.class, boolean.class}).invoke(eawtFullScreenUtilities, window, Boolean.TRUE);
     132                    Window.class, boolean.class).invoke(eawtFullScreenUtilities, window, Boolean.TRUE);
    133133        } catch (ReflectiveOperationException | SecurityException | IllegalArgumentException e) {
    134134            Main.warn("Failed to register with OSX: " + e);
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r11553 r12279  
    183183
    184184    private void saveDefault() {
    185         Main.pref.getCollection("shortcut.entry."+shortText, Arrays.asList(new String[]{longText,
    186         String.valueOf(requestedKey), String.valueOf(requestedGroup), String.valueOf(requestedKey),
    187         String.valueOf(getGroupModifier(requestedGroup)), String.valueOf(true), String.valueOf(false)}));
     185        Main.pref.getCollection("shortcut.entry."+shortText, Arrays.asList(longText,
     186            String.valueOf(requestedKey), String.valueOf(requestedGroup), String.valueOf(requestedKey),
     187            String.valueOf(getGroupModifier(requestedGroup)), String.valueOf(true), String.valueOf(false)));
    188188    }
    189189
     
    193193            return Main.pref.putCollection("shortcut.entry."+shortText, null);
    194194        } else {
    195             return Main.pref.putCollection("shortcut.entry."+shortText, Arrays.asList(new String[]{longText,
    196             String.valueOf(requestedKey), String.valueOf(requestedGroup), String.valueOf(assignedKey),
    197             String.valueOf(assignedModifier), String.valueOf(assignedDefault), String.valueOf(assignedUser)}));
     195            return Main.pref.putCollection("shortcut.entry."+shortText, Arrays.asList(longText,
     196                String.valueOf(requestedKey), String.valueOf(requestedGroup), String.valueOf(assignedKey),
     197                String.valueOf(assignedModifier), String.valueOf(assignedDefault), String.valueOf(assignedUser)));
    198198        }
    199199    }
  • trunk/src/org/openstreetmap/josm/tools/TextTagParser.java

    r10763 r12279  
    281281                    Main.parent,
    282282                    tr("Do you want to paste these tags?"),
    283                     new String[]{tr("Ok"), tr("Cancel"), tr("Clear buffer"), tr("Ignore warnings")});
    284         ed.setButtonIcons(new String[]{"ok", "cancel", "dialogs/delete", "pastetags"});
     283                    tr("Ok"), tr("Cancel"), tr("Clear buffer"), tr("Ignore warnings"));
     284        ed.setButtonIcons("ok", "cancel", "dialogs/delete", "pastetags");
    285285        ed.setContent("<html><b>"+text + "</b><br/><br/><div width=\"300px\">"+XmlWriter.encode(data, true)+"</html>");
    286286        ed.setDefaultButton(2);
     
    314314                    Main.parent,
    315315                    tr("Warning"),
    316                     new String[]{tr("Ok"), tr("Clear buffer")});
    317 
    318         ed.setButtonIcons(new String[]{"ok", "dialogs/delete"});
    319 
    320         ed.setContent(p);
    321         ed.setDefaultButton(1);
    322         ed.setCancelButton(1);
    323         ed.setIcon(JOptionPane.WARNING_MESSAGE);
    324         ed.toggleEnable("tags.paste.cleanbadbuffer");
     316                    tr("Ok"), tr("Clear buffer"))
     317            .setButtonIcons("ok", "dialogs/delete")
     318            .setContent(p)
     319            .setDefaultButton(1)
     320            .setCancelButton(1)
     321            .setIcon(JOptionPane.WARNING_MESSAGE)
     322            .toggleEnable("tags.paste.cleanbadbuffer");
     323
    325324        ed.showDialog();
    326325
    327         int r = ed.getValue();
    328326        // clean clipboard if user asked
    329         if (r == 2) ClipboardUtils.copyString("");
     327        if (ed.getValue() == 2) ClipboardUtils.copyString("");
    330328    }
    331329}
  • trunk/src/org/openstreetmap/josm/tools/WinRegistry.java

    r12225 r12279  
    137137    private static String readString(Preferences root, int hkey, String key, String value)
    138138            throws IllegalAccessException, InvocationTargetException {
    139         int[] handles = (int[]) regOpenKey.invoke(root,
    140                 new Object[] { Integer.valueOf(hkey), toCstr(key), Integer.valueOf(KEY_READ) });
     139        int[] handles = (int[]) regOpenKey.invoke(root, Integer.valueOf(hkey), toCstr(key), Integer.valueOf(KEY_READ));
    141140        if (handles[1] != REG_SUCCESS) {
    142141            return null;
    143142        }
    144         byte[] valb = (byte[]) regQueryValueEx.invoke(root, new Object[] { Integer.valueOf(handles[0]), toCstr(value) });
    145         regCloseKey.invoke(root, new Object[] { Integer.valueOf(handles[0]) });
     143        byte[] valb = (byte[]) regQueryValueEx.invoke(root, Integer.valueOf(handles[0]), toCstr(value));
     144        regCloseKey.invoke(root, Integer.valueOf(handles[0]));
    146145        return (valb != null ? new String(valb, StandardCharsets.UTF_8).trim() : null);
    147146    }
     
    150149            throws IllegalAccessException, InvocationTargetException {
    151150        HashMap<String, String> results = new HashMap<>();
    152         int[] handles = (int[]) regOpenKey.invoke(root,
    153                 new Object[] { Integer.valueOf(hkey), toCstr(key), Integer.valueOf(KEY_READ) });
     151        int[] handles = (int[]) regOpenKey.invoke(root, Integer.valueOf(hkey), toCstr(key), Integer.valueOf(KEY_READ));
    154152        if (handles[1] != REG_SUCCESS) {
    155153            return null;
    156154        }
    157         int[] info = (int[]) regQueryInfoKey.invoke(root, new Object[] { Integer.valueOf(handles[0]) });
     155        int[] info = (int[]) regQueryInfoKey.invoke(root, Integer.valueOf(handles[0]));
    158156
    159157        int count = info[0]; // count
    160158        int maxlen = info[3]; // value length max
    161159        for (int index = 0; index < count; index++) {
    162             byte[] name = (byte[]) regEnumValue.invoke(root,
    163                     new Object[] { Integer.valueOf(handles[0]), Integer.valueOf(index), Integer.valueOf(maxlen + 1) });
     160            byte[] name = (byte[]) regEnumValue.invoke(root, Integer.valueOf(handles[0]), Integer.valueOf(index), Integer.valueOf(maxlen + 1));
    164161            String value = readString(hkey, key, new String(name, StandardCharsets.UTF_8));
    165162            results.put(new String(name, StandardCharsets.UTF_8).trim(), value);
    166163        }
    167         regCloseKey.invoke(root, new Object[] { Integer.valueOf(handles[0]) });
     164        regCloseKey.invoke(root, Integer.valueOf(handles[0]));
    168165        return results;
    169166    }
     
    172169            throws IllegalAccessException, InvocationTargetException {
    173170        List<String> results = new ArrayList<>();
    174         int[] handles = (int[]) regOpenKey.invoke(root,
    175                 new Object[] { Integer.valueOf(hkey), toCstr(key), Integer.valueOf(KEY_READ) });
     171        int[] handles = (int[]) regOpenKey.invoke(root, Integer.valueOf(hkey), toCstr(key), Integer.valueOf(KEY_READ));
    176172        if (handles[1] != REG_SUCCESS) {
    177173            return Collections.emptyList();
    178174        }
    179         int[] info = (int[]) regQueryInfoKey.invoke(root, new Object[] { Integer.valueOf(handles[0]) });
     175        int[] info = (int[]) regQueryInfoKey.invoke(root, Integer.valueOf(handles[0]));
    180176
    181177        int count = info[0]; // Fix: info[2] was being used here with wrong results. Suggested by davenpcj, confirmed by Petrucio
    182178        int maxlen = info[3]; // value length max
    183179        for (int index = 0; index < count; index++) {
    184             byte[] name = (byte[]) regEnumKeyEx.invoke(root,
    185                     new Object[] { Integer.valueOf(handles[0]), Integer.valueOf(index), Integer.valueOf(maxlen + 1) });
     180            byte[] name = (byte[]) regEnumKeyEx.invoke(root, Integer.valueOf(handles[0]), Integer.valueOf(index), Integer.valueOf(maxlen + 1));
    186181            results.add(new String(name, StandardCharsets.UTF_8).trim());
    187182        }
    188         regCloseKey.invoke(root, new Object[] { Integer.valueOf(handles[0]) });
     183        regCloseKey.invoke(root, Integer.valueOf(handles[0]));
    189184        return results;
    190185    }
  • trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r12218 r12279  
    153153                    Method m = entry.getMethod(fieldName);
    154154                    if (m != null) {
    155                         m.invoke(c, new Object[]{getValueForClass(m.getParameterTypes()[0], value)});
     155                        m.invoke(c, getValueForClass(m.getParameterTypes()[0], value));
    156156                    }
    157157                }
  • trunk/src/org/openstreetmap/josm/tools/template_engine/Tokenizer.java

    r9078 r12279  
    4343    public enum TokenType { CONDITION_START, VARIABLE_START, CONTEXT_SWITCH_START, END, PIPE, APOSTROPHE, TEXT, EOF }
    4444
    45     private final Set<Character> specialCharaters = new HashSet<>(Arrays.asList(new Character[] {'$', '?', '{', '}', '|', '\'', '!'}));
     45    private final Set<Character> specialCharaters = new HashSet<>(Arrays.asList('$', '?', '{', '}', '|', '\'', '!'));
    4646
    4747    private final String template;
Note: See TracChangeset for help on using the changeset viewer.