Skip to content

Commit 8969023

Browse files
committed
Merge pull request #30 from DevFactory/release/Useless-parentheses-around-expressions
Fixing squid:UselessParenthesesCheck - Useless parentheses around expressions should be removed to prevent any misunderstanding
2 parents 160af9a + 2dcab93 commit 8969023

11 files changed

+30
-30
lines changed

src/main/java/org/audit4j/core/ValidationManager.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static boolean isSerializable(Object object) {
9696
} else {
9797
retVal = false;
9898
}
99-
return (retVal);
99+
return retVal;
100100
}
101101

102102
/**
@@ -108,8 +108,8 @@ static boolean isSerializable(Object object) {
108108
*/
109109
private static boolean implementsInterface(final Object o) {
110110
final boolean retVal;
111-
retVal = ((o instanceof Serializable) || (o instanceof Externalizable));
112-
return (retVal);
111+
retVal = (o instanceof Serializable) || (o instanceof Externalizable);
112+
return retVal;
113113
}
114114

115115
/**
@@ -131,7 +131,7 @@ private static boolean attemptToSerialize(final Object o) {
131131
stream.writeObject(o);
132132
// could also re-serilalize at this point too
133133
} catch (final IOException ex) {
134-
return (false);
134+
return false;
135135
} finally {
136136
if (stream != null) {
137137
try {
@@ -142,7 +142,7 @@ private static boolean attemptToSerialize(final Object o) {
142142
}
143143
}
144144

145-
return (true);
145+
return true;
146146
}
147147

148148
public static void main(String[] args) {

src/main/java/org/audit4j/core/schedule/ConcurrentTaskScheduler.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ public ConcurrentTaskScheduler(Executor concurrentExecutor, ScheduledExecutorSer
141141
public final void setScheduledExecutor(ScheduledExecutorService scheduledExecutor) {
142142
if (scheduledExecutor != null) {
143143
this.scheduledExecutor = scheduledExecutor;
144-
this.enterpriseConcurrentScheduler = (managedScheduledExecutorServiceClass != null && managedScheduledExecutorServiceClass
145-
.isInstance(scheduledExecutor));
144+
this.enterpriseConcurrentScheduler = managedScheduledExecutorServiceClass != null && managedScheduledExecutorServiceClass
145+
.isInstance(scheduledExecutor);
146146
} else {
147147
this.scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
148148
this.enterpriseConcurrentScheduler = false;
@@ -173,8 +173,8 @@ public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
173173
if (this.enterpriseConcurrentScheduler) {
174174
return new EnterpriseConcurrentTriggerScheduler().schedule(decorateTask(task, true), trigger);
175175
} else {
176-
ErrorHandler errorHandler = (this.errorHandler != null ? this.errorHandler : TaskUtils
177-
.getDefaultErrorHandler(true));
176+
ErrorHandler errorHandler = this.errorHandler != null ? this.errorHandler : TaskUtils
177+
.getDefaultErrorHandler(true);
178178
return new ReschedulingRunnable(task, trigger, this.scheduledExecutor, errorHandler).schedule();
179179
}
180180
} catch (RejectedExecutionException ex) {

src/main/java/org/audit4j/core/schedule/CronTrigger.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public String getExpression() {
8383
*/
8484
@Override
8585
public boolean equals(Object obj) {
86-
return (this == obj || (obj instanceof CronTrigger && this.sequenceGenerator
87-
.equals(((CronTrigger) obj).sequenceGenerator)));
86+
return this == obj || (obj instanceof CronTrigger && this.sequenceGenerator
87+
.equals(((CronTrigger) obj).sequenceGenerator));
8888
}
8989

9090
/**

src/main/java/org/audit4j/core/schedule/PeriodicTrigger.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public PeriodicTrigger(long period) {
5757
*/
5858
public PeriodicTrigger(long period, TimeUnit timeUnit) {
5959
//Assert.isTrue(period >= 0, "period must not be negative");
60-
this.timeUnit = (timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS);
60+
this.timeUnit = timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS;
6161
this.period = this.timeUnit.toMillis(period);
6262
}
6363

@@ -114,7 +114,7 @@ public boolean equals(Object obj) {
114114
return false;
115115
}
116116
PeriodicTrigger other = (PeriodicTrigger) obj;
117-
return (this.fixedRate == other.fixedRate && this.initialDelay == other.initialDelay && this.period == other.period);
117+
return this.fixedRate == other.fixedRate && this.initialDelay == other.initialDelay && this.period == other.period;
118118
}
119119

120120
/**

src/main/java/org/audit4j/core/schedule/ReschedulingRunnable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,6 @@ public int compareTo(Delayed other) {
190190
return 0;
191191
}
192192
long diff = getDelay(TimeUnit.MILLISECONDS) - other.getDelay(TimeUnit.MILLISECONDS);
193-
return (diff == 0 ? 0 : ((diff < 0) ? -1 : 1));
193+
return diff == 0 ? 0 : (diff < 0) ? -1 : 1;
194194
}
195195
}

src/main/java/org/audit4j/core/schedule/TaskUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static DelegatingErrorHandlingRunnable decorateTaskWithErrorHandler(Runna
5555
if (task instanceof DelegatingErrorHandlingRunnable) {
5656
return (DelegatingErrorHandlingRunnable) task;
5757
}
58-
ErrorHandler eh = (errorHandler != null ? errorHandler : getDefaultErrorHandler(isRepeatingTask));
58+
ErrorHandler eh = errorHandler != null ? errorHandler : getDefaultErrorHandler(isRepeatingTask);
5959
return new DelegatingErrorHandlingRunnable(task, eh);
6060
}
6161

@@ -69,7 +69,7 @@ public static DelegatingErrorHandlingRunnable decorateTaskWithErrorHandler(Runna
6969
* @return the default error handler
7070
*/
7171
public static ErrorHandler getDefaultErrorHandler(boolean isRepeatingTask) {
72-
return (isRepeatingTask ? LOG_AND_SUPPRESS_ERROR_HANDLER : LOG_AND_PROPAGATE_ERROR_HANDLER);
72+
return isRepeatingTask ? LOG_AND_SUPPRESS_ERROR_HANDLER : LOG_AND_PROPAGATE_ERROR_HANDLER;
7373
}
7474

