summaryrefslogtreecommitdiff
path: root/src/main/org/apache/tools/ant
diff options
context:
space:
mode:
authorGintas Grigelionis <gintas@apache.org>2018-11-04 10:02:42 +0100
committerGintas Grigelionis <gintas@apache.org>2018-11-04 10:03:38 +0100
commite2dd6ec79a083901907e35ac4f0cd3631e71ec55 (patch)
tree1bf63df88a4364260f80f94e68cf634cacc7965f /src/main/org/apache/tools/ant
parent2977bb596c7f8f0b3f81258d04d1c1ef0b3848b7 (diff)
downloadant-e2dd6ec79a083901907e35ac4f0cd3631e71ec55.tar.gz
SonarQube: unnecessary parentheses is a major code smell
Diffstat (limited to 'src/main/org/apache/tools/ant')
-rw-r--r--src/main/org/apache/tools/ant/AntTypeDefinition.java7
-rw-r--r--src/main/org/apache/tools/ant/ComponentHelper.java6
-rw-r--r--src/main/org/apache/tools/ant/Project.java10
-rw-r--r--src/main/org/apache/tools/ant/dispatch/DispatchUtils.java2
-rw-r--r--src/main/org/apache/tools/ant/listener/MailLogger.java16
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Exit.java6
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/FixCRLF.java7
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java4
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/PreSetDef.java17
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Recorder.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Redirector.java6
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Touch.java4
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/condition/Os.java8
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java10
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java2
-rw-r--r--src/main/org/apache/tools/ant/types/EnumeratedAttribute.java2
-rw-r--r--src/main/org/apache/tools/ant/types/Path.java3
-rw-r--r--src/main/org/apache/tools/ant/types/Permissions.java2
-rw-r--r--src/main/org/apache/tools/ant/types/RedirectorElement.java7
-rw-r--r--src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java8
-rw-r--r--src/main/org/apache/tools/ant/types/selectors/modifiedselector/EqualComparator.java2
-rw-r--r--src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java2
-rw-r--r--src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java2
-rw-r--r--src/main/org/apache/tools/ant/util/Base64Converter.java2
-rw-r--r--src/main/org/apache/tools/ant/util/DOMElementWriter.java2
-rw-r--r--src/main/org/apache/tools/ant/util/FileUtils.java2
30 files changed, 66 insertions, 83 deletions
diff --git a/src/main/org/apache/tools/ant/AntTypeDefinition.java b/src/main/org/apache/tools/ant/AntTypeDefinition.java
index 387577f92..20ae38d54 100644
--- a/src/main/org/apache/tools/ant/AntTypeDefinition.java
+++ b/src/main/org/apache/tools/ant/AntTypeDefinition.java
@@ -315,8 +315,7 @@ public class AntTypeDefinition {
noArg = false;
}
//now we instantiate
- T o = ctor.newInstance(
- ((noArg) ? new Object[0] : new Object[] {project}));
+ T o = ctor.newInstance(noArg ? new Object[0] : new Object[] {project});
//set up project references.
project.setProjectReference(o);
@@ -331,12 +330,12 @@ public class AntTypeDefinition {
* @return true if the definitions are the same.
*/
public boolean sameDefinition(AntTypeDefinition other, Project project) {
- return (other != null && other.getClass() == getClass()
+ return other != null && other.getClass() == getClass()
&& other.getTypeClass(project).equals(getTypeClass(project))
&& other.getExposedClass(project).equals(getExposedClass(project))
&& other.restrict == restrict
&& other.adapterClass == adapterClass
- && other.adaptToClass == adaptToClass);
+ && other.adaptToClass == adaptToClass;
}
/**
diff --git a/src/main/org/apache/tools/ant/ComponentHelper.java b/src/main/org/apache/tools/ant/ComponentHelper.java
index 28fa82486..1cc84f8ab 100644
--- a/src/main/org/apache/tools/ant/ComponentHelper.java
+++ b/src/main/org/apache/tools/ant/ComponentHelper.java
@@ -710,9 +710,9 @@ public class ComponentHelper {
}
Class<?> oldClass = old.getExposedClass(project);
boolean isTask = oldClass != null && Task.class.isAssignableFrom(oldClass);
- project.log("Trying to override old definition of "
- + (isTask ? "task " : "datatype ") + name, (def.similarDefinition(old,
- project)) ? Project.MSG_VERBOSE : Project.MSG_WARN);
+ project.log(String.format("Trying to override old definition of %s %s",
+ isTask ? "task" : "datatype", name), def.similarDefinition(old,
+ project) ? Project.MSG_VERBOSE : Project.MSG_WARN);
}
project.log(" +Datatype " + name + " " + def.getClassName(), Project.MSG_DEBUG);
antTypeTable.put(name, def);
diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java
index 62aafbc4c..6ff43d4df 100644
--- a/src/main/org/apache/tools/ant/Project.java
+++ b/src/main/org/apache/tools/ant/Project.java
@@ -268,7 +268,7 @@ public class Project implements ResourceFactory {
public Project createSubProject() {
Project subProject = null;
try {
- subProject = (getClass().newInstance());
+ subProject = getClass().newInstance();
} catch (final Exception e) {
subProject = new Project();
}
@@ -927,7 +927,7 @@ public class Project implements ResourceFactory {
throw new BuildException("Ant cannot work on Java prior to 1.8");
}
log("Detected Java version: " + javaVersion + " in: "
- + System.getProperty("java.home"), MSG_VERBOSE);
+ + JavaEnvUtils.getJavaHome(), MSG_VERBOSE);
log("Detected OS: " + System.getProperty("os.name"), MSG_VERBOSE);
}
@@ -1716,9 +1716,9 @@ public class Project implements ResourceFactory {
* <code>false</code> otherwise.
*/
public static boolean toBoolean(final String s) {
- return ("on".equalsIgnoreCase(s)
+ return "on".equalsIgnoreCase(s)
|| "true".equalsIgnoreCase(s)
- || "yes".equalsIgnoreCase(s));
+ || "yes".equalsIgnoreCase(s);
}
/**
@@ -1828,7 +1828,7 @@ public class Project implements ResourceFactory {
.collect(Collectors.joining(","))
+ " is " + ret, MSG_VERBOSE);
- final Vector<Target> complete = (returnAll) ? ret : new Vector<>(ret);
+ final Vector<Target> complete = returnAll ? ret : new Vector<>(ret);
for (final String curTarget : targetTable.keySet()) {
final String st = state.get(curTarget);
if (st == null) {
diff --git a/src/main/org/apache/tools/ant/dispatch/DispatchUtils.java b/src/main/org/apache/tools/ant/dispatch/DispatchUtils.java
index efaccf89d..f2802a921 100644
--- a/src/main/org/apache/tools/ant/dispatch/DispatchUtils.java
+++ b/src/main/org/apache/tools/ant/dispatch/DispatchUtils.java
@@ -104,7 +104,7 @@ public class DispatchUtils {
} catch (InvocationTargetException ie) {
Throwable t = ie.getTargetException();
if (t instanceof BuildException) {
- throw ((BuildException) t);
+ throw (BuildException) t;
} else {
throw new BuildException(t);
}
diff --git a/src/main/org/apache/tools/ant/listener/MailLogger.java b/src/main/org/apache/tools/ant/listener/MailLogger.java
index c2b9e25b0..29068b4e4 100644
--- a/src/main/org/apache/tools/ant/listener/MailLogger.java
+++ b/src/main/org/apache/tools/ant/listener/MailLogger.java
@@ -143,16 +143,13 @@ public class MailLogger extends DefaultLogger {
}
Values values = new Values()
.mailhost(getValue(properties, "mailhost", "localhost"))
- .port(Integer.parseInt(
- getValue(
- properties, "port",
- String.valueOf(MailMessage.DEFAULT_PORT))))
+ .port(Integer.parseInt(getValue(properties, "port",
+ String.valueOf(MailMessage.DEFAULT_PORT))))
.user(getValue(properties, "user", ""))
.password(getValue(properties, "password", ""))
- .ssl(Project.toBoolean(getValue(properties,
- "ssl", "off")))
+ .ssl(Project.toBoolean(getValue(properties, "ssl", "off")))
.starttls(Project.toBoolean(getValue(properties,
- "starttls.enable", "off")))
+ "starttls.enable", "off")))
.from(getValue(properties, "from", null))
.replytoList(getValue(properties, "replyto", ""))
.toList(getValue(properties, prefix + ".to", null))
@@ -161,9 +158,8 @@ public class MailLogger extends DefaultLogger {
.mimeType(getValue(properties, "mimeType", DEFAULT_MIME_TYPE))
.charset(getValue(properties, "charset", ""))
.body(getValue(properties, prefix + ".body", ""))
- .subject(getValue(
- properties, prefix + ".subject",
- (success) ? "Build Success" : "Build Failure"));
+ .subject(getValue(properties, prefix + ".subject",
+ success ? "Build Success" : "Build Failure"));
if (values.user().isEmpty()
&& values.password().isEmpty()
&& !values.ssl() && !values.starttls()) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java b/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java
index c55c1ec48..503a3f323 100644
--- a/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java
@@ -364,7 +364,7 @@ public abstract class AbstractCvsTask extends Task {
log("Caught exception: " + e.getMessage(), Project.MSG_WARN);
} catch (BuildException e) {
if (failOnError) {
- throw(e);
+ throw e;
}
Throwable t = e.getCause();
if (t == null) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/Exit.java b/src/main/org/apache/tools/ant/taskdefs/Exit.java
index c55c58462..739488780 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Exit.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Exit.java
@@ -134,8 +134,8 @@ public class Exit extends Task {
*/
@Override
public void execute() throws BuildException {
- boolean fail = (nestedConditionPresent()) ? testNestedCondition()
- : (testIfCondition() && testUnlessCondition());
+ boolean fail = nestedConditionPresent() ? testNestedCondition()
+ : testIfCondition() && testUnlessCondition();
if (fail) {
String text = null;
if (message != null && !message.trim().isEmpty()) {
@@ -231,7 +231,7 @@ public class Exit extends Task {
* @return <code>boolean</code>.
*/
private boolean nestedConditionPresent() {
- return (nestedCondition != null);
+ return nestedCondition != null;
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
index cdac0d238..af6c6fe07 100644
--- a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
+++ b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
@@ -420,10 +420,9 @@ public class FixCRLF extends MatchingTask implements ChainableReader {
throws BuildException {
this.srcFile = srcFile;
try {
- reader = new BufferedReader(
- ((encoding == null) ? new FileReader(srcFile)
- : new InputStreamReader(
- Files.newInputStream(srcFile.toPath()), encoding)), INBUFLEN);
+ reader = new BufferedReader(encoding == null ? new FileReader(srcFile)
+ : new InputStreamReader(Files.newInputStream(srcFile.toPath()),
+ encoding), INBUFLEN);
nextLine();
} catch (IOException e) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java b/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java
index 569968c94..0fb5834fa 100644
--- a/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java
+++ b/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java
@@ -169,9 +169,9 @@ public class JikesOutputParser implements ExecuteStreamHandler {
private void log(String line) {
if (!emacsMode) {
- task.log("", (error ? Project.MSG_ERR : Project.MSG_WARN));
+ task.log("", error ? Project.MSG_ERR : Project.MSG_WARN);
}
- task.log(line, (error ? Project.MSG_ERR : Project.MSG_WARN));
+ task.log(line, error ? Project.MSG_ERR : Project.MSG_WARN);
}
/**
diff --git a/src/main/org/apache/tools/ant/taskdefs/PreSetDef.java b/src/main/org/apache/tools/ant/taskdefs/PreSetDef.java
index b3439193a..f4b49c686 100644
--- a/src/main/org/apache/tools/ant/taskdefs/PreSetDef.java
+++ b/src/main/org/apache/tools/ant/taskdefs/PreSetDef.java
@@ -266,9 +266,9 @@ public class PreSetDef extends AntlibDefinition implements TaskContainer {
*/
@Override
public boolean sameDefinition(AntTypeDefinition other, Project project) {
- return (other != null && other.getClass() == getClass() && parent != null
- && parent.sameDefinition(((PreSetDefinition) other).parent, project)
- && element.similar(((PreSetDefinition) other).element));
+ return other != null && other.getClass() == getClass() && parent != null
+ && parent.sameDefinition(((PreSetDefinition) other).parent, project)
+ && element.similar(((PreSetDefinition) other).element);
}
/**
@@ -279,12 +279,11 @@ public class PreSetDef extends AntlibDefinition implements TaskContainer {
* @return true if the definitions are similar.
*/
@Override
- public boolean similarDefinition(
- AntTypeDefinition other, Project project) {
- return (other != null && other.getClass().getName().equals(
- getClass().getName()) && parent != null
- && parent.similarDefinition(((PreSetDefinition) other).parent, project)
- && element.similar(((PreSetDefinition) other).element));
+ public boolean similarDefinition(AntTypeDefinition other, Project project) {
+ return other != null && other.getClass().getName().equals(getClass().getName())
+ && parent != null
+ && parent.similarDefinition(((PreSetDefinition) other).parent, project)
+ && element.similar(((PreSetDefinition) other).element);
}
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Recorder.java b/src/main/org/apache/tools/ant/taskdefs/Recorder.java
index 90410b630..5d3d049ae 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Recorder.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Recorder.java
@@ -114,7 +114,7 @@ public class Recorder extends Task implements SubBuildListener {
* @param append if true, append to a previous file.
*/
public void setAppend(boolean append) {
- this.append = (append ? Boolean.TRUE : Boolean.FALSE);
+ this.append = append ? Boolean.TRUE : Boolean.FALSE;
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Redirector.java b/src/main/org/apache/tools/ant/taskdefs/Redirector.java
index 5d07de1a7..af51675cc 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Redirector.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Redirector.java
@@ -695,8 +695,7 @@ public class Redirector {
/** outStreams */
private void outStreams() {
if (out != null && out.length > 0) {
- final String logHead = "Output "
- + ((appendOut) ? "appended" : "redirected") + " to ";
+ final String logHead = "Output " + (appendOut ? "appended" : "redirected") + " to ";
outputStream = foldFiles(out, logHead, Project.MSG_VERBOSE,
appendOut, createEmptyFilesOut);
}
@@ -717,8 +716,7 @@ public class Redirector {
private void errorStreams() {
if (error != null && error.length > 0) {
- final String logHead = "Error "
- + ((appendErr) ? "appended" : "redirected") + " to ";
+ final String logHead = "Error " + (appendErr ? "appended" : "redirected") + " to ";
errorStream = foldFiles(error, logHead, Project.MSG_VERBOSE,
appendErr, createEmptyFilesErr);
} else if (!(logError || outputStream == null) && errorProperty == null) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/Touch.java b/src/main/org/apache/tools/ant/taskdefs/Touch.java
index 86c573a63..d7c9e97b7 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Touch.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Touch.java
@@ -254,7 +254,7 @@ public class Touch extends Task {
}
}
log("Setting millis to " + workmillis + " from datetime attribute",
- ((millis < 0) ? Project.MSG_DEBUG : Project.MSG_VERBOSE));
+ millis < 0 ? Project.MSG_DEBUG : Project.MSG_VERBOSE);
setMillis(workmillis);
// only set if successful to this point:
dateTimeConfigured = true;
@@ -352,7 +352,7 @@ public class Touch extends Task {
private void touch(File file, long modTime) {
if (!file.exists()) {
log("Creating " + file,
- ((verbose) ? Project.MSG_INFO : Project.MSG_VERBOSE));
+ verbose ? Project.MSG_INFO : Project.MSG_VERBOSE);
try {
FILE_UTILS.createNewFile(file, mkdirs);
} catch (IOException ioe) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Os.java b/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
index 9ca87a9c4..21178de0a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
@@ -264,12 +264,12 @@ public class Os implements Condition {
boolean isNT = false;
if (isWindows) {
//there are only four 9x platforms that we look for
- is9x = (OS_NAME.contains("95")
+ //wince isn't really 9x, but crippled enough to
+ //be a muchness. Ant doesn't run on CE, anyway.
+ is9x = OS_NAME.contains("95")
|| OS_NAME.contains("98")
|| OS_NAME.contains("me")
- //wince isn't really 9x, but crippled enough to
- //be a muchness. Ant doesn't run on CE, anyway.
- || OS_NAME.contains("ce"));
+ || OS_NAME.contains("ce");
isNT = !is9x;
}
switch (family) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java b/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java
index 40e531c14..a7ad4a462 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java
@@ -479,7 +479,7 @@ public class SchemaValidate extends XMLValidateTask {
public int hashCode() {
int result;
// CheckStyle:MagicNumber OFF
- result = (namespace == null ? 0 : namespace.hashCode());
+ result = namespace == null ? 0 : namespace.hashCode();
result = 29 * result + (file == null ? 0 : file.hashCode());
result = 29 * result + (url == null ? 0 : url.hashCode());
// CheckStyle:MagicNumber OFF
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
index c7000b3f9..61502db0b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
@@ -364,7 +364,7 @@ public class XMLValidateTask extends Task {
* @return true when a SAX1 parser is in use
*/
protected boolean isSax1Parser() {
- return (xmlReader instanceof ParserAdapter);
+ return xmlReader instanceof ParserAdapter;
}
/**
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
index 4484062fa..40a2b7c53 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
@@ -1081,12 +1081,7 @@ public class IPlanetEjbc {
* be run to bring the stubs and skeletons up to date.
*/
public boolean mustBeRecompiled(File destDir) {
-
- long sourceModified = sourceClassesModified(destDir);
-
- long destModified = destClassesModified(destDir);
-
- return (destModified < sourceModified);
+ return destClassesModified(destDir) < sourceClassesModified(destDir);
}
/**
@@ -1236,8 +1231,7 @@ public class IPlanetEjbc {
* names for the stubs and skeletons to be generated.
*/
private String[] classesToGenerate() {
- String[] classnames = (iiop)
- ? new String[NUM_CLASSES_WITH_IIOP]
+ String[] classnames = iiop ? new String[NUM_CLASSES_WITH_IIOP]
: new String[NUM_CLASSES_WITHOUT_IIOP];
final String remotePkg = remote.getPackageName() + ".";
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java b/src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java
index 1000d8d41..5f2e7e332 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java
@@ -467,7 +467,7 @@ public final class Extension {
* @return true if the specified extension is compatible with this extension
*/
public boolean isCompatibleWith(final Extension required) {
- return (COMPATIBLE == getCompatibilityWith(required));
+ return COMPATIBLE == getCompatibilityWith(required);
}
/**
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
index 901ff06a8..155e2ed55 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
@@ -876,7 +876,7 @@ public class FTP extends Task implements FTPTaskConfig {
* @return true if the file exists
*/
public boolean exists() {
- return (ftpFile != null);
+ return ftpFile != null;
}
/**
diff --git a/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java b/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java
index dac396615..3e29d79bd 100644
--- a/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java
+++ b/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java
@@ -103,7 +103,7 @@ public abstract class EnumeratedAttribute {
* @return true if the value is valid
*/
public final boolean containsValue(String value) {
- return (indexOfValue(value) != -1);
+ return indexOfValue(value) != -1;
}
/**
diff --git a/src/main/org/apache/tools/ant/types/Path.java b/src/main/org/apache/tools/ant/types/Path.java
index 08f5f2248..a4b0b6284 100644
--- a/src/main/org/apache/tools/ant/types/Path.java
+++ b/src/main/org/apache/tools/ant/types/Path.java
@@ -331,8 +331,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
* @param tryUserDir if true try the user directory if the file is not present
*/
public void addExisting(Path source, boolean tryUserDir) {
- File userDir = (tryUserDir) ? new File(System.getProperty("user.dir"))
- : null;
+ File userDir = tryUserDir ? new File(System.getProperty("user.dir")) : null;
for (String name : source.list()) {
File f = resolveFile(getProject(), name);
diff --git a/src/main/org/apache/tools/ant/types/Permissions.java b/src/main/org/apache/tools/ant/types/Permissions.java
index 7dd0ec9f0..aa7f4b775 100644
--- a/src/main/org/apache/tools/ant/types/Permissions.java
+++ b/src/main/org/apache/tools/ant/types/Permissions.java
@@ -348,7 +348,7 @@ public class Permissions {
*/
@Override
public String toString() {
- return ("Permission: " + className + " (\"" + name + "\", \"" + actions + "\")");
+ return String.format("Permission: %s (\"%s\", \"%s\")", className, name, actions);
}
}
}
diff --git a/src/main/org/apache/tools/ant/types/RedirectorElement.java b/src/main/org/apache/tools/ant/types/RedirectorElement.java
index c0b1bd5be..e814f46a6 100644
--- a/src/main/org/apache/tools/ant/types/RedirectorElement.java
+++ b/src/main/org/apache/tools/ant/types/RedirectorElement.java
@@ -342,7 +342,7 @@ public class RedirectorElement extends DataType {
if (isReference()) {
throw tooManyAttributes();
}
- this.append = ((append) ? Boolean.TRUE : Boolean.FALSE);
+ this.append = append ? Boolean.TRUE : Boolean.FALSE;
}
/**
@@ -356,7 +356,7 @@ public class RedirectorElement extends DataType {
if (isReference()) {
throw tooManyAttributes();
}
- this.alwaysLog = ((alwaysLog) ? Boolean.TRUE : Boolean.FALSE);
+ this.alwaysLog = alwaysLog ? Boolean.TRUE : Boolean.FALSE;
}
/**
@@ -368,8 +368,7 @@ public class RedirectorElement extends DataType {
if (isReference()) {
throw tooManyAttributes();
}
- this.createEmptyFiles = ((createEmptyFiles)
- ? Boolean.TRUE : Boolean.FALSE);
+ this.createEmptyFiles = createEmptyFiles ? Boolean.TRUE : Boolean.FALSE;
}
/**
diff --git a/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java b/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
index f8aba1d00..3c5f9bbbb 100644
--- a/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
+++ b/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
@@ -278,8 +278,8 @@ public final class SelectorUtils {
}
// Find the pattern between padIdxStart & padIdxTmp in str between
// strIdxStart & strIdxEnd
- int patLength = (patIdxTmp - patIdxStart - 1);
- int strLength = (strIdxEnd - strIdxStart + 1);
+ int patLength = patIdxTmp - patIdxStart - 1;
+ int strLength = strIdxEnd - strIdxStart + 1;
int foundIdx = -1;
strLoop:
for (int i = 0; i <= strLength - patLength; i++) {
@@ -433,8 +433,8 @@ public final class SelectorUtils {
}
// Find the pattern between padIdxStart & padIdxTmp in str between
// strIdxStart & strIdxEnd
- int patLength = (patIdxTmp - patIdxStart - 1);
- int strLength = (strIdxEnd - strIdxStart + 1);
+ int patLength = patIdxTmp - patIdxStart - 1;
+ int strLength = strIdxEnd - strIdxStart + 1;
int foundIdx = -1;
strLoop:
for (int i = 0; i <= strLength - patLength; i++) {
diff --git a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/EqualComparator.java b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/EqualComparator.java
index 94fb9351e..7e4bbe5cc 100644
--- a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/EqualComparator.java
+++ b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/EqualComparator.java
@@ -45,7 +45,7 @@ public class EqualComparator implements Comparator<Object> {
}
return 0;
}
- return (o1.equals(o2)) ? 0 : 1;
+ return o1.equals(o2) ? 0 : 1;
}
/**
diff --git a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java
index 181642c14..3aa6b0a11 100644
--- a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java
@@ -459,7 +459,7 @@ public class ModifiedSelector extends BaseExtendSelector
+ resource.getName()
+ "' does not provide an InputStream, so it is not checked. "
+ "According to 'selres' attribute value it is "
- + ((selectResourcesWithoutInputStream) ? "" : " not")
+ + (selectResourcesWithoutInputStream ? "" : " not")
+ "selected.", Project.MSG_INFO);
return selectResourcesWithoutInputStream;
} catch (Exception e) {
diff --git a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java
index ae52dc951..e8c8fd06b 100644
--- a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java
+++ b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java
@@ -118,7 +118,7 @@ public class PropertiesfileCache implements Cache {
*/
@Override
public boolean isValid() {
- return (cachefile != null);
+ return cachefile != null;
}
diff --git a/src/main/org/apache/tools/ant/util/Base64Converter.java b/src/main/org/apache/tools/ant/util/Base64Converter.java
index 4f62b0357..2a1740d25 100644
--- a/src/main/org/apache/tools/ant/util/Base64Converter.java
+++ b/src/main/org/apache/tools/ant/util/Base64Converter.java
@@ -91,7 +91,7 @@ public class Base64Converter {
out[outIndex++] = ALPHABET[bits6];
bits6 = (bits24 & POS_1_MASK) >> POS_1_SHIFT;
out[outIndex++] = ALPHABET[bits6];
- bits6 = (bits24 & POS_0_MASK);
+ bits6 = bits24 & POS_0_MASK;
out[outIndex++] = ALPHABET[bits6];
}
if (octetString.length - i == 2) {
diff --git a/src/main/org/apache/tools/ant/util/DOMElementWriter.java b/src/main/org/apache/tools/ant/util/DOMElementWriter.java
index ebef59b09..5c85b135c 100644
--- a/src/main/org/apache/tools/ant/util/DOMElementWriter.java
+++ b/src/main/org/apache/tools/ant/util/DOMElementWriter.java
@@ -515,7 +515,7 @@ public class DOMElementWriter {
int prevEnd = 0;
int cdataEndPos = value.indexOf("]]>");
while (prevEnd < len) {
- final int end = (cdataEndPos < 0 ? len : cdataEndPos);
+ final int end = cdataEndPos < 0 ? len : cdataEndPos;
// Write out stretches of legal characters in the range [prevEnd, end).
int prevLegalCharPos = prevEnd;
while (prevLegalCharPos < end) {
diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java
index 7764cebc5..1d0e9a388 100644
--- a/src/main/org/apache/tools/ant/util/FileUtils.java
+++ b/src/main/org/apache/tools/ant/util/FileUtils.java
@@ -1181,7 +1181,7 @@ public class FileUtils {
if (!l.endsWith(File.separator)) {
l += File.separator;
}
- return (p.startsWith(l)) ? p.substring(l.length()) : p;
+ return p.startsWith(l) ? p.substring(l.length()) : p;
}
/**