ソースを参照

Style/inspection fixes.

Change-Id: Icd1b2e56b740d27af85f82563f9eef06f33a1914
Reviewed-on: http://gerrit.dmdirc.com/3698
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
pull/1/head
Chris Smith 9年前
コミット
5321ea8492

+ 1
- 2
src/com/dmdirc/FrameContainer.java ファイルの表示

@@ -733,7 +733,6 @@ public abstract class FrameContainer {
733 733
     public boolean doNotification(final Date date, final String messageType, final Object... args) {
734 734
         final List<Object> messageArgs = new ArrayList<>();
735 735
         final List<Object> actionArgs = new ArrayList<>();
736
-        final StringBuffer buffer = new StringBuffer(messageType);
737 736
 
738 737
         actionArgs.add(this);
739 738
 
@@ -747,7 +746,7 @@ public abstract class FrameContainer {
747 746
 
748 747
         modifyNotificationArgs(actionArgs, messageArgs);
749 748
 
750
-        handleNotification(date, buffer.toString(), messageArgs.toArray());
749
+        handleNotification(date, messageType, messageArgs.toArray());
751 750
 
752 751
         return true;
753 752
     }

+ 4
- 2
src/com/dmdirc/ServerManager.java ファイルの表示

@@ -40,6 +40,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
40 40
 import java.net.URI;
41 41
 import java.net.URISyntaxException;
42 42
 import java.util.ArrayList;
43
+import java.util.Collection;
43 44
 import java.util.List;
44 45
 import java.util.Set;
45 46
 import java.util.concurrent.CopyOnWriteArraySet;
@@ -245,8 +246,9 @@ public class ServerManager implements ServerFactory {
245 246
         if (server.getState().isDisconnected()) {
246 247
             server.connect(uri, profile);
247 248
         } else {
248
-            server.join(server.getParser().extractChannels(uri)
249
-                    .toArray(new ChannelJoinRequest[0]));
249
+            Collection<? extends ChannelJoinRequest> joinRequests =
250
+                    server.getParser().extractChannels(uri);
251
+            server.join(joinRequests.toArray(new ChannelJoinRequest[joinRequests.size()]));
250 252
         }
251 253
 
252 254
         return server;

+ 1
- 2
src/com/dmdirc/actions/CoreActionComponent.java ファイルの表示

@@ -592,8 +592,7 @@ public enum CoreActionComponent implements ActionComponent {
592 592
     KEYEVENT_ALTSTATE {
593 593
         @Override
594 594
         public Object get(final Object arg) {
595
-            return Boolean
596
-                    .valueOf((((KeyStroke) arg).getModifiers() & KeyEvent.ALT_DOWN_MASK) != 0);
595
+            return (((KeyStroke) arg).getModifiers() & KeyEvent.ALT_DOWN_MASK) != 0;
597 596
         }
598 597
 
599 598
         @Override

+ 4
- 10
src/com/dmdirc/actions/wrappers/Profile.java ファイルの表示

@@ -219,16 +219,10 @@ public class Profile {
219 219
             return false;
220 220
         }
221 221
         final Profile other = (Profile) obj;
222
-        if (!Objects.equals(this.name, other.name)) {
223
-            return false;
224
-        }
225
-        if (!Objects.equals(this.realname, other.realname)) {
226
-            return false;
227
-        }
228
-        if (!Objects.equals(this.ident, other.ident)) {
229
-            return false;
230
-        }
231
-        return Objects.equals(this.nicknames, other.nicknames);
222
+        return Objects.equals(this.name, other.name) &&
223
+                Objects.equals(this.realname, other.realname) &&
224
+                Objects.equals(this.ident, other.ident) &&
225
+                Objects.equals(this.nicknames, other.nicknames);
232 226
     }
233 227
 
234 228
     @Override

+ 1
- 5
src/com/dmdirc/commandline/RemoteServer.java ファイルの表示

@@ -83,7 +83,6 @@ public class RemoteServer implements RemoteInterface {
83 83
                 registry.rebind("DMDirc", stub);
84 84
                 return;
85 85
             } catch (RemoteException ex) {
86
-                continue;
87 86
             }
88 87
         }
89 88
     }
@@ -100,13 +99,10 @@ public class RemoteServer implements RemoteInterface {
100 99
                 final Registry registry = LocateRegistry.getRegistry("localhost", port);
101 100
                 final RemoteInterface iface = (RemoteInterface) registry.lookup("DMDirc");
102 101
 
103
-                if (iface == null) {
104
-                    continue;
105
-                } else {
102
+                if (iface != null) {
106 103
                     return iface;
107 104
                 }
108 105
             } catch (RemoteException | NotBoundException ex) {
109
-                continue;
110 106
             }
111 107
         }
112 108
 

+ 1
- 4
src/com/dmdirc/commandparser/commands/PreviousCommand.java ファイルの表示

@@ -61,10 +61,7 @@ public final class PreviousCommand {
61 61
             return false;
62 62
         }
63 63
         final PreviousCommand other = (PreviousCommand) obj;
64
-        if (!Objects.equals(this.line, other.line)) {
65
-            return false;
66
-        }
67
-        return this.time == other.time;
64
+        return Objects.equals(this.line, other.line) && this.time == other.time;
68 65
     }
69 66
 
70 67
 }

