Browse Source

PMD fixes

Change-Id: Ifc4aa601de14ca2526646f499f60329ed7c5935e
Reviewed-on: http://gerrit.dmdirc.com/3937
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
changes/37/3937/2
Chris Smith 9 years ago
parent
commit
254baff399

+ 8
- 8
src/com/dmdirc/parser/irc/IRCChannelInfo.java View File

@@ -465,7 +465,7 @@ public class IRCChannelInfo implements ChannelInfo {
465 465
             sTemp = paramModes.get(cTemp);
466 466
             if (!sTemp.isEmpty()) {
467 467
                 sModes.append(cTemp);
468
-                sModeParams.append(" ").append(this.getMode(cTemp));
468
+                sModeParams.append(' ').append(this.getMode(cTemp));
469 469
             }
470 470
         }
471 471
 
@@ -683,20 +683,20 @@ public class IRCChannelInfo implements ChannelInfo {
683 683
             if (positive) {
684 684
                 positivemode.append(modestr.charAt(1));
685 685
                 if (modeparam.length > 1) {
686
-                    positiveparam.append(" ").append(modeparam[1]);
686
+                    positiveparam.append(' ').append(modeparam[1]);
687 687
                 }
688 688
             } else {
689 689
                 negativemode.append(modestr.charAt(1));
690 690
                 if (modeparam.length > 1) {
691
-                    negativeparam.append(" ").append(modeparam[1]);
691
+                    negativeparam.append(' ').append(modeparam[1]);
692 692
                 }
693 693
             }
694 694
         }
695 695
         if (negativemode.length() > 0) {
696
-            sendModeStr.append("-").append(negativemode);
696
+            sendModeStr.append('-').append(negativemode);
697 697
         }
698 698
         if (positivemode.length() > 0) {
699
-            sendModeStr.append("+").append(positivemode);
699
+            sendModeStr.append('+').append(positivemode);
700 700
         }
701 701
         if (negativeparam.length() > 0) {
702 702
             sendModeStr.append(negativeparam);
@@ -705,7 +705,7 @@ public class IRCChannelInfo implements ChannelInfo {
705 705
             sendModeStr.append(positiveparam);
706 706
         }
707 707
         parser.callDebugInfo(IRCParser.DEBUG_INFO, "Sending mode: %s", sendModeStr.toString());
708
-        parser.sendRawMessage("MODE " + name + " " + sendModeStr.toString());
708
+        parser.sendRawMessage("MODE " + name + ' ' + sendModeStr);
709 709
         clearModeQueue();
710 710
     }
711 711
 
@@ -760,7 +760,7 @@ public class IRCChannelInfo implements ChannelInfo {
760 760
         if (sMessage.isEmpty()) {
761 761
             sendMessage(char1 + sType.toUpperCase() + sMessage + char1);
762 762
         } else {
763
-            sendMessage(char1 + sType.toUpperCase() + " " + sMessage + char1);
763
+            sendMessage(char1 + sType.toUpperCase() + ' ' + sMessage + char1);
764 764
         }
765 765
     }
766 766
 
@@ -778,7 +778,7 @@ public class IRCChannelInfo implements ChannelInfo {
778 778
         if (sMessage.isEmpty()) {
779 779
             sendNotice(char1 + sType.toUpperCase() + sMessage + char1);
780 780
         } else {
781
-            sendNotice(char1 + sType.toUpperCase() + " " + sMessage + char1);
781
+            sendNotice(char1 + sType.toUpperCase() + ' ' + sMessage + char1);
782 782
         }
783 783
     }
784 784
 

+ 3
- 3
src/com/dmdirc/parser/irc/IRCClientInfo.java View File

@@ -442,15 +442,15 @@ public class IRCClientInfo implements LocalClientInfo {
442 442
         }
443 443
 
444 444
         if (negativemode.length() > 0) {
445
-            sendModeStr.append("-").append(negativemode);
445
+            sendModeStr.append('-').append(negativemode);
446 446
         }
447 447
 
448 448
         if (positivemode.length() > 0) {
449
-            sendModeStr.append("+").append(positivemode);
449
+            sendModeStr.append('+').append(positivemode);
450 450
         }
451 451
 
452 452
         parser.callDebugInfo(IRCParser.DEBUG_INFO, "Sending mode: %s", sendModeStr.toString());
