Browse Source

Minor tidying and inspection fiddling.

Change-Id: Id95ee234e909ddb46eb04e24f143fe18658d4194
Reviewed-on: http://gerrit.dmdirc.com/3823
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
pull/1/head
Chris Smith 9 years ago
parent
commit
0cc678300e

+ 8
- 3
.idea/inspectionProfiles/Project_Default.xml View File

@@ -3,7 +3,13 @@
3 3
     <option name="myName" value="Project Default" />
4 4
     <option name="myLocal" value="false" />
5 5
     <inspection_tool class="AbstractMethodCallInConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
6
-    <inspection_tool class="AccessToStaticFieldLockedOnInstance" enabled="true" level="WARNING" enabled_by_default="true" />
6
+    <inspection_tool class="AccessToStaticFieldLockedOnInstance" enabled="true" level="WARNING" enabled_by_default="true">
7
+      <option name="ignoredClasses">
8
+        <set>
9
+          <option value="org.slf4j.Logger" />
10
+        </set>
11
+      </option>
12
+    </inspection_tool>
7 13
     <inspection_tool class="AnonymousClassComplexity" enabled="true" level="WARNING" enabled_by_default="true">
8 14
       <option name="m_limit" value="3" />
9 15
     </inspection_tool>
@@ -39,7 +45,6 @@
39 45
     <inspection_tool class="CastThatLosesPrecision" enabled="true" level="WARNING" enabled_by_default="true">
40 46
       <option name="ignoreIntegerCharCasts" value="false" />
41 47
     </inspection_tool>
42
-    <inspection_tool class="CastToConcreteClass" enabled="true" level="WARNING" enabled_by_default="true" />
43 48
     <inspection_tool class="CastToIncompatibleInterface" enabled="true" level="WARNING" enabled_by_default="true" />
44 49
     <inspection_tool class="ChainedEquality" enabled="true" level="WARNING" enabled_by_default="true" />
45 50
     <inspection_tool class="ChannelResource" enabled="true" level="WARNING" enabled_by_default="true">
@@ -244,7 +249,7 @@
244 249
     <inspection_tool class="ThisEscapedInConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
245 250
     <inspection_tool class="ThreadWithDefaultRunMethod" enabled="true" level="WARNING" enabled_by_default="true" />
246 251
     <inspection_tool class="ThrowablePrintStackTrace" enabled="true" level="WARNING" enabled_by_default="true" />
247
-    <inspection_tool class="TodoComment" enabled="true" level="INFO" enabled_by_default="true" />
252
+    <inspection_tool class="TodoComment" enabled="false" level="INFO" enabled_by_default="false" />
248 253
     <inspection_tool class="TooBroadScope" enabled="true" level="WARNING" enabled_by_default="true">
249 254
       <option name="m_allowConstructorAsInitializer" value="false" />
250 255
       <option name="m_onlyLookAtBlocks" value="false" />

+ 5
- 4
.idea/misc.xml View File

@@ -2,10 +2,11 @@
2 2
 <project version="4">
3 3
   <component name="EntryPointsManager">
4 4
     <entry_points version="2.0" />
5
-    <list size="3">
6
-      <item index="0" class="java.lang.String" itemvalue="com.google.common.eventbus.Subscribe" />
7
-      <item index="1" class="java.lang.String" itemvalue="dagger.Provides" />
8
-      <item index="2" class="java.lang.String" itemvalue="net.engio.mbassy.listener.Handler" />
5
+    <list size="4">
6
+      <item index="0" class="java.lang.String" itemvalue="com.dmdirc.config.ConfigBinding" />
7
+      <item index="1" class="java.lang.String" itemvalue="com.google.common.eventbus.Subscribe" />
8
+      <item index="2" class="java.lang.String" itemvalue="dagger.Provides" />
9
+      <item index="3" class="java.lang.String" itemvalue="net.engio.mbassy.listener.Handler" />
9 10
     </list>
10 11
   </component>
