소스 검색

Fixed some FindBugs errors

 - Removed some superfluous method invocations
 - Fixed an infinite recursion but in ActionManager
 - Swapped some string concatenation for StringBuilders in ConditionTree
 - Fixed the regex in VLC media source when running under windows
 - Removed some unused/needed variables/code
 - Renamed CategoryChangeListener methods to follow naming conventions
 - Fixed useless string equals checks in the windows installer
 - Fixed some genericity errors in ErrorManager and ButtonBar
 - Fixed some crap primitive coercion in DurationEditor
 - toString in InviteLabel is now useful
 - Fixed some potential NPEs in the equals method in Profile
 - Fixed some casting errors in JWrappingLabel
 - Changed the scope of some fields in CipherUtils

git-svn-id: http://svn.dmdirc.com/trunk@3629 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Gregory Holmes 16 년 전
부모
커밋
f303578199

+ 1
- 1
src/com/dmdirc/Main.java 파일 보기

@@ -51,7 +51,7 @@ public final class Main {
51 51
     public static final String VERSION = "SVN";
52 52
     
53 53
     /** The SVN revision that this build was made from. */
54
-    public static final int SVN_REVISION = 3601;
54
+    public static final int SVN_REVISION = 3628; // 3601;
55 55
     
56 56
     /** Stores the update channel that this version came from, if any. */
57 57
     public static final UpdateChannel UPDATE_CHANNEL = UpdateChannel.NONE;

+ 1
- 1
src/com/dmdirc/actions/Action.java 파일 보기

@@ -315,7 +315,7 @@ public class Action extends ActionModel implements Serializable {
315 315
 
316 316
         if (newFormat != null) {
317 317
             newConfig.addDomain(DOMAIN_FORMAT, new ArrayList<String>());
318
-            newConfig.getFlatDomain(DOMAIN_FORMAT).add(newFormat.toString());
318
+            newConfig.getFlatDomain(DOMAIN_FORMAT).add(newFormat);
319 319
         }
320 320
 
321 321
         int i = 0;

+ 1
- 1
src/com/dmdirc/actions/ActionManager.java 파일 보기

@@ -395,7 +395,7 @@ public final class ActionManager {
395 395
      */
396 396
     public static void reregisterAction(final Action action) {
397 397
         unregisterAction(action);
398
-        reregisterAction(action);
398
+        registerAction(action);
399 399
     }
400 400
 
401 401
     /**

+ 3
- 3
src/com/dmdirc/actions/ConditionTree.java 파일 보기

@@ -189,14 +189,14 @@ public class ConditionTree {
189 189
             final char m = string.charAt(i);
190 190
 
191 191
             if (isInt(m)) {
192
-                String temp = String.valueOf(m);
192
+                StringBuilder temp = new StringBuilder(String.valueOf(m));
193 193
 
194 194
                 while (i + 1 < string.length() && isInt(string.charAt(i + 1))) {
195
-                    temp = temp + string.charAt(i + 1);
195
+                    temp.append(string.charAt(i + 1));
196 196
                     i++;
197 197
                 }
198 198
 
199
-                stack.add(new ConditionTree(Integer.parseInt(temp)));
199
+                stack.add(new ConditionTree(Integer.parseInt(temp.toString())));
200 200
             } else if (m != ' ' && m != '\t' && m != '\n' && m != '\r') {
201 201
                 stack.add(m);
202 202
             }

+ 1
- 1
src/com/dmdirc/addons/mediasource_vlc/VlcMediaSourcePlugin.java 파일 보기

@@ -79,7 +79,7 @@ public class VlcMediaSourcePlugin extends Plugin implements MediaSource {
79 79
         if (information.containsKey("playlist_current")) {
80 80
             try {
81 81
                 final int item = Integer.parseInt(information.get("playlist_current"));
82
-                String[] bits = information.get("playlist_item_" + item).split(File.separator);
82
+                String[] bits = information.get("playlist_item_" + item).split((File.separatorChar=='\\' ? "\\\\" : File.separator));
83 83
                 result = bits[bits.length-1];
84 84
                 bits = result.split("-");
85 85
                 if (bits.length > 1) {

+ 3
- 5
src/com/dmdirc/addons/nickcolours/NickColourPlugin.java 파일 보기

@@ -60,9 +60,6 @@ public final class NickColourPlugin extends Plugin implements ActionListener {
60 60
         "58ADB3", "9E54B3", "B39875", "3176B3",
61 61
     };
62 62
     
63
-    /** The nick colour panel we use for config. */
64
-    private NickColourPanel nickpanel;
65
-    
66 63
     /** Creates a new instance of NickColourPlugin. */
67 64
     public NickColourPlugin() {
68 65
         super();
@@ -137,7 +134,8 @@ public final class NickColourPlugin extends Plugin implements ActionListener {
137 134
      * by config settings.
138 135
      *
139 136
      * @param map The map to use
140
-     * @param colour The colour to be inserted
137
+     * @param textColour Text colour to be inserted
138
+     * @param nickColour Nick colour to be inserted
141 139
      */
142 140
     @SuppressWarnings("unchecked")
143 141
     private void putColour(final Map map, final Color textColour, final Color nickColour) {
@@ -222,7 +220,7 @@ public final class NickColourPlugin extends Plugin implements ActionListener {
222 220
     @Override
223 221
     public void onLoad() {
224 222
         if (IdentityManager.getGlobalConfig().hasOption(DOMAIN, "randomcolours")) {
225
-            randColours =(String[]) IdentityManager.getGlobalConfig().getOptionList(DOMAIN, "randomcolours").toArray();
223
+            randColours = IdentityManager.getGlobalConfig().getOptionList(DOMAIN, "randomcolours").toArray(new String[0]);
226 224
         }
227 225
         
228 226
         ActionManager.addListener(this, CoreActionType.CHANNEL_GOTNAMES,

+ 2
- 2
src/com/dmdirc/addons/osdplugin/OsdPlugin.java 파일 보기

@@ -122,7 +122,7 @@ public final class OsdPlugin extends Plugin implements CategoryChangeListener,
122 122
 
123 123
     /** {@inheritDoc} */
124 124
     @Override
125
-    public void CategorySelected(final PreferencesCategory category) {
125
+    public void categorySelected(final PreferencesCategory category) {
126 126
         osdWindow = new OsdWindow("Please drag this OSD to position", true, x, y);
127 127
         osdWindow.setBackgroundColour(backgroundSetting.getValue());
128 128
         osdWindow.setForegroundColour(foregroundSetting.getValue());
@@ -131,7 +131,7 @@ public final class OsdPlugin extends Plugin implements CategoryChangeListener,
131 131
 
132 132
     /** {@inheritDoc} */
133 133
     @Override
134
-    public void CategoryDeselected(final PreferencesCategory category) {
134
+    public void categoryDeselected(final PreferencesCategory category) {
135 135
         x = osdWindow.getLocationOnScreen().x;
136 136
         y = osdWindow.getLocationOnScreen().y;
137 137
         

+ 1
- 0
src/com/dmdirc/config/Identity.java 파일 보기

@@ -202,6 +202,7 @@ public class Identity extends ConfigSource implements Serializable,
202 202
         
203 203
         properties.clear();
204 204
         properties.load(input);
205
+        input.close();
205 206
         
206 207
         for (Entry<Object, Object> entry : properties.entrySet()) {
207 208
             if (oldProps.containsKey(entry.getKey())) {

+ 2
- 2
src/com/dmdirc/config/prefs/CategoryChangeListener.java 파일 보기

@@ -34,12 +34,12 @@ public interface CategoryChangeListener {
34 34
      * 
35 35
      * @param category The category that was selected
36 36
      */
37
-    void CategorySelected(final PreferencesCategory category);
37
+    void categorySelected(final PreferencesCategory category);
38 38
     
39 39
     /**
40 40
      * Called when a category has been deselected.
41 41
      * 
42 42
      * @param category The category that was deselected
43 43
      */
44
-    void CategoryDeselected(final PreferencesCategory category);
44
+    void categoryDeselected(final PreferencesCategory category);
45 45
 }

+ 2
- 2
src/com/dmdirc/config/prefs/PreferencesCategory.java 파일 보기

@@ -230,7 +230,7 @@ public class PreferencesCategory {
230 230
      */
231 231
     public void fireCategorySelected() {
232 232
         for (CategoryChangeListener listener : listeners.get(CategoryChangeListener.class)) {
233
-            listener.CategorySelected(this);
233
+            listener.categorySelected(this);
234 234
         }
235 235
     }
236 236
     
@@ -239,7 +239,7 @@ public class PreferencesCategory {
239 239
      */
240 240
     public void fireCategoryDeselected() {
241 241
         for (CategoryChangeListener listener : listeners.get(CategoryChangeListener.class)) {
242
-            listener.CategoryDeselected(this);
242
+            listener.categoryDeselected(this);
243 243
         }
244 244
     }    
245 245
 

+ 1
- 1
src/com/dmdirc/installer/WindowsInstaller.java 파일 보기

@@ -166,7 +166,7 @@ public class WindowsInstaller extends Installer {
166 166
 		}
167 167
 		params.add("/t");
168 168
 		params.add(type);
169
-		if (data != "") {
169
+		if (!data.equals("")) {
170 170
 			params.add("/d");
171 171
 			params.add(data);
172 172
 		}

+ 1
- 1
src/com/dmdirc/logger/ErrorManager.java 파일 보기

@@ -146,7 +146,7 @@ public final class ErrorManager implements Serializable, Runnable {
146 146
      *
147 147
      * @return ProgramError with specified ID
148 148
      */
149
-    public ProgramError getError(final int id) {
149
+    public ProgramError getError(final long id) {
150 150
         return errors.get(id);
151 151
     }
152 152
     

+ 2
- 2
src/com/dmdirc/ui/swing/JWrappingLabel.java 파일 보기

@@ -273,9 +273,9 @@ public class JWrappingLabel extends JComponent {
273 273
 					int x;
274 274
 					int alignment = getHorizontalAlignment();
275 275
 					if (alignment == SwingConstants.CENTER) {
276
-						x = (int)((getWidth()/2) - (bounds.getWidth()/2));
276
+						x = (getWidth() / 2) - ((int) bounds.getWidth() / 2);
277 277
 					} else if (alignment == SwingConstants.RIGHT) {
278
-						x = (int)(getWidth() - bounds.getWidth());
278
+						x = getWidth() - (int) bounds.getWidth();
279 279
 					} else {
280 280
 						x = 0;
281 281
 					}

+ 2
- 1
src/com/dmdirc/ui/swing/components/InviteLabel.java 파일 보기

@@ -40,6 +40,7 @@ import java.awt.event.MouseEvent;
40 40
 import java.awt.event.MouseListener;
41 41
 
42 42
 import java.util.ArrayList;
43
+import java.util.Arrays;
43 44
 import java.util.List;
44 45
 import javax.swing.AbstractAction;
45 46
 import javax.swing.BorderFactory;
@@ -271,6 +272,6 @@ class InviteAction extends AbstractAction {
271 272
     /** {@inheritDoc} */
272 273
     @Override
273 274
     public String toString() {
274
-        return invite.getChannel() + "(" + invite.getSource() + ")";
275
+        return invite.getChannel() + "(" + Arrays.toString(invite.getSource()) + ")";
275 276
     }
276 277
 }

+ 4
- 4
src/com/dmdirc/ui/swing/components/durationeditor/DurationEditor.java 파일 보기

@@ -91,13 +91,13 @@ public class DurationEditor extends StandardDialog implements ActionListener {
91 91
         minutesSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 60, 1));
92 92
         secondsSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 60, 1));
93 93
         
94
-        daysSpinner.setValue(new Long(duration / 86400).intValue());
94
+        daysSpinner.setValue((int) duration / 86400);
95 95
         duration = (duration % 86400);
96
-        hoursSpinner.setValue(new Long(duration / 3600).intValue());
96
+        hoursSpinner.setValue((int) duration / 3600);
97 97
         duration = (duration % 3600);
98
-        minutesSpinner.setValue(new Long(duration / 60).intValue());
98
+        minutesSpinner.setValue((int) duration / 60);
99 99
         duration = (duration % 60);
100
-        secondsSpinner.setValue(new Long(duration).intValue());
100
+        secondsSpinner.setValue((int) duration);
101 101
     }
102 102
 
103 103
     /**

+ 29
- 29
src/com/dmdirc/ui/swing/dialogs/profiles/Profile.java 파일 보기

@@ -48,7 +48,7 @@ public class Profile {
48 48
     public Profile() {
49 49
         this("");
50 50
     }
51
-    
51
+
52 52
     /**
53 53
      * Creates a new profile.
54 54
      *
@@ -316,23 +316,23 @@ public class Profile {
316 316
             profile.setOption(profileString, "altnicks", altNicknames);
317 317
         }
318 318
     }
319
-    
319
+
320 320
     /** Deletes the profile. */
321 321
     public void delete() {
322
-            final List<Identity> identities = IdentityManager.getProfiles();
323
-            Identity profile = null;
322
+        final List<Identity> identities = IdentityManager.getProfiles();
323
+        Identity profile = null;
324 324
 
325
-            for (Identity identity : identities) {
326
-                if (identity.getName().equals(name)) {
327
-                    profile = identity;
328
-                    break;
329
-                }
325
+        for (Identity identity : identities) {
326
+            if (identity.getName().equals(name)) {
327
+                profile = identity;
328
+                break;
330 329
             }
330
+        }
331 331
 
332
-            if (profile == null) {
333
-                return;
334
-            }
335
-            profile.delete();
332
+        if (profile == null) {
333
+            return;
334
+        }
335
+        profile.delete();
336 336
     }
337 337
 
338 338
     /** {@inheritDoc} */
@@ -346,27 +346,27 @@ public class Profile {
346 346
         }
347 347
 
348 348
         final Profile other = (Profile) obj;
349
-        
350
-        if (!this.name.equals(other.name) &&
351
-                (this.name == null || !this.name.equals(other.name))) {
349
+
350
+        if (!this.name.equals(other.name)) {
351
+            return false;
352
+        }
353
+        if (!this.nickname.equals(other.nickname)) {
354
+            return false;
355
+        }
356
+        if (!this.realname.equals(other.realname)) {
352 357
             return false;
353 358
         }
354
-        if (!this.nickname.equals(other.nickname) &&
355
-                (this.nickname == null || !this.nickname.equals(other.nickname))) {
359
+        if (this.ident == null && other.ident != null) {
356 360
             return false;
357 361
         }
358
-        if (!this.realname.equals(other.realname) &&
359
-                (this.realname == null || !this.realname.equals(other.realname))) {
362
+        if (this.ident != null && !this.ident.equals(other.ident)) {
360 363
             return false;
361 364
         }
362
-        if ((this.ident == null && other.ident != null) && 
363
-                !this.ident.equals(other.ident) &&
364
-                (this.ident == null || !this.ident.equals(other.ident))) {
365
+        if (this.altNicknames != other.altNicknames) {
365 366
             return false;
366 367
         }
367
-        if (this.altNicknames != other.altNicknames &&
368
-                (this.altNicknames == null ||
369
-                !this.altNicknames.equals(other.altNicknames))) {
368
+        if (this.altNicknames == null ||
369
+                !this.altNicknames.equals(other.altNicknames)) {
370 370
             return false;
371 371
         }
372 372
 
@@ -378,12 +378,12 @@ public class Profile {
378 378
     public int hashCode() {
379 379
         int hash = 5;
380 380
         hash = 79 * hash + (this.name != null ? this.name.hashCode() : 0);
381
-        hash =  79 * hash +
381
+        hash = 79 * hash +
382 382
                 (this.nickname != null ? this.nickname.hashCode() : 0);
383
-        hash =  79 * hash +
383
+        hash = 79 * hash +
384 384
                 (this.realname != null ? this.realname.hashCode() : 0);
385 385
         hash = 79 * hash + (this.ident != null ? this.ident.hashCode() : 0);
386
-        hash =  79 * hash +
386
+        hash = 79 * hash +
387 387
                 (this.altNicknames != null ? this.altNicknames.hashCode() : 0);
388 388
 
389 389
         return hash;

+ 0
- 9
src/com/dmdirc/ui/swing/dialogs/serversetting/IgnoreListPanel.java 파일 보기

@@ -33,7 +33,6 @@ import com.dmdirc.ui.swing.components.StandardInputDialog;
33 33
 
34 34
 import java.awt.event.ActionEvent;
35 35
 import java.awt.event.ActionListener;
36
-import java.util.List;
37 36
 
38 37
 import javax.swing.JButton;
39 38
 import javax.swing.JCheckBox;
@@ -140,14 +139,6 @@ public final class IgnoreListPanel extends JPanel implements ActionListener,
140 139
     
141 140
     /** Populates the ignore list. */
142 141
     private void populateList() {        
143
-        List<String> results;
144
-        
145
-        if (viewToggle.isSelected()) {
146
-            results = cachedIgnoreList.getRegexList();
147
-        } else {
148
-            results = cachedIgnoreList.getSimpleList();
149
-        }
150
-        
151 142
         if (list.getSelectedIndex() == -1) {
152 143
             delButton.setEnabled(false);
153 144
         }

+ 1
- 1
src/com/dmdirc/ui/swing/framemanager/buttonbar/ButtonBar.java 파일 보기

@@ -346,7 +346,7 @@ public final class ButtonBar implements FrameManager, ActionListener,
346 346
     /** {@inheritDoc} */
347 347
     @Override
348 348
     public void notificationSet(final Window window, final Color colour) {
349
-        if (buttons.containsKey(window)) {
349
+        if (buttons.containsKey(window.getContainer())) {
350 350
             buttons.get(window.getContainer()).setForeground(colour);
351 351
         }
352 352
     }

+ 7
- 8
src/com/dmdirc/util/CipherUtils.java 파일 보기

@@ -38,7 +38,6 @@ import java.security.spec.AlgorithmParameterSpec;
38 38
 import java.security.spec.InvalidKeySpecException;
39 39
 import java.security.spec.KeySpec;
40 40
 
41
-import java.util.logging.Level;
42 41
 import javax.crypto.BadPaddingException;
43 42
 import javax.crypto.Cipher;
44 43
 import javax.crypto.IllegalBlockSizeException;
@@ -55,28 +54,28 @@ import net.miginfocom.Base64;
55 54
 public class CipherUtils {
56 55
     
57 56
     /** Singleton instance. */
58
-    protected static CipherUtils me;
57
+    private static CipherUtils me;
59 58
     
60 59
     /** Encryption cipher. */
61
-    protected Cipher ecipher;
60
+    private Cipher ecipher;
62 61
     
63 62
     /** Decryption cipher. */
64
-    protected Cipher dcipher;
63
+    private Cipher dcipher;
65 64
     
66 65
     /** Salt. */
67
-    protected final byte[] SALT = {
66
+    private final byte[] SALT = {
68 67
         (byte) 0xA9, (byte) 0x9B, (byte) 0xC8, (byte) 0x32,
69 68
         (byte) 0x56, (byte) 0x35, (byte) 0xE3, (byte) 0x03,
70 69
     };
71 70
     
72 71
     /** Iteration count. */
73
-    protected final int ITERATIONS = 19;
72
+    private static final int ITERATIONS = 19;
74 73
     
75 74
     /** Number of auth attemps before failing the attempt. */
76
-    protected final int AUTH_TRIES = 4;
75
+    private static final int AUTH_TRIES = 4;
77 76
     
78 77
     /** User password. */
79
-    protected String password;
78
+    private String password;
80 79
     
81 80
     /**
82 81
      * Prevents creation of a new instance of Encipher.

Loading…
취소
저장