Browse Source

fix issues reported by PMD

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273480 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
acb441fdfa
25 changed files with 37 additions and 123 deletions
  1. +17
    -17
      src/main/org/apache/tools/ant/listener/AnsiColorLogger.java
  2. +0
    -2
      src/main/org/apache/tools/ant/listener/Log4jListener.java
  3. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  4. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/Socket.java
  5. +0
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
  6. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java
  7. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java
  8. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFile.java
  9. +0
    -19
      src/main/org/apache/tools/ant/taskdefs/optional/depend/JarFileIterator.java
  10. +0
    -22
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java
  11. +0
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/j2ee/JonasHotDeploymentTool.java
  12. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/jlink/ClassNameReader.java
  13. +0
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.java
  14. +2
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
  15. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
  16. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
  17. +2
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java
  18. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/ClassFile.java
  19. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCREATE.java
  20. +0
    -21
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java
  21. +1
    -1
      src/main/org/apache/tools/ant/types/optional/image/Draw.java
  22. +0
    -1
      src/main/org/apache/tools/ant/util/FileUtils.java
  23. +1
    -1
      src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java
  24. +1
    -1
      src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java
  25. +1
    -2
      src/main/org/apache/tools/tar/TarUtils.java

+ 17
- 17
src/main/org/apache/tools/ant/listener/AnsiColorLogger.java View File