453
-        parser.sendRawMessage("MODE " + nickname + " " + sendModeStr.toString());
453
+        parser.sendRawMessage("MODE " + nickname + ' ' + sendModeStr);
454 454
         clearModeQueue();
455 455
     }
456 456
 

+ 1
- 1
src/com/dmdirc/parser/irc/ProcessMode.java View File

@@ -252,7 +252,7 @@ public class ProcessMode extends IRCProcessor {
252 252
 
253 253
         // Call Callbacks
254 254
         for (String aSModestr : sModestr) {
255
-            sFullModeStr.append(aSModestr).append(" ");
255
+            sFullModeStr.append(aSModestr).append(' ');
256 256
         }
257 257
 
258 258
         iChannel.setMode(nCurrent);

+ 14
- 9
test/com/dmdirc/harness/parser/TestParser.java View File

@@ -25,8 +25,13 @@ package com.dmdirc.harness.parser;
25 25
 import com.dmdirc.parser.common.ChildImplementations;
26 26
 import com.dmdirc.parser.common.MyInfo;
27 27
 import com.dmdirc.parser.common.QueuePriority;
28
-import com.dmdirc.parser.interfaces.Parser;
29
-import com.dmdirc.parser.irc.*;
28
+import com.dmdirc.parser.irc.IRCChannelClientInfo;
29
+import com.dmdirc.parser.irc.IRCChannelInfo;
30
+import com.dmdirc.parser.irc.IRCClientInfo;
31
+import com.dmdirc.parser.irc.IRCParser;
32
+import com.dmdirc.parser.irc.IRCReader;
33
+import com.dmdirc.parser.irc.SocketState;
34
+
30 35
 import java.net.URI;
31 36
 import java.net.URISyntaxException;
32 37
 import java.util.ArrayList;
@@ -38,7 +43,7 @@ import java.util.Timer;
38 43
     IRCChannelInfo.class,
39 44
     IRCClientInfo.class
40 45
 })
