Browse Source

Enable PMD for plugins.

Fix assorted PMD errors.

Change-Id: I9af7e36f2aeb10bd658c5825ad2f94161e0bb243
Reviewed-on: http://gerrit.dmdirc.com/3940
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
changes/40/3940/2
Chris Smith 9 years ago
parent
commit
4c68c5e600
23 changed files with 278 additions and 125 deletions
  1. 6
    0
      build.gradle
  2. 1
    1
      calc/test/com/dmdirc/addons/calc/EvaluatorTest.java
  3. 3
    3
      conditional_execute/test/com/dmdirc/addons/conditional_execute/ConditionalExecuteCommandTest.java
  4. 10
    11
      dcc/src/com/dmdirc/addons/dcc/DCCManager.java
  5. 1
    1
      dcc/src/com/dmdirc/addons/dcc/TransferContainer.java
  6. 1
    1
      dcc/src/com/dmdirc/addons/dcc/ui/TransferPanel.java
  7. 0
    1
      debug/test/com/dmdirc/addons/debug/DebugTest.java
  8. 142
    0
      etc/pmd/full.xml
  9. 1
    1
      lagdisplay/src/com/dmdirc/addons/lagdisplay/LagDisplayManager.java
  10. 20
    7
      logging/src/com/dmdirc/addons/logging/LoggingManager.java
  11. 2
    2
      mediasource_dbus/src/com/dmdirc/addons/mediasource_dbus/MPRISSource.java
  12. 2
    2
      mediasource_dcop/src/com/dmdirc/addons/mediasource_dcop/KaffeineSource.java
  13. 3
    3
      mediasource_dcop/src/com/dmdirc/addons/mediasource_dcop/NoatunSource.java
  14. 1
    1
      mediasource_windows/src/com/dmdirc/addons/mediasource_windows/DllSource.java
  15. 2
    2
      ui_swing/src/com/dmdirc/addons/ui_swing/UIUtilities.java
  16. 1
    1
      ui_swing/src/com/dmdirc/addons/ui_swing/components/NickList.java
  17. 17
    22
      ui_swing/src/com/dmdirc/addons/ui_swing/components/SwingSearchBar.java
  18. 1
    1
      ui_swing/src/com/dmdirc/addons/ui_swing/components/menubar/MenuBar.java
  19. 2
    2
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionDisplayPanel.java
  20. 2
    2
      ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/AddNicknameValidatorTest.java
  21. 3
    3
      ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/EditNicknameValidatorTest.java
  22. 54
    55
      ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerModelTest.java
  23. 3
    3
      ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileNameValidatorTest.java

+ 6
- 0
build.gradle View File

@@ -4,6 +4,7 @@ import org.mdonoughe.JGitDescribeTask
4 4
 