11 12
   <component name="NullableNotNullManager">

+ 3
- 3
src/com/dmdirc/Channel.java View File

@@ -418,7 +418,7 @@ public class Channel extends MessageTarget implements GroupChat {
418 418
                     + " null ChannelClientInfo");
419 419
         }
420 420
 
421
-        final String[] res = new String[]{
421
+        final String[] res = {
422 422
             getModes(client),
423 423
             Styliser.CODE_NICKNAME + client.getClient().getNickname() + Styliser.CODE_NICKNAME,
424 424
             client.getClient().getUsername(),
@@ -428,10 +428,10 @@ public class Channel extends MessageTarget implements GroupChat {
428 428
             final Map<?, ?> map = client.getMap();
429 429
 
430 430
             if (map.containsKey(ChannelClientProperty.TEXT_FOREGROUND)) {
431
-                String prefix;
431
+                final String prefix;
432 432
 
433 433
                 if (map.containsKey(ChannelClientProperty.TEXT_BACKGROUND)) {
434
-                    prefix = "," + ColourManager.getHex((Colour) map.get(
434
+                    prefix = ',' + ColourManager.getHex((Colour) map.get(
435 435
                             ChannelClientProperty.TEXT_BACKGROUND));
436 436
                 } else {
437 437
                     prefix = Styliser.CODE_HEXCOLOUR + ColourManager.getHex((Colour) map.get(

+ 1
- 1
src/com/dmdirc/Query.java View File

@@ -265,7 +265,7 @@ public class Query extends MessageTarget implements PrivateActionListener,
265 265
 
266 266
             addLine(format, oldNick, client.getUsername(),
267 267
                     client.getHostname(), client.getNickname());
268
-            host = client.getNickname() + "!" + client.getUsername() + "@" + client.getHostname();
268
+            host = client.getNickname() + '!' + client.getUsername() + '@' + client.getHostname();
269 269
             nickname = client.getNickname();
270 270
             updateTitle();
271 271
 

+ 25
- 21
src/com/dmdirc/Server.java View File

@@ -67,8 +67,12 @@ import com.dmdirc.ui.input.TabCompletionType;
67 67
 import com.dmdirc.ui.messages.Formatter;
68 68
 import com.dmdirc.util.URLBuilder;
69 69
 
70
+import java.net.NoRouteToHostException;
71
+import java.net.SocketException;
72
+import java.net.SocketTimeoutException;
70 73
 import java.net.URI;
71 74
 import java.net.URISyntaxException;
75
+import java.net.UnknownHostException;
72 76
 import java.security.cert.CertificateException;
73 77
 import java.security.cert.X509Certificate;
74 78
 import java.util.ArrayList;
@@ -80,7 +84,6 @@ import java.util.HashSet;
80 84
 import java.util.List;
81 85
 import java.util.Map;
82 86
 import java.util.Random;
83
-import java.util.Set;
84 87
 import java.util.concurrent.ConcurrentSkipListMap;
85 88
 import java.util.concurrent.ScheduledExecutorService;
86 89
 import java.util.concurrent.ScheduledFuture;
@@ -89,6 +92,7 @@ import java.util.concurrent.locks.ReadWriteLock;
89 92
 import java.util.concurrent.locks.ReentrantReadWriteLock;
90 93
 
91 94
 import javax.annotation.Nonnull;
95
+import javax.net.ssl.SSLException;
92 96
 import javax.net.ssl.TrustManager;
93 97
 
94 98
 import org.slf4j.LoggerFactory;
@@ -146,7 +150,7 @@ public class Server extends FrameContainer implements ConfigChangeListener,
146 150
     /** A list of outstanding invites. */
147 151
     private final List<Invite> invites = new ArrayList<>();
148 152
     /** A set of channels we want to join without focusing. */
149
-    private final Set<String> backgroundChannels = new HashSet<>();
153
+    private final Collection<String> backgroundChannels = new HashSet<>();
150 154
     /** Our ignore list. */
151 155
     private final IgnoreList ignoreList = new IgnoreList();
152 156
     /** Our string convertor. */
@@ -936,14 +940,14 @@ public class Server extends FrameContainer implements ConfigChangeListener,
936 940
         boolean isTLD = false;
937 941
 
938 942
         for (String tld : tlds) {
939
-            if (serverName.endsWith("." + tld)) {
943
+            if (serverName.endsWith('.' + tld)) {
940 944
                 isTLD = true;
941 945
                 break;
942 946
             }
943 947
         }
944 948
 
945 949
         if (isTLD && parts.length > 2) {
946
-            return parts[parts.length - 2] + "." + parts[parts.length - 1];
950
+            return parts[parts.length - 2] + '.' + parts[parts.length - 1];
947 951
         } else if (parts.length > 2) {
948 952
             final StringBuilder network = new StringBuilder();
949 953
 
@@ -1038,13 +1042,13 @@ public class Server extends FrameContainer implements ConfigChangeListener,
1038 1042
 
1039 1043
     @Override
1040 1044
     public void sendCTCPReply(final String source, final String type, final String args) {
1041
-        if (type.equalsIgnoreCase("VERSION")) {
1045
+        if ("VERSION".equalsIgnoreCase(type)) {
1042 1046
             parser.sendCTCPReply(source, "VERSION", "DMDirc "
1043 1047
                     + getConfigManager().getOption("version", "version")
1044 1048
                     + " - http://www.dmdirc.com/");
1045
-        } else if (type.equalsIgnoreCase("PING")) {
1049
+        } else if ("PING".equalsIgnoreCase(type)) {
1046 1050
             parser.sendCTCPReply(source, "PING", args);
1047
-        } else if (type.equalsIgnoreCase("CLIENTINFO")) {
1051
+        } else if ("CLIENTINFO".equalsIgnoreCase(type)) {
1048 1052
             parser.sendCTCPReply(source, "CLIENTINFO", "VERSION PING CLIENTINFO");
1049 1053
         }
1050 1054
     }
@@ -1054,7 +1058,7 @@ public class Server extends FrameContainer implements ConfigChangeListener,
1054 1058
         try {
1055 1059
             parserLock.readLock().lock();
1056 1060
             return hasChannel(channelName)
1057
-                    || (parser != null && parser.isValidChannelName(channelName));
1061
+                    || parser != null && parser.isValidChannelName(channelName);
1058 1062
         } finally {
1059 1063
             parserLock.readLock().unlock();
1060 1064
         }
@@ -1088,7 +1092,7 @@ public class Server extends FrameContainer implements ConfigChangeListener,
1088 1092
 
1089 1093
             try {
1090 1094
                 parserLock.readLock().lock();
1091
-                final Object[] arguments = new Object[]{
1095
+                final Object[] arguments = {
1092 1096
                     address.getHost(), parser == null ? "Unknown" : parser.getServerName(),
1093 1097
                     address.getPort(), parser == null ? "Unknown" : getNetwork(),
1094 1098
                     parser == null ? "Unknown" : parser.getLocalClient().getNickname(),};
@@ -1155,7 +1159,7 @@ public class Server extends FrameContainer implements ConfigChangeListener,
1155 1159
         if (numeric < 10) {
1156 1160
             snumeric = "00" + snumeric;
1157 1161
         } else if (numeric < 100) {
1158
-            snumeric = "0" + snumeric;
1162
+            snumeric = '0' + snumeric;
1159 1163
         }
1160 1164
 
1161 1165
         final String sansIrcd = "numeric_" + snumeric;
@@ -1277,21 +1281,21 @@ public class Server extends FrameContainer implements ConfigChangeListener,
1277 1281
 
1278 1282
             updateIcon();
1279 1283
 
1280
-            String description;
1284
+            final String description;
1281 1285
 
1282 1286
             if (errorInfo.getException() == null) {
1283 1287
                 description = errorInfo.getData();
1284 1288
             } else {
1285 1289
                 final Exception exception = errorInfo.getException();
1286 1290
 
1287
-                if (exception instanceof java.net.UnknownHostException) {
1291
+                if (exception instanceof UnknownHostException) {
1288 1292
                     description = "Unknown host (unable to resolve)";
1289
-                } else if (exception instanceof java.net.NoRouteToHostException) {
1293
+                } else if (exception instanceof NoRouteToHostException) {
1290 1294
                     description = "No route to host";
1291
-                } else if (exception instanceof java.net.SocketTimeoutException) {
1295
+                } else if (exception instanceof SocketTimeoutException) {
1292 1296
                     description = "Connection attempt timed out";
1293
-                } else if (exception instanceof java.net.SocketException
1294
-                        || exception instanceof javax.net.ssl.SSLException) {
1297
+                } else if (exception instanceof SocketException
1298
+                        || exception instanceof SSLException) {
1295 1299
                     description = exception.getMessage();
1296 1300
                 } else {
1297 1301
                     Logger.appError(ErrorLevel.LOW, "Unknown socket error: "
@@ -1318,7 +1322,7 @@ public class Server extends FrameContainer implements ConfigChangeListener,
1318 1322
     public void onPingFailed() {
1319 1323
         statusBarManager.setMessage(new StatusMessage(
1320 1324
                 "No ping reply from " + getName() + " for over "
1321
-                + ((int) (Math.floor(parser.getPingTime() / 1000.0)))
1325
+                + (int) Math.floor(parser.getPingTime() / 1000.0)
1322 1326
                 + " seconds.", getConfigManager()));
1323 1327
 
1324 1328
         getEventBus().publishAsync(new ServerNopingEvent(this, parser.getPingTime()));
@@ -1412,8 +1416,8 @@ public class Server extends FrameContainer implements ConfigChangeListener,
1412 1416
                 missing.append(missingUmodes);
1413 1417
             }
1414 1418
 
1415
-            Logger.appError(ErrorLevel.LOW, missing.toString() + " ["
1416
-                    + parser.getServerSoftwareType() + "]",
1419
+            Logger.appError(ErrorLevel.LOW, missing + " ["
1420
+                    + parser.getServerSoftwareType() + ']',
1417 1421
                     new MissingModeAliasException(getNetwork(), parser,
1418 1422
                             getConfigManager().getOption("identity",
1419 1423
                                     "modealiasversion"), missing.toString()));
@@ -1547,8 +1551,8 @@ public class Server extends FrameContainer implements ConfigChangeListener,
1547 1551
 
1548 1552
     @Override
1549 1553
     public void updateAwayState(final String message) {
1550
-        if ((awayMessage != null && awayMessage.equals(message))
1551
-                || (awayMessage == null && message == null)) {
1554
+        if (awayMessage != null && awayMessage.equals(message)
1555
+                || awayMessage == null && message == null) {
1552 1556
             return;
1553 1557
         }
1554 1558
 

+ 2
- 2
src/com/dmdirc/ServerStatus.java View File

@@ -104,7 +104,7 @@ public class ServerStatus {
104 104
         builder.append('→');
105 105
         builder.append(toState.name());
106 106
         builder.append(' ');
107
-        builder.append(Thread.currentThread().getStackTrace()[3].toString());
107
+        builder.append(Thread.currentThread().getStackTrace()[3]);
108 108
         builder.append(" [");
109 109
         builder.append(Thread.currentThread().getName());
110 110
         builder.append("] (parser #");
@@ -117,7 +117,7 @@ public class ServerStatus {
117 117
     /**
118 118
      * Retrieves the transition history of this status object as a string.
119 119
      *
120
-     * @see #addHistoryEntry(com.dmdirc.ServerState, com.dmdirc.ServerState)
120
+     * @see #addHistoryEntry(ServerState, ServerState)
121 121
      * @return A line feed ('\n') delimited string containing one entry for each of the entries in
122 122
      *         this status's transition history.
123 123
      */

Loading…
Cancel
Save