7575
/**

src/main/java/org/audit4j/core/schedule/ThreadPoolTaskScheduler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ public boolean prefersShortLivedTasks() {
304304
public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
305305
ScheduledExecutorService executor = getScheduledExecutor();
306306
try {
307-
ErrorHandler errorHandler = (this.errorHandler != null ? this.errorHandler : TaskUtils
308-
.getDefaultErrorHandler(true));
307+
ErrorHandler errorHandler = this.errorHandler != null ? this.errorHandler : TaskUtils
308+
.getDefaultErrorHandler(true);
309309
return new ReschedulingRunnable(task, trigger, executor, errorHandler).schedule();
310310
} catch (RejectedExecutionException ex) {
311311
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);

src/main/java/org/audit4j/core/schedule/util/ClassUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private ClassUtils(){
2929
* @see Class#getMethod
3030
*/
3131
public static boolean hasMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) {
32-
return (getMethodIfAvailable(clazz, methodName, paramTypes) != null);
32+
return getMethodIfAvailable(clazz, methodName, paramTypes) != null;
3333
}
3434

3535
/**

src/main/java/org/audit4j/core/schedule/util/CustomizableThreadCreator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ public CustomizableThreadCreator() {
3838
* the prefix to use for the names of newly created threads
3939
*/
4040
public CustomizableThreadCreator(String threadNamePrefix) {
41-
this.threadNamePrefix = (threadNamePrefix != null ? threadNamePrefix : getDefaultThreadNamePrefix());
41+
this.threadNamePrefix = threadNamePrefix != null ? threadNamePrefix : getDefaultThreadNamePrefix();
4242
}
4343

4444
/**
4545
* Specify the prefix to use for the names of newly created threads. Default
4646
* is "SimpleAsyncTaskExecutor-".
4747
*/
4848
public void setThreadNamePrefix(String threadNamePrefix) {
49-
this.threadNamePrefix = (threadNamePrefix != null ? threadNamePrefix : getDefaultThreadNamePrefix());
49+
this.threadNamePrefix = threadNamePrefix != null ? threadNamePrefix : getDefaultThreadNamePrefix();
5050
}
5151

5252
/**

src/main/java/org/audit4j/core/schedule/util/StringUtils.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private StringUtils(){
4848
* @since 3.2.1
4949
*/
5050
public static boolean isEmpty(Object str) {
51-
return (str == null || "".equals(str));
51+
return str == null || "".equals(str);
5252
}
5353

5454
/**
@@ -70,7 +70,7 @@ public static boolean isEmpty(Object str) {
7070
* @see #hasText(String)
7171
*/
7272
public static boolean hasLength(CharSequence str) {
73-
return (str != null && str.length() > 0);
73+
return str != null && str.length() > 0;
7474
}
7575

7676
/**
@@ -470,7 +470,7 @@ public static String deleteAny(String inString, String charsToDelete) {
470470
* input was {@code null}
471471
*/
472472
public static String quote(String str) {
473-
return (str != null ? "'" + str + "'" : null);
473+
return str != null ? "'" + str + "'" : null;
474474
}
475475

476476
/**
@@ -483,7 +483,7 @@ public static String quote(String str) {
483483
* if not a String
484484
*/
485485
public static Object quoteIfString(Object obj) {
486-
return (obj instanceof String ? quote((String) obj) : obj);
486+
return obj instanceof String ? quote((String) obj) : obj;
487487
}
488488

489489
/**
@@ -561,7 +561,7 @@ public static String getFilename(String path) {
561561
return null;
562562
}
563563
int separatorIndex = path.lastIndexOf(FOLDER_SEPARATOR);
564-
return (separatorIndex != -1 ? path.substring(separatorIndex + 1) : path);
564+
return separatorIndex != -1 ? path.substring(separatorIndex + 1) : path;
565565
}
566566

567567
/**
@@ -726,8 +726,8 @@ public static boolean pathEquals(String path1, String path2) {
726726
*/
727727
public static Locale parseLocaleString(String localeString) {
728728
String[] parts = tokenizeToStringArray(localeString, "_ ", false, false);
729-
String language = (parts.length > 0 ? parts[0] : "");
730-
String country = (parts.length > 1 ? parts[1] : "");
729+
String language = parts.length > 0 ? parts[0] : "";
730+
String country = parts.length > 1 ? parts[1] : "";
731731
validateLocalePart(language);
732732
validateLocalePart(country);
733733
String variant = "";
@@ -743,7 +743,7 @@ public static Locale parseLocaleString(String localeString) {
743743
variant = trimLeadingCharacter(variant, '_');
744744
}
745745
}
746-
return (language.length() > 0 ? new Locale(language, country, variant) : null);
746+
return language.length() > 0 ? new Locale(language, country, variant) : null;
747747
}
748748

749749
private static void validateLocalePart(String localePart) {

0 commit comments

Comments
 (0)