소스 검색

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
     public static final String VERSION = "SVN";
51
     public static final String VERSION = "SVN";
52
     
52
     
53
     /** The SVN revision that this build was made from. */
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
     /** Stores the update channel that this version came from, if any. */
56
     /** Stores the update channel that this version came from, if any. */
57
     public static final UpdateChannel UPDATE_CHANNEL = UpdateChannel.NONE;
57
     public static final UpdateChannel UPDATE_CHANNEL = UpdateChannel.NONE;

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

315
 
315
 
316
         if (newFormat != null) {
316
         if (newFormat != null) {
317
             newConfig.addDomain(DOMAIN_FORMAT, new ArrayList<String>());
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
         int i = 0;
321
         int i = 0;

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

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

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

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

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

79
         if (information.containsKey("playlist_current")) {
79
         if (information.containsKey("playlist_current")) {
80
             try {
80
             try {
81
                 final int item = Integer.parseInt(information.get("playlist_current"));
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
                 result = bits[bits.length-1];
83
                 result = bits[bits.length-1];
84
                 bits = result.split("-");
84
                 bits = result.split("-");
85
                 if (bits.length > 1) {
85
                 if (bits.length > 1) {

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

60
         "58ADB3", "9E54B3", "B39875", "3176B3",
60
         "58ADB3", "9E54B3", "B39875", "3176B3",
61
     };
61
     };
62
     
62
     
63
-    /** The nick colour panel we use for config. */
64
-    private NickColourPanel nickpanel;
65
-    
66
     /** Creates a new instance of NickColourPlugin. */
63
     /** Creates a new instance of NickColourPlugin. */
67
     public NickColourPlugin() {
64
     public NickColourPlugin() {
68
         super();
65
         super();
137
      * by config settings.
134
      * by config settings.
138
      *
135
      *
139
      * @param map The map to use
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
     @SuppressWarnings("unchecked")
140
     @SuppressWarnings("unchecked")
143
     private void putColour(final Map map, final Color textColour, final Color nickColour) {
141
     private void putColour(final Map map, final Color textColour, final Color nickColour) {
222
     @Override
220
     @Override
223
     public void onLoad() {
221
     public void onLoad() {
224
         if (IdentityManager.getGlobalConfig().hasOption(DOMAIN, "randomcolours")) {
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
         ActionManager.addListener(this, CoreActionType.CHANNEL_GOTNAMES,
226
         ActionManager.addListener(this, CoreActionType.CHANNEL_GOTNAMES,

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

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

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

202
         
202
         
203
         properties.clear();
203
         properties.clear();
204
         properties.load(input);
204
         properties.load(input);
205
+        input.close();
205
         
206
         
206
         for (Entry<Object, Object> entry : properties.entrySet()) {
207
         for (Entry<Object, Object> entry : properties.entrySet()) {
207
             if (oldProps.containsKey(entry.getKey())) {
208
             if (oldProps.containsKey(entry.getKey())) {

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

34
      * 
34
      * 
35
      * @param category The category that was selected
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
      * Called when a category has been deselected.
40
      * Called when a category has been deselected.
41
      * 
41
      * 
42
      * @param category The category that was deselected
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
      */
230
      */
231
     public void fireCategorySelected() {
231
     public void fireCategorySelected() {
232
         for (CategoryChangeListener listener : listeners.get(CategoryChangeListener.class)) {
232
         for (CategoryChangeListener listener : listeners.get(CategoryChangeListener.class)) {
233
-            listener.CategorySelected(this);
233
+            listener.categorySelected(this);
234
         }
234
         }
235
     }
235
     }
236
     
236
     
239
      */
239
      */
240
     public void fireCategoryDeselected() {
240
     public void fireCategoryDeselected() {
241
         for (CategoryChangeListener listener : listeners.get(CategoryChangeListener.class)) {
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
 		}
166
 		}
167
 		params.add("/t");
167
 		params.add("/t");
168
 		params.add(type);
168
 		params.add(type);
169
-		if (data != "") {
169
+		if (!data.equals("")) {
170
 			params.add("/d");
170
 			params.add("/d");
171
 			params.add(data);
171
 			params.add(data);
172
 		}
172
 		}

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

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

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

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

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

40
 import java.awt.event.MouseListener;
40
 import java.awt.event.MouseListener;
41
 
41
 
42
 import java.util.ArrayList;
42
 import java.util.ArrayList;
43
+import java.util.Arrays;
43
 import java.util.List;
44
 import java.util.List;
44
 import javax.swing.AbstractAction;
45
 import javax.swing.AbstractAction;
45
 import javax.swing.BorderFactory;
46
 import javax.swing.BorderFactory;
271
     /** {@inheritDoc} */
272
     /** {@inheritDoc} */
272
     @Override
273
     @Override
273
     public String toString() {
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
         minutesSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 60, 1));
91
         minutesSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 60, 1));
92
         secondsSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 60, 1));
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
         duration = (duration % 86400);
95
         duration = (duration % 86400);
96
-        hoursSpinner.setValue(new Long(duration / 3600).intValue());
96
+        hoursSpinner.setValue((int) duration / 3600);
97
         duration = (duration % 3600);
97
         duration = (duration % 3600);
98
-        minutesSpinner.setValue(new Long(duration / 60).intValue());
98
+        minutesSpinner.setValue((int) duration / 60);
99
         duration = (duration % 60);
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
     public Profile() {
48
     public Profile() {
49
         this("");
49
         this("");
50
     }
50
     }
51
-    
51
+
52
     /**
52
     /**
53
      * Creates a new profile.
53
      * Creates a new profile.
54
      *
54
      *
316
             profile.setOption(profileString, "altnicks", altNicknames);
316
             profile.setOption(profileString, "altnicks", altNicknames);
317
         }
317
         }
318
     }
318
     }
319
-    
319
+
320
     /** Deletes the profile. */
320
     /** Deletes the profile. */
321
     public void delete() {
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
     /** {@inheritDoc} */
338
     /** {@inheritDoc} */
346
         }
346
         }
347
 
347
 
348
         final Profile other = (Profile) obj;
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
             return false;
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
             return false;
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
             return false;
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
             return false;
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
             return false;
370
             return false;
371
         }
371
         }
372
 
372
 
378
     public int hashCode() {
378
     public int hashCode() {
379
         int hash = 5;
379
         int hash = 5;
380
         hash = 79 * hash + (this.name != null ? this.name.hashCode() : 0);
380
         hash = 79 * hash + (this.name != null ? this.name.hashCode() : 0);
381
-        hash =  79 * hash +
381
+        hash = 79 * hash +
382
                 (this.nickname != null ? this.nickname.hashCode() : 0);
382
                 (this.nickname != null ? this.nickname.hashCode() : 0);
383
-        hash =  79 * hash +
383
+        hash = 79 * hash +
384
                 (this.realname != null ? this.realname.hashCode() : 0);
384
                 (this.realname != null ? this.realname.hashCode() : 0);
385
         hash = 79 * hash + (this.ident != null ? this.ident.hashCode() : 0);
385
         hash = 79 * hash + (this.ident != null ? this.ident.hashCode() : 0);
386
-        hash =  79 * hash +
386
+        hash = 79 * hash +
387
                 (this.altNicknames != null ? this.altNicknames.hashCode() : 0);
387
                 (this.altNicknames != null ? this.altNicknames.hashCode() : 0);
388
 
388
 
389
         return hash;
389
         return hash;

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

33
 
33
 
34
 import java.awt.event.ActionEvent;
34
 import java.awt.event.ActionEvent;
35
 import java.awt.event.ActionListener;
35
 import java.awt.event.ActionListener;
36
-import java.util.List;
37
 
36
 
38
 import javax.swing.JButton;
37
 import javax.swing.JButton;
39
 import javax.swing.JCheckBox;
38
 import javax.swing.JCheckBox;
140
     
139
     
141
     /** Populates the ignore list. */
140
     /** Populates the ignore list. */
142
     private void populateList() {        
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
         if (list.getSelectedIndex() == -1) {
142
         if (list.getSelectedIndex() == -1) {
152
             delButton.setEnabled(false);
143
             delButton.setEnabled(false);
153
         }
144
         }

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

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

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

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

Loading…
취소
저장