@@ -134,31 +134,31 @@ import org.apache.tools.ant.Project;
* @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
*/
public final class AnsiColorLogger extends DefaultLogger {
private static final int ATTR_NORMAL = 0;
private static final int ATTR_BRIGHT = 1;
// private static final int ATTR_NORMAL = 0;
// private static final int ATTR_BRIGHT = 1;
private static final int ATTR_DIM = 2;
private static final int ATTR_UNDERLINE = 3;
private static final int ATTR_BLINK = 5;
private static final int ATTR_REVERSE = 7;
private static final int ATTR_HIDDEN = 8;
// private static final int ATTR_UNDERLINE = 3;
// private static final int ATTR_BLINK = 5;
// private static final int ATTR_REVERSE = 7;
// private static final int ATTR_HIDDEN = 8;

private static final int FG_BLACK = 30;
// private static final int FG_BLACK = 30;
private static final int FG_RED = 31;
private static final int FG_GREEN = 32;
private static final int FG_YELLOW = 33;
// private static final int FG_YELLOW = 33;
private static final int FG_BLUE = 34;
private static final int FG_MAGENTA = 35;
private static final int FG_CYAN = 36;
private static final int FG_WHITE = 37;
// private static final int FG_WHITE = 37;

private static final int BG_BLACK = 40;
private static final int BG_RED = 41;
private static final int BG_GREEN = 42;
private static final int BG_YELLOW = 44;
private static final int BG_BLUE = 44;
private static final int BG_MAGENTA = 45;
private static final int BG_CYAN = 46;
private static final int BG_WHITE = 47;
// private static final int BG_BLACK = 40;
// private static final int BG_RED = 41;
// private static final int BG_GREEN = 42;
// private static final int BG_YELLOW = 44;
// private static final int BG_BLUE = 44;
// private static final int BG_MAGENTA = 45;
// private static final int BG_CYAN = 46;
// private static final int BG_WHITE = 47;

private static final String PREFIX = "\u001b[";
private static final String SUFFIX = "m";


+ 0
- 2
src/main/org/apache/tools/ant/listener/Log4jListener.java View File

@@ -69,8 +69,6 @@ import org.apache.tools.ant.Task;
* @author Conor MacNeill
*/
public class Log4jListener implements BuildListener {
/** Log4j Configuration file */
private static final String LOG4J_CONFIG_PROPERTY = "log4j.configuration";

/** Indicates if the listener was initialized. */
private boolean initialized = false;


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -1644,7 +1644,7 @@ public class Javadoc extends Task {
// is the href a valid URL
try {
URL base = new URL("file://.");
URL testHref = new URL(base, la.getHref());
new URL(base, la.getHref());
} catch (MalformedURLException mue) {
// ok - just skip
log("Link href \"" + la.getHref()


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/condition/Socket.java View File

@@ -90,7 +90,7 @@ public class Socket extends ProjectComponent implements Condition {
log("Checking for listener at " + server + ":" + port,
Project.MSG_VERBOSE);
try {
java.net.Socket socket = new java.net.Socket(server, port);
new java.net.Socket(server, port);
} catch (IOException e) {
return false;
}


+ 0
- 8
src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java View File

@@ -147,14 +147,6 @@ import org.apache.tools.ant.types.EnumeratedAttribute;
*/
public class PropertyFile extends Task {

/* ========================================================================
*
* Static variables.
*/

private static final String NEWLINE = System.getProperty("line.separator");


/* ========================================================================
*
* Instance variables.


+ 0
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java View File

@@ -134,7 +134,6 @@ public class CCMCheck extends Continuus {
*/
public void execute() throws BuildException {
Commandline commandLine = new Commandline();
Project aProj = getProject();
int result = 0;

// build the command line from what we got the format is


+ 0
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java View File

@@ -85,7 +85,6 @@ public class CCMReconfigure extends Continuus {
*/
public void execute() throws BuildException {
Commandline commandLine = new Commandline();
Project aProj = getProject();
int result = 0;

// build the command line from what we got the format


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFile.java View File

@@ -100,8 +100,8 @@ public class ClassFile {
}

// right we have a good looking class file.
int minorVersion = classStream.readUnsignedShort();
int majorVersion = classStream.readUnsignedShort();
/* int minorVersion = */ classStream.readUnsignedShort();
/* int majorVersion = */ classStream.readUnsignedShort();

// read the constant pool in and resolve it
constantPool = new ConstantPool();
@@ -109,9 +109,9 @@ public class ClassFile {
constantPool.read(classStream);
constantPool.resolve();

int accessFlags = classStream.readUnsignedShort();
/* int accessFlags = */ classStream.readUnsignedShort();
int thisClassIndex = classStream.readUnsignedShort();
int superClassIndex = classStream.readUnsignedShort();
/* int superClassIndex = */ classStream.readUnsignedShort();
ClassCPInfo classInfo
= (ClassCPInfo) constantPool.getEntry(thisClassIndex);
className = classInfo.getClassName();


+ 0
- 19
src/main/org/apache/tools/ant/taskdefs/optional/depend/JarFileIterator.java View File

@@ -81,25 +81,6 @@ public class JarFileIterator implements ClassFileIterator {
jarStream = new ZipInputStream(stream);
}

/**
* Read a stream into an array of bytes
*
* @param stream the stream from which the bytes are read
* @return the stream's content as a byte array
* @exception IOException if the stream cannot be read
*/
private byte[] getEntryBytes(InputStream stream) throws IOException {
byte[] buffer = new byte[8192];
ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
int n;

while ((n = stream.read(buffer, 0, buffer.length)) != -1) {
baos.write(buffer, 0, n);
}

return baos.toByteArray();
}

/**
* Get the next ClassFile object from the jar
*


+ 0
- 22
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java View File

@@ -206,28 +206,6 @@ abstract class VAJLocalUtil implements VAJUtil{
}
}

/**
* returns a list of project names matching the given pattern
*/
private Vector findMatchingProjects(String pattern) {
String[] projectNames;
try {
projectNames = getWorkspace().getRepository().getProjectNames();
} catch (IvjException e) {
throw createBuildException("VA Exception occured: ", e);
}

Vector matchingProjects = new Vector();
for (int i = 0; i < projectNames.length; i++) {
if (VAJWorkspaceScanner.match(pattern, projectNames[i])) {
matchingProjects.addElement(projectNames[i]);
}
}

return matchingProjects;
}


/**
* return project descriptions containing full project names instead
* of patterns with wildcards.


+ 0
- 2
src/main/org/apache/tools/ant/taskdefs/optional/j2ee/JonasHotDeploymentTool.java View File

@@ -236,8 +236,6 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements
}
}

String anAction = getTask().getAction();

if (getServer() != null) {
java.createArg().setLine("-n " + getServer());
}


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/jlink/ClassNameReader.java View File

@@ -142,12 +142,12 @@ public class ClassNameReader extends Object {
if (cookie != 0xCAFEBABE) {
return null;
}
int version = data.readInt();
/* int version = */ data.readInt();
// read the constant pool.
ConstantPool constants = new ConstantPool(data);
Object[] values = constants.values;
// read access flags and class index.
int accessFlags = data.readUnsignedShort();
/* int accessFlags = */ data.readUnsignedShort();
int classIndex = data.readUnsignedShort();
Integer stringIndex = (Integer) values[classIndex];
String className = (String) values[stringIndex.intValue()];


+ 0
- 2
src/main/org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.java View File

@@ -207,8 +207,6 @@ public class JlinkTask extends MatchingTask {

private boolean compress = false;

private String ps = System.getProperty("path.separator");

}



+ 2
- 4
src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java View File

@@ -320,8 +320,6 @@ public class jlink extends Object {
*/
private void addFile(ZipOutputStream output, File file, String prefix, boolean compress) throws IOException {
//Make sure file exists
long checksum = 0;

if (!file.exists()) {
return;
}
@@ -417,7 +415,7 @@ public class jlink extends Object {
private long calcChecksum(File f) throws IOException {
BufferedInputStream in = new BufferedInputStream(new FileInputStream(f));

return calcChecksum(in, f.length());
return calcChecksum(in);
}


@@ -425,7 +423,7 @@ public class jlink extends Object {
* Necessary in the case where you add a entry that
* is not compressed.
*/
private long calcChecksum(InputStream in, long size) throws IOException {
private long calcChecksum(InputStream in) throws IOException {
CRC32 crc = new CRC32();
int len = buffer.length;
int count = -1;


+ 0
- 1
src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java View File

@@ -165,7 +165,6 @@ public class WLJspc extends MatchingTask {
File jspFile = null;
String parents = "";
String arg = "";
int j = 0;
//XXX this array stuff is a remnant of prev trials.. gotta remove.
args[j++] = "-d";


+ 0
- 1
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java View File

@@ -469,7 +469,6 @@ public class JUnitTestRunner implements TestListener {
* </table>
*/
public static void main(String[] args) throws IOException {
boolean exitAtEnd = true;
boolean haltError = false;
boolean haltFail = false;
boolean stackfilter = true;


+ 2
- 3
src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java View File

@@ -122,10 +122,10 @@ public class Pvcs extends org.apache.tools.ant.Task {
*/
private static final String PCLI_EXE = "pcli";

/**
/*
* Constant for the PCLI listversionedfiles recursive i a format "get" understands
*/
private static final String PCLI_LVF_ARGS = "lvf -z -aw";
// private static final String PCLI_LVF_ARGS = "lvf -z -aw";

/**
* Constant for the thing to execute
@@ -164,7 +164,6 @@ public class Pvcs extends org.apache.tools.ant.Task {
* @exception org.apache.tools.ant.BuildException Something is stopping the build...
*/
public void execute() throws org.apache.tools.ant.BuildException {
Project aProj = getProject();
int result = 0;

if (repository == null || repository.trim().equals("")) {


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/ClassFile.java View File

@@ -86,9 +86,9 @@ public final class ClassFile {
DataInputStream dis = new DataInputStream(is);
ConstantPool constantPool = new ConstantPool();

int magic = dis.readInt(); // 0xCAFEBABE
int minor = dis.readShort();
int major = dis.readShort();
/* int magic = */ dis.readInt(); // 0xCAFEBABE
/* int minor = */ dis.readShort();
/* int major = */ dis.readShort();

constantPool.read(dis);
constantPool.resolve();
@@ -97,7 +97,7 @@ public final class ClassFile {
access_flags = dis.readShort();
int this_class = dis.readShort();
fullname = ((ClassCPInfo) constantPool.getEntry(this_class)).getClassName().replace('/', '.');
int super_class = dis.readShort();
/* int super_class = */ dis.readShort();

// skip interfaces...
int count = dis.readShort();


+ 0
- 1
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCREATE.java View File

@@ -113,7 +113,6 @@ import org.apache.tools.ant.types.Commandline;
public class MSVSSCREATE extends MSVSS {

private String m_AutoResponse = null;
private String m_Name = null;
private String m_Comment = "-";
private boolean m_Quiet = false;


+ 0
- 21
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java View File

@@ -301,16 +301,6 @@ public class MSVSSHISTORY extends MSVSS {
}
}

/**
* Builds the User command.
* @param cmd the commandline the command is to be added to
*/
private void getUserCommand(Commandline cmd) {
if (m_User != null) {
cmd.createArgument().setValue(FLAG_USER + m_User);
}
}

/**
* Calculates the start date for version comparison.
* <p>
@@ -343,17 +333,6 @@ public class MSVSSHISTORY extends MSVSS {
m_User = user;
}

/**
* @return the 'recursive' command if the attribute was 'true', otherwise an empty string
*/
private void getRecursiveCommand(Commandline cmd) {
if (!m_Recursive) {
return;
} else {
cmd.createArgument().setValue(FLAG_RECURSION);
}
}

/**
* Specify the output style; optional.
*


+ 1
- 1
src/main/org/apache/tools/ant/types/optional/image/Draw.java View File

@@ -120,7 +120,7 @@ public class Draw extends TransformOperation
BufferedImage child = op.getAsBufferedImage();
log("\tDrawing to x=" + xloc + " y=" + yloc);
graphics.drawImage(child, null, xloc, yloc);
PlanarImage test = PlanarImage.wrapRenderedImage(bi);
PlanarImage.wrapRenderedImage(bi);
}
}
image = PlanarImage.wrapRenderedImage(bi);


+ 0
- 1
src/main/org/apache/tools/ant/util/FileUtils.java View File

@@ -360,7 +360,6 @@ public class FileUtils {
in = new BufferedReader(rdr);
}

int length;
String newline = null;
String line = in.readLine();
while (line != null) {


+ 1
- 1
src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java View File

@@ -72,7 +72,7 @@ public class AncestorAnalyzer extends AbstractAnalyzer {
public AncestorAnalyzer() {
// force BCEL classes to load now
try {
ClassParser parser = new ClassParser("force");
new ClassParser("force");
} catch (IOException e) {
// ignore
}


+ 1
- 1
src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java View File

@@ -72,7 +72,7 @@ public class FullAnalyzer extends AbstractAnalyzer {
public FullAnalyzer() {
// force BCEL classes to load now
try {
ClassParser parser = new ClassParser("force");
new ClassParser("force");
} catch (IOException e) {
// ignore
}


+ 1
- 2
src/main/org/apache/tools/tar/TarUtils.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000,2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -157,7 +157,6 @@ public class TarUtils {
* @return The integer value of the octal bytes.
*/
public static int getOctalBytes(long value, byte[] buf, int offset, int length) {
byte[] result = new byte[length];
int idx = length - 1;

buf[offset + idx] = 0;


Loading…
Cancel
Save