5 5
 subprojects {
6 6
     apply plugin: 'java'
7
+    apply plugin: 'pmd'
7 8
 
8 9
     configurations {
9 10
         bundle
@@ -73,6 +74,11 @@ subprojects {
73 74
         targetFile << "\n\nversion:\n  number=${version}\n"
74 75
     }
75 76
 
77
+    pmd {
78
+        ruleSets = []
79
+        ruleSetFiles = files("$rootDir/etc/pmd/full.xml")
80
+    }
81
+
76 82
     jar {
77 83
         from("$buildDir/plugin.config") {
78 84
             into 'META-INF'

+ 1
- 1
calc/test/com/dmdirc/addons/calc/EvaluatorTest.java View File

@@ -37,7 +37,7 @@ public class EvaluatorTest {
37 37
     private final String input;
38 38
     private final float output;
39 39
 
40
-    public EvaluatorTest(String input, String output) {
40
+    public EvaluatorTest(final String input, final String output) {
41 41
         this.input = input;
42 42
         this.output = Float.parseFloat(output);
43 43
     }

+ 3
- 3
conditional_execute/test/com/dmdirc/addons/conditional_execute/ConditionalExecuteCommandTest.java View File

@@ -154,11 +154,11 @@ public class ConditionalExecuteCommandTest {
154 154
         verifyNoCommandExecuted();
155 155
     }
156 156
 
157
-    private void execute(String line) {
157
+    private void execute(final String line) {
158 158
         command.execute(container, new CommandArguments(commandController, line), context);
159 159
     }
160 160
 
161
-    private void verifyCommandExecuted(String command) {
161
+    private void verifyCommandExecuted(final String command) {
162 162
         verify(commandParser).parseCommand(same(container), eq(command));
163 163
     }
164 164
 
@@ -166,7 +166,7 @@ public class ConditionalExecuteCommandTest {
166 166
         verify(commandParser, never()).parseCommand(same(container), anyString());
167 167
     }
168 168
 
169
-    private void verifyErrorOutput(String substring) {
169
+    private void verifyErrorOutput(final String substring) {
170 170
         verify(container).addLine(eq("commandError"), contains(substring));
171 171
     }
172 172
 

+ 10
- 11
dcc/src/com/dmdirc/addons/dcc/DCCManager.java View File

@@ -464,10 +464,10 @@ public class DCCManager {
464 464
                     bit = bit.substring(1);
465 465
                 }
466 466
                 if (bit.endsWith("\"")) {
467
-                    filenameBits.append(" ").append(bit.substring(0, bit.length() - 1));
467
+                    filenameBits.append(' ').append(bit.substring(0, bit.length() - 1));
468 468
                     break;
469 469
                 } else {
470
-                    filenameBits.append(" ").append(bit);
470
+                    filenameBits.append(' ').append(bit);
471 471
                 }
472 472
             }
473 473
             tmpFilename = filenameBits.toString().trim();
@@ -514,13 +514,12 @@ public class DCCManager {
514 514
             return;
515 515
         }
516 516
 
517
-        if (DCCTransfer.findByToken(token) == null && !dontAsk) {
518
-            if (token.isEmpty() || port.equals("0")) {
519
-                // Make sure this is not a reverse DCC Send that we no longer care about.
520
-                eventBus.publish(new DccSendRequestEvent(connection, nickname, filename));
521
-                new SendRequestDialog(mainWindow, this, token, ipLong, portInt, filename, size,
522
-                        nickname, connection).display();
523
-            }
517
+        if (DCCTransfer.findByToken(token) == null && !dontAsk &&
518
+                (token.isEmpty() || port.equals("0"))) {
519
+            // Make sure this is not a reverse DCC Send that we no longer care about.
520
+            eventBus.publish(new DccSendRequestEvent(connection, nickname, filename));
521
+            new SendRequestDialog(mainWindow, this, token, ipLong, portInt, filename, size,
522
+                    nickname, connection).display();
524 523
         }
525 524
     }
526 525
 
@@ -561,11 +560,11 @@ public class DCCManager {
561 560
                     bit = bit.substring(1);
562 561
                 }
563 562
                 if (bit.endsWith("\"")) {
564
-                    filenameBits.append(" ")
563
+                    filenameBits.append(' ')
565 564
                             .append(bit.substring(0, bit.length() - 1));
566 565
                     break;
567 566
                 } else {
568
-                    filenameBits.append(" ").append(bit);
567
+                    filenameBits.append(' ').append(bit);
569 568
                 }
570 569
             }
571 570
             filename = filenameBits.toString().trim();

+ 1
- 1
dcc/src/com/dmdirc/addons/dcc/TransferContainer.java View File

@@ -161,7 +161,7 @@ public class TransferContainer extends FrameContainer implements
161 161
         if (percentageInTitle) {
162 162
             final StringBuilder title = new StringBuilder();
163 163
             if (dcc.isListenSocket()) {
164
-                title.append("*");
164
+                title.append('*');
165 165
             }
166 166
             title.append(dcc.getType() == DCCTransfer.TransferType.SEND
167 167
                     ? "Sending: " : "Receiving: ");

+ 1
- 1
dcc/src/com/dmdirc/addons/dcc/ui/TransferPanel.java View File

@@ -260,7 +260,7 @@ public class TransferPanel extends JPanel implements ActionListener,
260 260
 
261 261
         if (hours > 0) {
262 262
             result.append(hours);
263
-            result.append(":");
263
+            result.append(':');
264 264
         }
265 265
         result.append(String.format("%0,2d:%0,2d", minutes, seconds));
266 266
 

+ 0
- 1
debug/test/com/dmdirc/addons/debug/DebugTest.java View File

@@ -51,7 +51,6 @@ public class DebugTest {
51 51
 
52 52
     @Mock private CommandArguments arguments;
53 53
     @Mock private FrameContainer container;
54
-    @Mock private DebugPlugin plugin;
55 54
     @Mock private CommandController controller;
56 55
     @Mock private DebugCommand debugCommand;
57 56
     @Mock private CommandContext commandContext;

+ 142
- 0
etc/pmd/full.xml View File

@@ -0,0 +1,142 @@
1
+<?xml version="1.0"?>
2
+<ruleset name="DMDirc PMD checks"
3
+         xmlns="http://pmd.sf.net/ruleset/1.0.0"
4
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+         xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
6
+         xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
7
+        <description>DMDirc minimal PMD checks.</description>
8
+
9
+<rule ref="rulesets/java/empty.xml/EmptyIfStmt"><priority>1</priority></rule>
10
+<rule ref="rulesets/java/empty.xml/EmptyWhileStmt"><priority>1</priority></rule>
11
+<rule ref="rulesets/java/empty.xml/EmptyTryBlock"><priority>1</priority></rule>
12
+<rule ref="rulesets/java/empty.xml/EmptyFinallyBlock"><priority>1</priority></rule>
13
+<rule ref="rulesets/java/empty.xml/EmptySwitchStatements"><priority>1</priority></rule>
14
+<rule ref="rulesets/java/basic.xml/JumbledIncrementer"><priority>1</priority></rule>
15
+<rule ref="rulesets/java/basic.xml/ForLoopShouldBeWhileLoop"><priority>1</priority></rule>
16
+<rule ref="rulesets/java/unnecessary.xml/UnnecessaryConversionTemporary"><priority>1</priority></rule>
17
+<rule ref="rulesets/java/basic.xml/OverrideBothEqualsAndHashcode"><priority>1</priority></rule>
18
+<rule ref="rulesets/java/basic.xml/DoubleCheckedLocking"><priority>1</priority></rule>
19
+<rule ref="rulesets/java/basic.xml/ReturnFromFinallyBlock"><priority>1</priority></rule>
20
+<rule ref="rulesets/java/empty.xml/EmptySynchronizedBlock"><priority>1</priority></rule>
21
+<rule ref="rulesets/java/empty.xml/EmptyStaticInitializer"><priority>1</priority></rule>
22
+<rule ref="rulesets/java/basic.xml/UnconditionalIfStatement"><priority>1</priority></rule>
23
+<rule ref="rulesets/java/empty.xml/EmptyStatementNotInLoop"><priority>1</priority></rule>
24
+<rule ref="rulesets/java/basic.xml/BooleanInstantiation"><priority>1</priority></rule>
25
+<rule ref="rulesets/java/unnecessary.xml/UnnecessaryFinalModifier"><priority>1</priority></rule>
26
+<rule ref="rulesets/java/basic.xml/CollapsibleIfStatements"><priority>1</priority></rule>
27
+<rule ref="rulesets/java/unnecessary.xml/UselessOverridingMethod"><priority>1</priority></rule>
28
+<rule ref="rulesets/java/basic.xml/ClassCastExceptionWithToArray"><priority>1</priority></rule>
29
+<rule ref="rulesets/java/basic.xml/AvoidDecimalLiteralsInBigDecimalConstructor"><priority>1</priority></rule>
30
+<rule ref="rulesets/java/unnecessary.xml/UselessOperationOnImmutable"><priority>1</priority></rule>
31
+<rule ref="rulesets/java/basic.xml/MisplacedNullCheck"><priority>1</priority></rule>
32
+<rule ref="rulesets/java/unnecessary.xml/UnusedNullCheckInEquals"><priority>1</priority></rule>
33
+<rule ref="rulesets/java/basic.xml/BrokenNullCheck"><priority>1</priority></rule>
34
+<rule ref="rulesets/java/basic.xml/BigIntegerInstantiation"><priority>1</priority></rule>
35
+<rule ref="rulesets/java/basic.xml/AvoidMultipleUnaryOperators"><priority>1</priority></rule>
36
+<rule ref="rulesets/java/empty.xml/EmptyInitializer"><priority>1</priority></rule>
37
+
38
+<rule ref="rulesets/java/braces.xml/IfStmtsMustUseBraces"><priority>1</priority></rule>
39
+<rule ref="rulesets/java/braces.xml/WhileLoopsMustUseBraces"><priority>1</priority></rule>
40
+<rule ref="rulesets/java/braces.xml/IfElseStmtsMustUseBraces"><priority>1</priority></rule>
41
+<rule ref="rulesets/java/braces.xml/ForLoopsMustUseBraces"><priority>1</priority></rule>
42
+
43
+<rule ref="rulesets/java/unusedcode.xml/UnusedModifier"><priority>1</priority></rule>
44
+<rule ref="rulesets/java/controversial.xml/DontImportSun"><priority>1</priority></rule>
45
+
46
+<rule ref="rulesets/java/design.xml/SimplifyBooleanReturns"><priority>1</priority></rule>
47
+<rule ref="rulesets/java/design.xml/SimplifyBooleanExpressions"><priority>1</priority></rule>
48
+<rule ref="rulesets/java/design.xml/AvoidReassigningParameters"><priority>1</priority></rule>
49
+<rule ref="rulesets/java/design.xml/FinalFieldCouldBeStatic"><priority>1</priority></rule>
50
+<rule ref="rulesets/java/design.xml/NonStaticInitializer"><priority>1</priority></rule>
51
+<rule ref="rulesets/java/design.xml/OptimizableToArrayCall"><priority>1</priority></rule>
52
+<rule ref="rulesets/java/design.xml/BadComparison"><priority>1</priority></rule>
53
+<rule ref="rulesets/java/design.xml/EqualsNull"><priority>1</priority></rule>
54
+<rule ref="rulesets/java/design.xml/InstantiationToGetClass"><priority>1</priority></rule>
55
+<rule ref="rulesets/java/design.xml/IdempotentOperations"><priority>1</priority></rule>
56
+<rule ref="rulesets/java/design.xml/AssignmentToNonFinalStatic"><priority>1</priority></rule>
57
+<rule ref="rulesets/java/design.xml/MissingStaticMethodInNonInstantiatableClass"><priority>1</priority></rule>
58
+<rule ref="rulesets/java/design.xml/UseNotifyAllInsteadOfNotify"><priority>1</priority></rule>
59
+<rule ref="rulesets/java/design.xml/AvoidInstanceofChecksInCatchClause"><priority>1</priority></rule>
60
+<rule ref="rulesets/java/design.xml/SimplifyConditional"><priority>1</priority></rule>
61
+<rule ref="rulesets/java/design.xml/UnnecessaryLocalBeforeReturn"><priority>1</priority></rule>
62
+<rule ref="rulesets/java/design.xml/NonThreadSafeSingleton"><priority>1</priority></rule>
63
+<rule ref="rulesets/java/design.xml/AvoidConstantsInterface"><priority>1</priority></rule>
64
+<rule ref="rulesets/java/design.xml/UnsynchronizedStaticDateFormatter"><priority>1</priority></rule>
65
+<rule ref="rulesets/java/design.xml/PreserveStackTrace"><priority>1</priority></rule>
66
+<rule ref="rulesets/java/design.xml/UseCollectionIsEmpty"><priority>1</priority></rule>
67
+
68
+<rule ref="rulesets/java/finalizers.xml/EmptyFinalizer"><priority>1</priority></rule>
69
+<rule ref="rulesets/java/finalizers.xml/FinalizeOnlyCallsSuperFinalize"><priority>1</priority></rule>
70
+<rule ref="rulesets/java/finalizers.xml/FinalizeOverloaded"><priority>1</priority></rule>
71
+<rule ref="rulesets/java/finalizers.xml/FinalizeDoesNotCallSuperFinalize"><priority>1</priority></rule>
72
+<rule ref="rulesets/java/finalizers.xml/FinalizeShouldBeProtected"><priority>1</priority></rule>
73
+<rule ref="rulesets/java/finalizers.xml/AvoidCallingFinalize"><priority>1</priority></rule>
74
+
75
+<rule ref="rulesets/java/imports.xml/DuplicateImports"><priority>1</priority></rule>
76
+<rule ref="rulesets/java/imports.xml/DontImportJavaLang"><priority>1</priority></rule>
77
+<rule ref="rulesets/java/imports.xml/UnusedImports"><priority>1</priority></rule>
78
+<rule ref="rulesets/java/imports.xml/ImportFromSamePackage"><priority>1</priority></rule>
79
+
80
+<rule ref="rulesets/java/logging-java.xml/MoreThanOneLogger"><priority>1</priority></rule>
81
+<rule ref="rulesets/java/logging-java.xml/LoggerIsNotStaticFinal"><priority>1</priority></rule>
82
+
83
+<rule ref="rulesets/java/migrating.xml/ReplaceVectorWithList"><priority>1</priority></rule>
84
+<rule ref="rulesets/java/migrating.xml/ReplaceHashtableWithMap"><priority>1</priority></rule>
85
+<rule ref="rulesets/java/migrating.xml/ReplaceEnumerationWithIterator"><priority>1</priority></rule>
86
+<rule ref="rulesets/java/migrating.xml/AvoidEnumAsIdentifier"><priority>1</priority></rule>
87
+<rule ref="rulesets/java/migrating.xml/AvoidAssertAsIdentifier"><priority>1</priority></rule>
88
+<rule ref="rulesets/java/migrating.xml/IntegerInstantiation"><priority>1</priority></rule>
89
+<rule ref="rulesets/java/migrating.xml/ByteInstantiation"><priority>1</priority></rule>
90
+<rule ref="rulesets/java/migrating.xml/ShortInstantiation"><priority>1</priority></rule>
91
+<rule ref="rulesets/java/migrating.xml/LongInstantiation"><priority>1</priority></rule>
92
+
93
+<rule ref="rulesets/java/naming.xml/VariableNamingConventions"><priority>1</priority></rule>
94
+<rule ref="rulesets/java/naming.xml/MethodNamingConventions"><priority>1</priority></rule>
95
+<rule ref="rulesets/java/naming.xml/ClassNamingConventions"><priority>1</priority></rule>
96
+<rule ref="rulesets/java/naming.xml/AvoidDollarSigns"><priority>1</priority></rule>
97
+<rule ref="rulesets/java/naming.xml/MethodWithSameNameAsEnclosingClass"><priority>1</priority></rule>
98
+<rule ref="rulesets/java/naming.xml/SuspiciousHashcodeMethodName"><priority>1</priority></rule>
99
+<rule ref="rulesets/java/naming.xml/SuspiciousConstantFieldName"><priority>1</priority></rule>
100
+<rule ref="rulesets/java/naming.xml/SuspiciousEqualsMethodName"><priority>1</priority></rule>
101
+<rule ref="rulesets/java/naming.xml/NoPackage"><priority>1</priority></rule>
102
+<rule ref="rulesets/java/naming.xml/PackageCase"><priority>1</priority></rule>
103
+
104
+<rule ref="rulesets/java/optimizations.xml/LocalVariableCouldBeFinal"><priority>1</priority><properties><property name="violationSuppressXPath" value="//ForInit|//ForStatement/LocalVariableDeclaration"/></properties></rule>
105
+<rule ref="rulesets/java/optimizations.xml/MethodArgumentCouldBeFinal"><priority>1</priority></rule>
106
+<rule ref="rulesets/java/optimizations.xml/UseArrayListInsteadOfVector"><priority>1</priority></rule>
107
+<rule ref="rulesets/java/optimizations.xml/SimplifyStartsWith"><priority>1</priority></rule>
108
+<rule ref="rulesets/java/optimizations.xml/UseArraysAsList"><priority>1</priority></rule>
109
+<rule ref="rulesets/java/optimizations.xml/AvoidArrayLoops"><priority>1</priority></rule>
110
+<rule ref="rulesets/java/optimizations.xml/UnnecessaryWrapperObjectCreation"><priority>1</priority></rule>
111
+<rule ref="rulesets/java/optimizations.xml/AddEmptyString"><priority>1</priority></rule>
112
+
113
+<rule ref="rulesets/java/strictexception.xml/AvoidCatchingThrowable"><priority>1</priority></rule>
114
+<rule ref="rulesets/java/strictexception.xml/SignatureDeclareThrowsException"><priority>1</priority></rule>
115
+<rule ref="rulesets/java/strictexception.xml/ExceptionAsFlowControl"><priority>1</priority></rule>
116
+<rule ref="rulesets/java/strictexception.xml/AvoidCatchingNPE"><priority>1</priority></rule>
117
+<rule ref="rulesets/java/strictexception.xml/AvoidThrowingRawExceptionTypes"><priority>1</priority></rule>
118
+<rule ref="rulesets/java/strictexception.xml/DoNotExtendJavaLangError"><priority>1</priority></rule>
119
+<rule ref="rulesets/java/strictexception.xml/DoNotThrowExceptionInFinally"><priority>1</priority></rule>
120
+<rule ref="rulesets/java/strictexception.xml/AvoidThrowingNewInstanceOfSameException"><priority>1</priority></rule>
121
+
122
+<rule ref="rulesets/java/strings.xml/StringInstantiation"><priority>1</priority></rule>
123
+<rule ref="rulesets/java/strings.xml/StringToString"><priority>1</priority></rule>
124
+<rule ref="rulesets/java/strings.xml/InefficientStringBuffering"><priority>1</priority></rule>
125
+<rule ref="rulesets/java/strings.xml/UnnecessaryCaseChange"><priority>1</priority></rule>
126
+<rule ref="rulesets/java/strings.xml/UseStringBufferLength"><priority>1</priority></rule>
127
+<rule ref="rulesets/java/strings.xml/AppendCharacterWithChar"><priority>1</priority></rule>
128
+<rule ref="rulesets/java/strings.xml/UseIndexOfChar"><priority>1</priority></rule>
129
+<rule ref="rulesets/java/strings.xml/InefficientEmptyStringCheck"><priority>1</priority></rule>
130
+<rule ref="rulesets/java/strings.xml/UselessStringValueOf"><priority>1</priority></rule>
131
+<rule ref="rulesets/java/strings.xml/StringBufferInstantiationWithChar"><priority>1</priority></rule>
132
+<rule ref="rulesets/java/strings.xml/UseEqualsToCompareStrings"><priority>1</priority></rule>
133
+
134
+<rule ref="rulesets/java/typeresolution.xml/UnusedImports"><priority>1</priority><properties><property name="violationSuppressXPath" value="//ImportDeclaration[@ImportOnDemand='true']"/></properties></rule>
135
+<rule ref="rulesets/java/typeresolution.xml/SignatureDeclareThrowsException"><priority>1</priority></rule>
136
+
137
+<rule ref="rulesets/java/unusedcode.xml/UnusedPrivateField"><priority>1</priority></rule>
138
+<rule ref="rulesets/java/unusedcode.xml/UnusedLocalVariable"><priority>1</priority></rule>
139
+<rule ref="rulesets/java/unusedcode.xml/UnusedPrivateMethod"><priority>1</priority></rule>
140
+<rule ref="rulesets/java/unusedcode.xml/UnusedFormalParameter"><priority>1</priority></rule>
141
+
142
+</ruleset>

+ 1
- 1
lagdisplay/src/com/dmdirc/addons/lagdisplay/LagDisplayManager.java View File

@@ -254,7 +254,7 @@ public class LagDisplayManager implements ConfigChangeListener, SelectionListene
254 254
     }
255 255
 
256 256
     @Handler
257
-    public void HandleServerPingSent(final ServerPingsentEvent event) {
257
+    public void handleServerPingSent(final ServerPingsentEvent event) {
258 258
         if (!event.getConnection().getWindowModel().getConfigManager().
259 259
                 getOptionBool(domain, "usealternate")) {
260 260
             return;

+ 20
- 7
logging/src/com/dmdirc/addons/logging/LoggingManager.java View File

@@ -97,6 +97,8 @@ public class LoggingManager implements ConfigChangeListener {
97 97
     /** Date format used for "File Opened At" log. */
98 98
     private static final DateFormat OPENED_AT_FORMAT = new SimpleDateFormat(
99 99
             "EEEE MMMM dd, yyyy - HH:mm:ss");
100
+    /** Object for synchronising access to the date forma.t */
101
+    private static final Object FORMAT_LOCK = new Object();
100 102
     /** This plugin's plugin info. */
101 103
     private final String domain;
102 104
     /** Global config. */
@@ -220,9 +222,11 @@ public class LoggingManager implements ConfigChangeListener {
220 222
             showBackBuffer(event.getQuery(), filename);
221 223
         }
222 224
 
223
-        appendLine(filename, "*** Query opened at: %s", OPENED_AT_FORMAT.format(new Date()));
224
-        appendLine(filename, "*** Query with User: %s", event.getQuery().getHost());
225
-        appendLine(filename, "");
225
+        synchronized (FORMAT_LOCK) {
226
+            appendLine(filename, "*** Query opened at: %s", OPENED_AT_FORMAT.format(new Date()));
227
+            appendLine(filename, "*** Query with User: %s", event.getQuery().getHost());
228
+            appendLine(filename, "");
229
+        }
226 230
     }
227 231
 
228 232
     @Handler
@@ -230,7 +234,11 @@ public class LoggingManager implements ConfigChangeListener {
230 234
         final Parser parser = event.getQuery().getConnection().getParser();
231 235
         final ClientInfo client = parser.getClient(event.getQuery().getHost());
232 236
         final String filename = getLogFile(client);
233
-        appendLine(filename, "*** Query closed at: %s", OPENED_AT_FORMAT.format(new Date()));
237
+
238
+        synchronized (FORMAT_LOCK) {
239
+            appendLine(filename, "*** Query closed at: %s", OPENED_AT_FORMAT.format(new Date()));
240
+        }
241
+
234 242
         if (openFiles.containsKey(filename)) {
235 243
             StreamUtils.close(openFiles.get(filename).writer);
236 244
             openFiles.remove(filename);
@@ -370,15 +378,20 @@ public class LoggingManager implements ConfigChangeListener {
370 378
             showBackBuffer(event.getChannel(), filename);
371 379
         }
372 380
 
373
-        appendLine(filename, "*** Channel opened at: %s", OPENED_AT_FORMAT.format(new Date()));
374
-        appendLine(filename, "");
381
+        synchronized (FORMAT_LOCK) {
382
+            appendLine(filename, "*** Channel opened at: %s", OPENED_AT_FORMAT.format(new Date()));
383
+            appendLine(filename, "");
384
+        }
375 385
     }
376 386
 
377 387
     @Handler
378 388
     public void handleChannelClosed(final ChannelClosedEvent event) {
379 389
         final String filename = getLogFile(event.getChannel().getName());
380 390
 
381
-        appendLine(filename, "*** Channel closed at: %s", OPENED_AT_FORMAT.format(new Date()));
391
+        synchronized (FORMAT_LOCK) {
392
+            appendLine(filename, "*** Channel closed at: %s", OPENED_AT_FORMAT.format(new Date()));
393
+        }
394
+
382 395
         if (openFiles.containsKey(filename)) {
383 396
             StreamUtils.close(openFiles.get(filename).writer);
384 397
             openFiles.remove(filename);

+ 2
- 2
mediasource_dbus/src/com/dmdirc/addons/mediasource_dbus/MPRISSource.java View File

@@ -208,14 +208,14 @@ public class MPRISSource implements MediaSource {
208 208
                 result.append('0');
209 209
             }
210 210
 
211
-            result.append(hours).append(":");
211
+            result.append(hours).append(':');
212 212
         }
213 213
 
214 214
         if (minutes < 10) {
215 215
             result.append('0');
216 216
         }
217 217
 
218
-        result.append(minutes).append(":");
218
+        result.append(minutes).append(':');
219 219
 
220 220
         if (seconds < 10) {
221 221
             result.append('0');

+ 2
- 2
mediasource_dcop/src/com/dmdirc/addons/mediasource_dcop/KaffeineSource.java View File

@@ -119,14 +119,14 @@ public class KaffeineSource implements MediaSource {
119 119
                 result.append('0');
120 120
             }
121 121
 
122
-            result.append(hours).append(":");
122
+            result.append(hours).append(':');
123 123
         }
124 124
 
125 125
         if (minutes < 10) {
126 126
             result.append('0');
127 127
         }
128 128
 
129
-        result.append(minutes).append(":");
129
+        result.append(minutes).append(':');
130 130
 
131 131
         if (seconds < 10) {
132 132
             result.append('0');

+ 3
- 3
mediasource_dcop/src/com/dmdirc/addons/mediasource_dcop/NoatunSource.java View File

@@ -132,11 +132,11 @@ public class NoatunSource implements MediaSource {
132 132
         final long seconds = secondsInput % 60;
133 133
 
134 134
         if (hours > 0) {
135
-            result.append(hours).append(":");
135
+            result.append(hours).append(':');
136 136
         }
137 137
 
138
-        result.append(minutes).append(":");
139
-        result.append(seconds).append(":");
138
+        result.append(minutes).append(':');
139
+        result.append(seconds).append(':');
140 140
 
141 141
         return result.toString();
142 142
     }

+ 1
- 1
mediasource_windows/src/com/dmdirc/addons/mediasource_windows/DllSource.java View File

@@ -136,7 +136,7 @@ public class DllSource implements MediaSource {
136 136
         final long seconds = (secondsInput % 60);
137 137
 
138 138
         if (hours > 0) {
139
-            result.append(hours).append(":");
139
+            result.append(hours).append(':');
140 140
         }
141 141
         result.append(String.format("%0,2d:%0,2d", minutes, seconds));
142 142
 

+ 2
- 2
ui_swing/src/com/dmdirc/addons/ui_swing/UIUtilities.java View File

@@ -206,7 +206,7 @@ public final class UIUtilities {
206 206
             } catch (InterruptedException ex) {
207 207
                 //Ignore
208 208
             } catch (InvocationTargetException ex) {
209
-                throw new RuntimeException(ex);
209
+                throw new RuntimeException(ex); // NOPMD
210 210
             }
211 211
         }
212 212
     }
@@ -229,7 +229,7 @@ public final class UIUtilities {
229 229
                 return task.get();
230 230
             }
231 231
         } catch (Exception ex) {
232
-            throw new RuntimeException(ex);
232
+            throw new RuntimeException(ex); // NOPMD
233 233
         }
234 234
     }
235 235
 

+ 1
- 1
ui_swing/src/com/dmdirc/addons/ui_swing/components/NickList.java View File

@@ -164,7 +164,7 @@ public class NickList extends JScrollPane implements ConfigChangeListener,
164 164
 
165 165
             for (ChannelClientInfo value : values) {
166 166
                 if (builder.length() > 0) {
167
-                    builder.append("\n");
167
+                    builder.append('\n');
168 168
                 }
169 169
 
170 170
                 builder.append(value.getClient().getNickname());

+ 17
- 22
ui_swing/src/com/dmdirc/addons/ui_swing/components/SwingSearchBar.java View File

@@ -68,8 +68,6 @@ public final class SwingSearchBar extends JPanel implements ActionListener,
68 68
     private final TextFrame parent;
69 69
     /** Colour Manager. */
70 70
     private final ColourManager colourManager;
71
-    /** Config to read from. */
72
-    private final AggregateConfigProvider config;
73 71
     /** Close button. */
74 72
     private ImageButton<Object> closeButton;
75 73
     /** Next match button. */
@@ -101,7 +99,6 @@ public final class SwingSearchBar extends JPanel implements ActionListener,
101 99
         listeners = new ListenerList();
102 100
 
103 101
         this.parent = newParent;
104
-        this.config = parent.getContainer().getConfigManager();
105 102
         this.colourManager = colourManager;
106 103
 
107 104
         getInputMap(JComponent.WHEN_FOCUSED).
@@ -247,25 +244,23 @@ public final class SwingSearchBar extends JPanel implements ActionListener,
247 244
         final LinePosition result = up ? searcher.searchUp() : searcher.
248 245
                 searchDown();
249 246
 
250
-        if (result == null) {
251
-            //Do nothing
252
-        } else if ((textPane.getSelectedRange().getEndLine() != 0 || textPane.
253
-                getSelectedRange().getEndPos() != 0)
254
-                && ((up && result.getEndLine() > textPane.getSelectedRange().
255
-                getEndLine())
256
-                || (!up && result.getStartLine() < textPane.getSelectedRange().
257
-                getStartLine()))) {
258
-            wrapIndicator.setVisible(true);
259
-            textPane.setScrollBarPosition(result.getEndLine());
260
-            textPane.setSelectedText(result);
261
-            validator.setValidates(true);
262
-            searchBox.checkError();
263
-        } else {
264
-            //found, select and return found
265
-            textPane.setScrollBarPosition(result.getEndLine());
266
-            textPane.setSelectedText(result);
267
-            validator.setValidates(true);
268
-            searchBox.checkError();
247
+        if (result != null) {
248
+            if ((textPane.getSelectedRange().getEndLine() != 0 || textPane.
249
+                    getSelectedRange().getEndPos() != 0)
250
+                    && (up && result.getEndLine() > textPane.getSelectedRange().getEndLine()
251
+                    || !up && result.getStartLine() < textPane.getSelectedRange().getStartLine())) {
252
+                wrapIndicator.setVisible(true);
253
+                textPane.setScrollBarPosition(result.getEndLine());
254
+                textPane.setSelectedText(result);
255
+                validator.setValidates(true);
256
+                searchBox.checkError();
257
+            } else {
258
+                //found, select and return found
259
+                textPane.setScrollBarPosition(result.getEndLine());
260
+                textPane.setSelectedText(result);
261
+                validator.setValidates(true);
262
+                searchBox.checkError();
263
+            }
269 264
         }
270 265
     }
271 266
 

+ 1
- 1
ui_swing/src/com/dmdirc/addons/ui_swing/components/menubar/MenuBar.java View File

@@ -52,7 +52,7 @@ public class MenuBar extends JMenuBar {
52 52
     /** Normal menu count. */
53 53
     private final int menuItemCount;
54 54
     /** Stores a list of tokens used to remove added menu items. */
55
-    private final Map<String, JMenuItem> menuItems;
55
+    private final Map<String, JMenuItem> menuItems; // NOPMD
56 56
 
57 57
     /**
58 58
      * Instantiates a new menu bar.

+ 2
- 2
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionDisplayPanel.java View File

@@ -234,7 +234,7 @@ public class ActionConditionDisplayPanel extends JPanel implements
234 234
             }
235 235
 
236 236
             sb.append(condition.getComponent().getName());
237
-            sb.append(" ");
237
+            sb.append(' ');
238 238
 
239 239
             if (condition.getComparison() == null) {
240 240
                 sb.append(" ...");
@@ -250,7 +250,7 @@ public class ActionConditionDisplayPanel extends JPanel implements
250 250
             }
251 251
 
252 252
             sb.append(condition.getTarget().replace("<", "&lt;"));
253
-            sb.append("'");
253
+            sb.append('\'');
254 254
             return sb.toString();
255 255
         }
256 256
     }

+ 2
- 2
ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/AddNicknameValidatorTest.java View File

@@ -41,7 +41,7 @@ public class AddNicknameValidatorTest {
41 41
         final ProfileManagerModel model = mock(ProfileManagerModel.class);
42 42
         when(model.getNicknames()).thenReturn(Arrays.asList(
43 43
                 new String[]{"nickname1", "nickname2",}));
44
-        AddNicknameValidator instance = new AddNicknameValidator(model);
44
+        final AddNicknameValidator instance = new AddNicknameValidator(model);
45 45
         assertTrue(instance.validate("nickname1").isFailure());
46 46
     }
47 47
 
@@ -53,7 +53,7 @@ public class AddNicknameValidatorTest {
53 53
         final ProfileManagerModel model = mock(ProfileManagerModel.class);
54 54
         when(model.getNicknames()).thenReturn(Arrays.asList(
55 55
                 new String[]{"nickname1", "nickname2",}));
56
-        AddNicknameValidator instance = new AddNicknameValidator(model);
56
+        final AddNicknameValidator instance = new AddNicknameValidator(model);
57 57
         assertFalse(instance.validate("nickname").isFailure());
58 58
     }
59 59
 }

+ 3
- 3
ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/EditNicknameValidatorTest.java View File

@@ -42,7 +42,7 @@ public class EditNicknameValidatorTest {
42 42
         when(model.getSelectedNickname()).thenReturn(null);
43 43
         when(model.getNicknames()).thenReturn(Arrays.asList(
44 44
                 new String[]{"nickname1", "nickname2",}));
45
-        EditNicknameValidator instance = new EditNicknameValidator(model);
45
+        final EditNicknameValidator instance = new EditNicknameValidator(model);
46 46
         assertFalse(instance.validate("nickname").isFailure());
47 47
     }
48 48
 
@@ -55,7 +55,7 @@ public class EditNicknameValidatorTest {
55 55
         when(model.getSelectedNickname()).thenReturn("nickname");
56 56
         when(model.getNicknames()).thenReturn(Arrays.asList(
57 57
                 new String[]{"nickname1", "nickname2",}));
58
-        EditNicknameValidator instance = new EditNicknameValidator(model);
58
+        final EditNicknameValidator instance = new EditNicknameValidator(model);
59 59
         assertFalse(instance.validate("nickname").isFailure());
60 60
     }
61 61
 
@@ -68,7 +68,7 @@ public class EditNicknameValidatorTest {
68 68
         when(model.getSelectedNickname()).thenReturn("nickname");
69 69
         when(model.getNicknames()).thenReturn(Arrays.asList(
70 70
                 new String[]{"nickname1", "nickname2",}));
71
-        EditNicknameValidator instance = new EditNicknameValidator(model);
71
+        final EditNicknameValidator instance = new EditNicknameValidator(model);
72 72
         assertFalse(instance.validate("nickname3").isFailure());
73 73
     }
74 74
 }

+ 54
- 55
ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerModelTest.java View File

@@ -70,8 +70,7 @@ public class ProfileManagerModelTest {
70 70
         when(configProvider.getOption("profile", "realname")).thenReturn(prefix + "realname");
71 71
         when(configProvider.getOption("profile", "ident")).thenReturn(prefix + "ident");
72 72
 
73
-        final Profile profile = new Profile(identityFactory, configProvider);
74
-        return profile;
73
+        return new Profile(identityFactory, configProvider);
75 74
     }
76 75
 
77 76
     private ProfileManagerModel createModel() {
@@ -82,7 +81,7 @@ public class ProfileManagerModelTest {
82 81
     }
83 82
 
84 83
     @Before
85
-    public void setup() throws Exception {
84
+    public void setup() {
86 85
         final List<ConfigProvider> identities = Collections.emptyList();
87 86
         manager = mock(IdentityController.class);
88 87
         when(manager.getProvidersByType("profile")).thenReturn(identities);
@@ -106,7 +105,7 @@ public class ProfileManagerModelTest {
106 105
         final IdentityController im = mock(IdentityController.class);
107 106
         when(im.getProvidersByType("profile")).thenReturn(identities);
108 107
 
109
-        ProfileManagerModel instance = new ProfileManagerModel(im, identityFactory);
108
+        final ProfileManagerModel instance = new ProfileManagerModel(im, identityFactory);
110 109
         instance.load();
111 110
 
112 111
         assertEquals(Arrays.asList(new Profile[]{new Profile(identityFactory, configProvider), }), instance.getProfiles());
@@ -119,7 +118,7 @@ public class ProfileManagerModelTest {
119 118
     public void testGetAndSetProfiles() {
120 119
         final List<Profile> newProfiles = Arrays.asList(
121 120
                 new Profile[]{createProfile("2"),});
122
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
121
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
123 122
         assertEquals(Collections.emptyList(), instance.getProfiles());
124 123
         instance.setProfiles(newProfiles);
125 124
         assertEquals(newProfiles, instance.getProfiles());
@@ -131,7 +130,7 @@ public class ProfileManagerModelTest {
131 130
     @Test
132 131
     public void testAddProfiles() {
133 132
         final Profile newProfile = createProfile("2");
134
-        ProfileManagerModel instance = createModel();
133
+        final ProfileManagerModel instance = createModel();
135 134
         assertEquals(Arrays.asList(new Profile[]{defaultProfile,}), instance.getProfiles());
136 135
         final List<Profile> newProfiles = new ArrayList<>();
137 136
         newProfiles.add(defaultProfile);
@@ -146,7 +145,7 @@ public class ProfileManagerModelTest {
146 145
     @Test
147 146
     public void testDeleteProfileNullProfile() {
148 147
         final Profile first = createProfile("1");
149
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
148
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
150 149
         instance.addProfile(first);
151 150
         instance.setSelectedProfile(first);
152 151
         assertEquals(first, instance.getSelectedProfile());
@@ -161,7 +160,7 @@ public class ProfileManagerModelTest {
161 160
     public void testDeleteProfileNotSelected() {
162 161
         final Profile first = createProfile("1");
163 162
         final Profile second = createProfile("2");
164
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
163
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
165 164
         instance.addProfile(first);
166 165
         instance.addProfile(second);
167 166
         instance.setSelectedProfile(second);
@@ -177,7 +176,7 @@ public class ProfileManagerModelTest {
177 176
     public void testDeleteProfileLastProfile() {
178 177
         final Profile first = createProfile("1");
179 178
         final Profile second = createProfile("2");
180
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
179
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
181 180
         instance.addProfile(first);
182 181
         instance.addProfile(second);
183 182
         instance.setSelectedProfile(second);
@@ -193,7 +192,7 @@ public class ProfileManagerModelTest {
193 192
     public void testDeleteProfileFirstProfile() {
194 193
         final Profile first = createProfile("1");
195 194
         final Profile second = createProfile("2");
196
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
195
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
197 196
         instance.addProfile(first);
198 197
         instance.addProfile(second);
199 198
         instance.setSelectedProfile(first);
@@ -210,7 +209,7 @@ public class ProfileManagerModelTest {
210 209
         final Profile first = createProfile("1");
211 210
         final Profile second = createProfile("2");
212 211
         final Profile third = createProfile("3");
213
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
212
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
214 213
         instance.addProfile(first);
215 214
         instance.addProfile(second);
216 215
         instance.addProfile(third);
@@ -226,7 +225,7 @@ public class ProfileManagerModelTest {
226 225
     @Test
227 226
     public void testDeleteProfileOnlyProfile() {
228 227
         final Profile first = createProfile("1");
229
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
228
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
230 229
         instance.addProfile(first);
231 230
         instance.setSelectedProfile(first);
232 231
         assertEquals(first, instance.getSelectedProfile());
@@ -239,10 +238,10 @@ public class ProfileManagerModelTest {
239 238
      */
240 239
     @Test
241 240
     public void testGetAndSetSelectedProfile() {
242
-        Profile profile2 = createProfile("2");
243
-        Profile profile3 = createProfile("3");
244
-        Profile profile4 = createProfile("4");
245
-        ProfileManagerModel instance = createModel();
241
+        final Profile profile2 = createProfile("2");
242
+        final Profile profile3 = createProfile("3");
243
+        final Profile profile4 = createProfile("4");
244
+        final ProfileManagerModel instance = createModel();
246 245
         assertEquals(defaultProfile, instance.getSelectedProfile());
247 246
         instance.addProfile(profile2);
248 247
         assertEquals(profile2, instance.getSelectedProfile());
@@ -258,7 +257,7 @@ public class ProfileManagerModelTest {
258 257
      */
259 258
     @Test
260 259
     public void testGetAndSetNicknames() {
261
-        ProfileManagerModel instance = createModel();
260
+        final ProfileManagerModel instance = createModel();
262 261
         final List<String> expResult = defaultProfile.getNicknames();
263 262
         List<String> result = instance.getNicknames();
264 263
         assertEquals(expResult, result);
@@ -272,8 +271,8 @@ public class ProfileManagerModelTest {
272 271
      */
273 272
     @Test
274 273
     public void testAddNickname() {
275
-        String nickname = "foo";
276
-        ProfileManagerModel instance = createModel();
274
+        final String nickname = "foo";
275
+        final ProfileManagerModel instance = createModel();
277 276
         assertEquals(defaultProfile.getNicknames(), instance.getNicknames());
278 277
         final List<String> nicknames = new ArrayList<>(defaultProfile.getNicknames());
279 278
         instance.addNickname(nickname);
@@ -286,7 +285,7 @@ public class ProfileManagerModelTest {
286 285
      */
287 286
     @Test
288 287
     public void testDeleteNicknameObject() {
289
-        ProfileManagerModel instance = createModel();
288
+        final ProfileManagerModel instance = createModel();
290 289
         final List<String> nicknames = new ArrayList<>(instance.getNicknames());
291 290
         Object nickname = (Object) "";
292 291
         assertEquals(nicknames, instance.getNicknames());
@@ -303,7 +302,7 @@ public class ProfileManagerModelTest {
303 302
      */
304 303
     @Test
305 304
     public void testDeleteNicknameNullSelectedProfile() {
306
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
305
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
307 306
         assertNull(instance.getSelectedProfile());
308 307
         assertTrue(instance.getNicknames().isEmpty());
309 308
         instance.deleteNickname("1nickname");
@@ -316,7 +315,7 @@ public class ProfileManagerModelTest {
316 315
     public void testDeleteNicknameNullNickname() {
317 316
         final Profile profile = createProfile("1");
318 317
         final String first = "1nickname";
319
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
318
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
320 319
         instance.addProfile(profile);
321 320
         instance.setSelectedProfile(profile);
322 321
         instance.setSelectedNickname(first);
@@ -333,7 +332,7 @@ public class ProfileManagerModelTest {
333 332
         final Profile profile = createProfile("1");
334 333
         final String first = "1nickname";
335 334
         final String second = "1nickname2";
336
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
335
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
337 336
         instance.addProfile(profile);
338 337
         instance.setSelectedProfile(profile);
339 338
         instance.addNickname(second);
@@ -351,7 +350,7 @@ public class ProfileManagerModelTest {
351 350
         final Profile profile = createProfile("1");
352 351
         final String first = "1nickname";
353 352
         final String second = "1nickname2";
354
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
353
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
355 354
         instance.addProfile(profile);
356 355
         instance.setSelectedProfile(profile);
357 356
         instance.addNickname(second);
@@ -369,7 +368,7 @@ public class ProfileManagerModelTest {
369 368
         final Profile profile = createProfile("1");
370 369
         final String first = "1nickname";
371 370
         final String second = "1nickname2";
372
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
371
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
373 372
         instance.addProfile(profile);
374 373
         instance.setSelectedProfile(profile);
375 374
         instance.addNickname(second);
@@ -388,7 +387,7 @@ public class ProfileManagerModelTest {
388 387
         final String first = "1nickname";
389 388
         final String second = "1nickname2";
390 389
         final String third = "1nickname3";
391
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
390
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
392 391
         instance.addProfile(profile);
393 392
         instance.setSelectedProfile(profile);
394 393
         instance.addNickname(second);
@@ -406,7 +405,7 @@ public class ProfileManagerModelTest {
406 405
     public void testDeleteNicknameOnlyNickname() {
407 406
         final Profile profile = createProfile("1");
408 407
         final String first = "1nickname";
409
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
408
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
410 409
         instance.addProfile(profile);
411 410
         instance.setSelectedProfile(profile);
412 411
         instance.setSelectedNickname(first);
@@ -421,7 +420,7 @@ public class ProfileManagerModelTest {
421 420
     @Test
422 421
     public void testGetAndSetSelectedNickname() {
423 422
         final String selectedNickname = "1nickname";
424
-        ProfileManagerModel instance = createModel();
423
+        final ProfileManagerModel instance = createModel();
425 424
         assertNull(instance.getSelectedNickname());
426 425
         instance.setSelectedNickname(selectedNickname);
427 426
         assertEquals(selectedNickname, instance.getSelectedNickname());
@@ -434,7 +433,7 @@ public class ProfileManagerModelTest {
434 433
      */
435 434
     @Test
436 435
     public void testEditNickname() {
437
-        ProfileManagerModel instance = createModel();
436
+        final ProfileManagerModel instance = createModel();
438 437
         final List<String> nicknames = new ArrayList<>(instance.getNicknames());
439 438
         final String nickname = nicknames.get(0);
440 439
         assertEquals(nicknames, instance.getNicknames());
@@ -450,7 +449,7 @@ public class ProfileManagerModelTest {
450 449
      */
451 450
     @Test
452 451
     public void testGetAndSetName() {
453
-        ProfileManagerModel instance = createModel();
452
+        final ProfileManagerModel instance = createModel();
454 453
         final String name = defaultProfile.getName();
455 454
         final String newName = "foo";
456 455
         assertEquals(name, instance.getName());
@@ -463,7 +462,7 @@ public class ProfileManagerModelTest {
463 462
      */
464 463
     @Test
465 464
     public void testGetAndSetRealname() {
466
-        ProfileManagerModel instance = createModel();
465
+        final ProfileManagerModel instance = createModel();
467 466
         final String name = "1realname";
468 467
         final String newName = "foo";
469 468
         assertEquals(name, instance.getRealname());
@@ -476,7 +475,7 @@ public class ProfileManagerModelTest {
476 475
      */
477 476
     @Test
478 477
     public void testGetAndSetIdent() {
479
-        ProfileManagerModel instance = createModel();
478
+        final ProfileManagerModel instance = createModel();
480 479
         final String name = "1ident";
481 480
         final String newName = "foo";
482 481
         assertEquals(name, instance.getIdent());
@@ -489,7 +488,7 @@ public class ProfileManagerModelTest {
489 488
      */
490 489
     @Test
491 490
     public void testIsManipulateProfileAllowed() {
492
-        ProfileManagerModel instance = createModel();
491
+        final ProfileManagerModel instance = createModel();
493 492
         assertTrue(instance.isManipulateProfileAllowed());
494 493
         instance.setProfiles(Arrays.asList(new Profile[]{}));
495 494
         assertFalse(instance.isManipulateProfileAllowed());
@@ -500,7 +499,7 @@ public class ProfileManagerModelTest {
500 499
      */
501 500
     @Test
502 501
     public void testIsManipulateNicknameAllowed() {
503
-        ProfileManagerModel instance = createModel();
502
+        final ProfileManagerModel instance = createModel();
504 503
         assertFalse(instance.isManipulateNicknameAllowed());
505 504
         instance.setSelectedNickname("1nickname");
506 505
         assertTrue(instance.isManipulateNicknameAllowed());
@@ -512,7 +511,7 @@ public class ProfileManagerModelTest {
512 511
         profile.setName("*");
513 512
         profile.setRealname("");
514 513
         profile.setIdent("*");
515
-        ProfileManagerModel instance = createModel();
514
+        final ProfileManagerModel instance = createModel();
516 515
         assertTrue(instance.isChangeProfileAllowed());
517 516
         instance.setProfiles(Arrays.asList(new Profile[]{profile,}));
518 517
         assertFalse(instance.isChangeProfileAllowed());
@@ -535,7 +534,7 @@ public class ProfileManagerModelTest {
535 534
         profile.setName("*");
536 535
         profile.setRealname("");
537 536
         profile.setIdent("*");
538
-        ProfileManagerModel instance = createModel();
537
+        final ProfileManagerModel instance = createModel();
539 538
         assertTrue(instance.isOKAllowed());
540 539
         instance.setProfiles(Arrays.asList(new Profile[]{}));
541 540
         assertFalse(instance.isOKAllowed());
@@ -556,7 +555,7 @@ public class ProfileManagerModelTest {
556 555
      */
557 556
     @Test
558 557
     public void testIsNameInValid() {
559
-        ProfileManagerModel instance = createModel();
558
+        final ProfileManagerModel instance = createModel();
560 559
         instance.setProfiles(Arrays.asList(defaultProfile));
561 560
         instance.setName("\\");
562 561
         assertTrue(instance.isNameValid().isFailure());
@@ -567,7 +566,7 @@ public class ProfileManagerModelTest {
567 566
      */
568 567
     @Test
569 568
     public void testIsNameValid() {
570
-        ProfileManagerModel instance = createModel();
569
+        final ProfileManagerModel instance = createModel();
571 570
         instance.setProfiles(Arrays.asList(defaultProfile));
572 571
         instance.setName("profile");
573 572
         assertFalse(instance.isNameValid().isFailure());
@@ -578,7 +577,7 @@ public class ProfileManagerModelTest {
578 577
      */
579 578
     @Test
580 579
     public void testIsNicknamesInValid() {
581
-        ProfileManagerModel instance = createModel();
580
+        final ProfileManagerModel instance = createModel();
582 581
         instance.setProfiles(Arrays.asList(defaultProfile));
583 582
         instance.setNicknames(Arrays.asList(new String[]{}));
584 583
         assertTrue(instance.isNicknamesValid().isFailure());
@@ -589,7 +588,7 @@ public class ProfileManagerModelTest {
589 588
      */
590 589
     @Test
591 590
     public void testIsNicknamesValid() {
592
-        ProfileManagerModel instance = createModel();
591
+        final ProfileManagerModel instance = createModel();
593 592
         instance.setProfiles(Arrays.asList(defaultProfile));
594 593
         instance.setNicknames(Arrays.asList(new String[]{"nickname"}));
595 594
         assertFalse(instance.isNicknamesValid().isFailure());
@@ -600,7 +599,7 @@ public class ProfileManagerModelTest {
600 599
      */
601 600
     @Test
602 601
     public void testIsRealnameInValid() {
603
-        ProfileManagerModel instance = createModel();
602
+        final ProfileManagerModel instance = createModel();
604 603
         instance.setProfiles(Arrays.asList(defaultProfile));
605 604
         instance.setRealname("");
606 605
         assertTrue(instance.isRealnameValid().isFailure());
@@ -611,7 +610,7 @@ public class ProfileManagerModelTest {
611 610
      */
612 611
     @Test
613 612
     public void testIsRealnameValid() {
614
-        ProfileManagerModel instance = createModel();
613
+        final ProfileManagerModel instance = createModel();
615 614
         instance.setProfiles(Arrays.asList(defaultProfile));
616 615
         instance.setRealname("realname");
617 616
         assertFalse(instance.isRealnameValid().isFailure());
@@ -622,7 +621,7 @@ public class ProfileManagerModelTest {
622 621
      */
623 622
     @Test
624 623
     public void testIsIdentInValid() {
625
-        ProfileManagerModel instance = createModel();
624
+        final ProfileManagerModel instance = createModel();
626 625
         instance.setProfiles(Arrays.asList(defaultProfile));
627 626
         instance.setIdent("*");
628 627
         assertTrue(instance.isIdentValid().isFailure());
@@ -633,7 +632,7 @@ public class ProfileManagerModelTest {
633 632
      */
634 633
     @Test
635 634
     public void testIsIdentValid() {
636
-        ProfileManagerModel instance = createModel();
635
+        final ProfileManagerModel instance = createModel();
637 636
         instance.setProfiles(Arrays.asList(defaultProfile));
638 637
         instance.setIdent("ident");
639 638
         assertFalse(instance.isIdentValid().isFailure());
@@ -644,7 +643,7 @@ public class ProfileManagerModelTest {
644 643
      */
645 644
     @Test
646 645
     public void testIsIdentValidEmptyString() {
647
-        ProfileManagerModel instance = createModel();
646
+        final ProfileManagerModel instance = createModel();
648 647
         instance.setProfiles(Arrays.asList(defaultProfile));
649 648
         instance.setIdent("");
650 649
         assertFalse(instance.isIdentValid().isFailure());
@@ -655,7 +654,7 @@ public class ProfileManagerModelTest {
655 654
      */
656 655
     @Test
657 656
     public void testNullSelectedProfileGetters() {
658
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
657
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
659 658
         assertTrue("".equals(instance.getSelectedNickname()));
660 659
         assertTrue("".equals(instance.getName()));
661 660
         assertTrue("".equals(instance.getRealname()));
@@ -668,7 +667,7 @@ public class ProfileManagerModelTest {
668 667
      */
669 668
     @Test
670 669
     public void testNullSelectedProfileValidators() {
671
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
670
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
672 671
         assertFalse(instance.isNameValid().isFailure());
673 672
         assertFalse(instance.isNicknamesValid().isFailure());
674 673
         assertFalse(instance.isRealnameValid().isFailure());
@@ -681,7 +680,7 @@ public class ProfileManagerModelTest {
681 680
     @Test
682 681
     public void testNullSelectedProfileSetSelectedNickname() {
683 682
         final String test = "test";
684
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
683
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
685 684
         assertTrue("".equals(instance.getSelectedNickname()));
686 685
         instance.setSelectedNickname(test);
687 686
         assertTrue("".equals(instance.getSelectedNickname()));
@@ -693,7 +692,7 @@ public class ProfileManagerModelTest {
693 692
     @Test
694 693
     public void testNullSelectedProfileSetName() {
695 694
         final String test = "test";
696
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
695
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
697 696
         assertTrue("".equals(instance.getName()));
698 697
         instance.setName(test);
699 698
         assertTrue("".equals(instance.getName()));
@@ -705,7 +704,7 @@ public class ProfileManagerModelTest {
705 704
     @Test
706 705
     public void testNullSelectedProfileSetRealname() {
707 706
         final String test = "test";
708
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
707
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
709 708
         assertTrue("".equals(instance.getRealname()));
710 709
         instance.setRealname(test);
711 710
         assertTrue("".equals(instance.getRealname()));
@@ -717,7 +716,7 @@ public class ProfileManagerModelTest {
717 716
     @Test
718 717
     public void testNullSelectedProfileSetIdent() {
719 718
         final String test = "test";
720
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
719
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
721 720
         assertTrue("".equals(instance.getIdent()));
722 721
         instance.setIdent(test);
723 722
         assertTrue("".equals(instance.getIdent()));
@@ -729,7 +728,7 @@ public class ProfileManagerModelTest {
729 728
     @Test
730 729
     public void testNullSelectedProfileSetNicknames() {
731 730
         final String test = "test";
732
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
731
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
733 732
         assertTrue(instance.getNicknames().isEmpty());
734 733
         instance.setNicknames(Arrays.asList(new String[]{test, }));
735 734
         assertTrue(instance.getNicknames().isEmpty());
@@ -741,7 +740,7 @@ public class ProfileManagerModelTest {
741 740
     @Test
742 741
     public void testNullSelectedProfileAddNickname() {
743 742
         final String test = "test";
744
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
743
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
745 744
         assertTrue(instance.getNicknames().isEmpty());
746 745
         instance.addNickname(test);
747 746
         assertTrue(instance.getNicknames().isEmpty());
@@ -753,7 +752,7 @@ public class ProfileManagerModelTest {
753 752
     @Test
754 753
     public void testNullSelectedProfileDeleteNickname() {
755 754
         final String test = "test";
756
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
755
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
757 756
         assertTrue(instance.getNicknames().isEmpty());
758 757
         instance.deleteNickname(test);
759 758
         assertTrue(instance.getNicknames().isEmpty());
@@ -770,7 +769,7 @@ public class ProfileManagerModelTest {
770 769
         final Profile second = mock(Profile.class);
771 770
         when(first.isDeleted()).thenReturn(false);
772 771
         when(second.isDeleted()).thenReturn(true);
773
-        ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
772
+        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
774 773
         instance.setProfiles(Arrays.asList(new Profile[]{first, second, }));
775 774
         instance.save();
776 775
         verify(first).save();

+ 3
- 3
ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileNameValidatorTest.java View File

@@ -63,7 +63,7 @@ public class ProfileNameValidatorTest {
63 63
      */
64 64
     @Test
65 65
     public void testValidateNoDupes() {
66
-        ProfileRenameValidator instance = new ProfileRenameValidator(model);
66
+        final ProfileRenameValidator instance = new ProfileRenameValidator(model);
67 67
         assertFalse(instance.validate("Random").isFailure());
68 68
     }
69 69
 
@@ -72,7 +72,7 @@ public class ProfileNameValidatorTest {
72 72
      */
73 73
     @Test
74 74
     public void testValidateNonSelectedDupe() {
75
-        ProfileRenameValidator instance = new ProfileRenameValidator(model);
75
+        final ProfileRenameValidator instance = new ProfileRenameValidator(model);
76 76
         assertTrue(instance.validate("other").isFailure());
77 77
     }
78 78
 
@@ -81,7 +81,7 @@ public class ProfileNameValidatorTest {
81 81
      */
82 82
     @Test
83 83
     public void testValidateSelectedDupe() {
84
-        ProfileRenameValidator instance = new ProfileRenameValidator(model);
84
+        final ProfileRenameValidator instance = new ProfileRenameValidator(model);
85 85
         assertFalse(instance.validate("selected").isFailure());
86 86
     }
87 87
 }

Loading…
Cancel
Save