+ 2
- 2
src/com/dmdirc/commandparser/commands/global/SetCommand.java ファイルの表示

@@ -177,7 +177,7 @@ public class SetCommand extends Command implements IntelligentCommand {
177 177
      */
178 178
     private void doDomainList(final FrameContainer origin, final boolean isSilent,
179 179
             final AggregateConfigProvider manager) {
180
-        final StringBuffer output = new StringBuffer(67);
180
+        final StringBuilder output = new StringBuilder(67);
181 181
 
182 182
         output.append("Valid domains (use ");
183 183
         output.append(getController().getCommandChar());
@@ -201,7 +201,7 @@ public class SetCommand extends Command implements IntelligentCommand {
201 201
      */
202 202
     private void doOptionsList(final FrameContainer origin,
203 203
             final boolean isSilent, final AggregateConfigProvider manager, final String domain) {
204
-        final StringBuffer output = new StringBuffer(24);
204
+        final StringBuilder output = new StringBuilder(24);
205 205
 
206 206
         output.append("Options in domain '");
207 207
         output.append(domain);

+ 4
- 4
src/com/dmdirc/config/ConfigFileBackedConfigProvider.java ファイルの表示

@@ -318,8 +318,8 @@ public class ConfigFileBackedConfigProvider extends BaseConfigProvider implement
318 318
 
319 319
         synchronized (this) {
320 320
             oldValue = getOption(domain, option);
321
-            log.trace("{}: setting {}.{} to {} (was: {})",
322
-                    new Object[]{getName(), domain, option, value, oldValue});
321
+            log.trace("{}: setting {}.{} to {} (was: {})", getName(), domain, option, value,
322
+                    oldValue);
323 323
 
324 324
             if (myTarget.getType() == ConfigTarget.TYPE.GLOBAL) {
325 325
                 // If we're the global config, don't set useless settings that are
@@ -455,8 +455,8 @@ public class ConfigFileBackedConfigProvider extends BaseConfigProvider implement
455 455
 
456 456
                         if (globalConfig.hasOptionString(domain, key)
457 457
                                 && globalConfig.getOption(domain, key).equals(value)) {
458
-                            log.debug("{}: found superfluous setting: {}.{} (= {})",
459
-                                    new Object[]{getName(), domain, key, value});
458
+                            log.debug("{}: found superfluous setting: {}.{} (= {})", getName(),
459
+                                    domain, key, value);
460 460
                             file.getKeyDomain(domain).remove(key);
461 461
                         }
462 462
                     }

+ 3
- 5
src/com/dmdirc/config/ConfigManager.java ファイルの表示

@@ -277,7 +277,7 @@ class ConfigManager extends BaseConfigProvider implements ConfigChangeListener,
277 277
                 && identityTargetMatches(identity.getTarget().getData(), comp);
278 278
 
279 279
         log.trace("Checking if identity {} applies. Comparison: {}, target: {}, result: {}",
280
-                new Object[]{identity, comp, identity.getTarget().getData(), result});
280
+                identity, comp, identity.getTarget().getData(), result);
281 281
 
282 282
         return result;
283 283
     }
@@ -359,10 +359,8 @@ class ConfigManager extends BaseConfigProvider implements ConfigChangeListener,
359 359
      */
360 360
     void migrate(final String protocol, final String ircd,
361 361
             final String network, final String server, final String channel) {
362
-        log.debug("Migrating from {{}, {}, {}, {}, {}} to {{}, {}, {}, {}, {}}",
363
-                new Object[]{
364
-                    this.protocol, this.ircd, this.network, this.server, this.channel,
365
-                    protocol, ircd, network, server, channel,});
362
+        log.debug("Migrating from {{}, {}, {}, {}, {}} to {{}, {}, {}, {}, {}}", this.protocol, this.ircd,
363
+                this.network, this.server, this.channel, protocol, ircd, network, server, channel);
366 364
 
367 365
         this.protocol = protocol;
368 366
         this.ircd = ircd;

+ 1
- 5
src/com/dmdirc/logger/ErrorLevel.java ファイルの表示

@@ -73,11 +73,7 @@ public enum ErrorLevel {
73 73
      * @return true iff the error is more important
74 74
      */
75 75
     public boolean moreImportant(final ErrorLevel level) {
76
-        if (level == null) {
77
-            return false;
78
-        }
79
-
80
-        return ordinal() > level.ordinal();
76
+        return level != null && ordinal() > level.ordinal();
81 77
     }
82 78
 
83 79
 }

+ 3
- 12
src/com/dmdirc/logger/ProgramError.java ファイルの表示

@@ -375,19 +375,10 @@ public final class ProgramError implements Serializable {
375 375
         }
376 376
 
377 377
         final ProgramError other = (ProgramError) obj;
378
-        if (this.level != other.level) {
379
-            return false;
380
-        }
381
-
382
-        if (!this.message.equals(other.message)) {
383
-            return false;
384
-        }
385
-
386
-        if (!Objects.equals(this.exception, other.exception)) {
387
-            return false;
388
-        }
378
+        return this.level == other.level && this.message.equals(other.message) &&
379
+                Objects.equals(this.exception, other.exception) &&
380
+                Objects.equals(this.details, other.details);
389 381
 
390
-        return Objects.equals(this.details, other.details);
391 382
     }
392 383
 
393 384
     @Override

+ 1
- 1
src/com/dmdirc/tls/CertificateAction.java ファイルの表示

@@ -34,6 +34,6 @@ public enum CertificateAction {
34 34
     /** Ignores the problem but does not store the exception. */
35 35
     IGNORE_TEMPORARILY,
36 36
     /** Adds a permanent exception for the certificate. */
37
-    IGNORE_PERMANENTLY;
37
+    IGNORE_PERMANENTLY
38 38
 
39 39
 }

+ 1
- 1
src/com/dmdirc/tls/CertificateManager.java ファイルの表示

@@ -235,7 +235,7 @@ public class CertificateManager implements X509TrustManager {
235 235
         try {
236 236
             if (certificate.getSubjectAlternativeNames() != null) {
237 237
                 for (List<?> entry : certificate.getSubjectAlternativeNames()) {
238
-                    final int type = ((Integer) entry.get(0)).intValue();
238
+                    final int type = (Integer) entry.get(0);
239 239
 
240 240
                     // DNS or IP
241 241
                     if ((type == 2 || type == 7) && isMatchingServerName((String) entry.get(1))) {

+ 1
- 1
src/com/dmdirc/ui/WindowManager.java ファイルの表示

@@ -300,7 +300,7 @@ public class WindowManager {
300 300
             final String name) {
301 301
         for (FrameContainer window : windows) {
302 302
             if (window instanceof CustomWindow
303
-                    && ((CustomWindow) window).getName().equals(name)) {
303
+                    && window.getName().equals(name)) {
304 304
                 return window;
305 305
             }
306 306
         }

+ 1
- 1
src/com/dmdirc/ui/core/newserver/CoreNewServerDialogModel.java ファイルの表示

@@ -129,7 +129,7 @@ public class CoreNewServerDialogModel implements NewServerDialogModel, ConfigPro
129 129
 
130 130
     @Override
131 131
     public Validator<List<ConfigProvider>> getProfileListValidator() {
132
-        return new ListNotEmptyValidator<ConfigProvider>();
132
+        return new ListNotEmptyValidator<>();
133 133
     }
134 134
 
135 135
     @Override

+ 2
- 2
src/com/dmdirc/ui/core/profiles/CoreProfilesDialogModel.java ファイルの表示

@@ -115,7 +115,7 @@ public class CoreProfilesDialogModel implements ProfilesDialogModel {
115 115
 
116 116
     @Override
117 117
     public Validator<List<Profile>> getProfileListValidator() {
118
-        return new ListNotEmptyValidator<Profile>();
118
+        return new ListNotEmptyValidator<>();
119 119
     }
120 120
 
121 121
     @Override
@@ -353,7 +353,7 @@ public class CoreProfilesDialogModel implements ProfilesDialogModel {
353 353
 
354 354
     @Override
355 355
     public Validator<List<String>> getSelectedProfileNicknamesValidator() {
356
-        return new ListNotEmptyValidator<String>();
356
+        return new ListNotEmptyValidator<>();
357 357
     }
358 358
 
359 359
     @Override

+ 1
- 1
src/com/dmdirc/ui/input/TabCompleterResult.java ファイルの表示

@@ -135,7 +135,7 @@ public class TabCompleterResult {
135 135
     /** {@inheritDoc} */
136 136
     @Override
137 137
     public String toString() {
138
-        final StringBuffer buff = new StringBuffer();
138
+        final StringBuilder buff = new StringBuilder();
139 139
 
140 140
         for (String entry : results) {
141 141
             if (buff.length() > 0) {

+ 1
- 1
src/com/dmdirc/ui/input/TabCompletionType.java ファイルの表示

@@ -38,6 +38,6 @@ public enum TabCompletionType {
38 38
     /** Additional results. */
39 39
     ADDITIONAL,
40 40
     /** Anything else. */
41
-    OTHER;
41
+    OTHER
42 42
 
43 43
 }

+ 1
- 1
src/com/dmdirc/ui/messages/Formatter.java ファイルの表示

@@ -151,7 +151,7 @@ public final class Formatter {
151 151
                     // Date
152 152
                     if (args[i] instanceof String) {
153 153
                         // Assume it's a timestamp(?)
154
-                        res[i] = Long.valueOf(1000 * Long.valueOf((String) args[i]));
154
+                        res[i] = 1000 * Long.valueOf((String) args[i]);
155 155
                     } else {
156 156
                         res[i] = args[i];
157 157
                     }

+ 1
- 4
src/com/dmdirc/ui/messages/Line.java ファイルの表示

@@ -146,10 +146,7 @@ public class Line {
146 146
     /** {@inheritDoc} */
147 147
     @Override
148 148
     public boolean equals(final Object obj) {
149
-        if (obj instanceof Line) {
150
-            return Arrays.equals(((Line) obj).getLineParts(), getLineParts());
151
-        }
152
-        return false;
149
+        return obj instanceof Line && Arrays.equals(((Line) obj).getLineParts(), getLineParts());
153 150
     }
154 151
 
155 152
     /** {@inheritDoc} */

+ 7
- 8
src/com/dmdirc/ui/messages/Styliser.java ファイルの表示

@@ -179,8 +179,8 @@ public class Styliser implements ConfigChangeListener {
179 179
     public void addStyledString(final StyledDocument styledDoc,
180 180
             final String[] strings, final SimpleAttributeSet attribs) {
181 181
         resetAttributes(attribs);
182
-        for (int i = 0; i < strings.length; i++) {
183
-            final char[] chars = strings[i].toCharArray();
182
+        for (String string : strings) {
183
+            final char[] chars = string.toCharArray();
184 184
 
185 185
             for (int j = 0; j < chars.length; j++) {
186 186
                 if (chars[j] == 65533) {
@@ -189,12 +189,11 @@ public class Styliser implements ConfigChangeListener {
189 189
             }
190 190
 
191 191
             try {
192
-                final int ooffset = styledDoc.getLength();
193
-                int offset = ooffset;
192
+                int offset = styledDoc.getLength();
194 193
                 int position = 0;
195 194
 
196
-                final String target = doSmilies(doLinks(new String(chars)
197
-                        .replaceAll(INTERNAL_CHARS, "")));
195
+                final String target =
196
+                        doSmilies(doLinks(new String(chars).replaceAll(INTERNAL_CHARS, "")));
198 197
 
199 198
                 attribs.addAttribute("DefaultFontFamily", UIManager.getFont("TextPane.font"));
200 199
 
@@ -207,8 +206,8 @@ public class Styliser implements ConfigChangeListener {
207 206
                     offset += next.length();
208 207
 
209 208
                     if (position < target.length()) {
210
-                        position += readControlChars(target.substring(position),
211
-                                attribs, position == 0);
209
+                        position += readControlChars(target.substring(position), attribs,
210
+                                position == 0);
212 211
                     }
213 212
                 }
214 213
             } catch (BadLocationException ex) {

+ 1
- 1
src/com/dmdirc/updater/UpdateChannel.java ファイルの表示

@@ -34,6 +34,6 @@ public enum UpdateChannel {
34 34
     /** Nightly update chanel. */
35 35
     NIGHTLY,
36 36
     /** Not an official release (e.g. GIT). */
37
-    NONE;
37
+    NONE
38 38
 
39 39
 }

読み込み中…
キャンセル
保存