41
-public class TestParser extends IRCParser implements Parser {
46
+public class TestParser extends IRCParser {
42 47
 
43 48
     public final List<String> sentLines = new ArrayList<>();
44 49
 
@@ -53,7 +58,7 @@ public class TestParser extends IRCParser implements Parser {
53 58
         setPingTimerInterval(60000);
54 59
     }
55 60
 
56
-    public TestParser(MyInfo myDetails, URI address) {
61
+    public TestParser(final MyInfo myDetails, final URI address) {
57 62
         super(myDetails, address);
58 63
         currentSocketState = SocketState.OPEN;
59 64
         setPingTimerFraction(10);
@@ -69,28 +74,28 @@ public class TestParser extends IRCParser implements Parser {
69 74
     }
70 75
 
71 76
     @Override
72
-    protected boolean doSendString(String line, QueuePriority priority, boolean fromParser) {
77
+    protected boolean doSendString(final String line, final QueuePriority priority, final boolean fromParser) {
73 78
         sentLines.add(line);
74 79
         return true;
75 80
     }
76 81
 
77
-    public String[] getLine(int index) {
82
+    public String[] getLine(final int index) {
78 83
         return tokeniseLine(sentLines.get(index));
79 84
     }
80 85
 
81
-    public void injectLine(String line) {
86
+    public void injectLine(final String line) {
82 87
         processLine(new IRCReader.ReadLine(line, IRCParser.tokeniseLine(line)));
83 88
     }
84 89
 
85 90
     public void injectConnectionStrings() {
86
-        final String[] lines = new String[]{
91
+        final String[] lines = {
87 92
             "NOTICE AUTH :Blah, blah",
88 93
             ":server 001 " + nick + " :Welcome to the Testing IRC Network, " + nick,
89 94
             ":server 002 " + nick + " :Your host is server.net, running version foo",
90 95
             ":server 003 " + nick + " :This server was created Sun Jan 6 2008 at 17:34:54 CET",
91 96
             ":server 004 " + nick + " server.net foo dioswkgxRXInP bRIeiklmnopstvrDcCNuMT bklov",
92 97
             ":server 005 " + nick + " WHOX WALLCHOPS WALLVOICES USERIP PREFIX=(ov)@+ " +
93
-                    (network == null ? "" : "NETWORK=" + network + " ") +
98
+                    (network == null ? "" : "NETWORK=" + network + ' ') +
94 99
                     ":are supported by this server",
95 100
             ":server 005 " + nick + " MAXNICKLEN=15 TOPICLEN=250 AWAYLEN=160 MODES=6 " +
96 101
                     "CHANMODES=bIeR,k,l,imnpstrDducCNMT :are supported by this server",

+ 2
- 2
test/com/dmdirc/parser/common/IgnoreListTest.java View File

@@ -73,7 +73,7 @@ public class IgnoreListTest {
73 73
             boolean except = false;
74 74
             
75 75
             try {
76
-                String converted = IgnoreList.regexToSimple(test);
76
+                IgnoreList.regexToSimple(test);
77 77
             } catch (UnsupportedOperationException ex) {
78 78
                 except = true;
79 79
             }
@@ -84,7 +84,7 @@ public class IgnoreListTest {
84 84
     
85 85
     @Test
86 86
     public void testConstructor() {
87
-        final List<String> items = Arrays.asList(new String[]{"abc", "def"});
87
+        final List<String> items = Arrays.asList("abc", "def");
88 88
         final IgnoreList list = new IgnoreList(items);
89 89
         
90 90
         assertEquals(items, list.getRegexList());

+ 1
- 1
test/com/dmdirc/parser/irc/IRCParserIrcdTest.java View File

@@ -35,7 +35,7 @@ public class IRCParserIrcdTest {
35 35
 
36 36
     private final String ircd, expected;
37 37
 
38
-    public IRCParserIrcdTest(String ircd, String expected) {
38
+    public IRCParserIrcdTest(final String ircd, final String expected) {
39 39
         this.ircd = ircd;
40 40
         this.expected = expected;
41 41
     }

+ 1
- 1
test/com/dmdirc/parser/irc/IRCParserTest.java View File

@@ -49,7 +49,7 @@ import static org.mockito.Mockito.*;
49 49
 
50 50
 public class IRCParserTest {
51 51
 
52
-    private static interface TestCallback extends CallbackInterface { }
52
+    private interface TestCallback extends CallbackInterface { }
53 53
 
54 54
     @Test(expected=CallbackNotFoundException.class)
55 55
     public void testIssue42() {

+ 1
- 1
test/com/dmdirc/parser/irc/ParserErrorTest.java View File

@@ -93,7 +93,7 @@ public class ParserErrorTest {
93 93
 
94 94
     @Test
95 95
     public void testException() {
96
-        fatal.setException(new Exception("foo"));
96
+        fatal.setException(new UnsupportedOperationException("foo"));
97 97
         
98 98
         assertTrue(fatal.isException());
99 99
         assertTrue(fatal.isFatal());

+ 1
- 1
test/com/dmdirc/parser/irc/ProcessListModeTest.java View File

@@ -30,7 +30,7 @@ import static org.junit.Assert.*;
30 30
 
31 31
 public class ProcessListModeTest {
32 32
 
33
-    private void testListModes(String numeric1, String numeric2, char mode) {
33
+    private void testListModes(final String numeric1, final String numeric2, final char mode) {
34 34
         final TestParser parser = new TestParser();
35 35
         parser.injectConnectionStrings();
36 36
 

+ 2
- 2
test/com/dmdirc/parser/irc/ProcessNickTest.java View File

@@ -53,7 +53,7 @@ public class ProcessNickTest {
53 53
         assertNotNull(parser.getClient("LUSER"));
54 54
         assertEquals(1, parser.getClient("LUSER").getChannelClients().size());
55 55
 
56
-        IRCChannelClientInfo cci = parser.getClient("LUSER").getChannelClients().get(0);
56
+        final IRCChannelClientInfo cci = parser.getClient("LUSER").getChannelClients().get(0);
57 57
         assertEquals(parser.getChannel("#DMDirc_testing"), cci.getChannel());
58 58
         assertEquals("+", cci.getChanModeStr(true));
59 59
 
@@ -75,7 +75,7 @@ public class ProcessNickTest {
75 75
         assertFalse(parser.isKnownClient("luser"));
76 76
         assertEquals(1, parser.getClient("foobar").getChannelClients().size());
77 77
 
78
-        IRCChannelClientInfo cci = parser.getClient("foobar").getChannelClients().get(0);
78
+        final IRCChannelClientInfo cci = parser.getClient("foobar").getChannelClients().get(0);
79 79
         assertEquals(parser.getChannel("#DMDirc_testing"), cci.getChannel());
80 80
         assertEquals("+", cci.getChanModeStr(true));
81 81
     }    

Loading…
Cancel
Save