Browse Source

more magic numbers

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@577364 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
7aff35c2c2
9 changed files with 27 additions and 9 deletions
  1. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  2. +4
    -0
      src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java
  3. +2
    -0
      src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java
  4. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
  5. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
  6. +3
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
  7. +2
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java
  8. +6
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
  9. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java

+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java View File

@@ -45,6 +45,7 @@ import org.apache.tools.ant.taskdefs.condition.Os;
* @since Ant 1.3 * @since Ant 1.3
*/ */
public abstract class DefaultCompilerAdapter implements CompilerAdapter { public abstract class DefaultCompilerAdapter implements CompilerAdapter {
private static final int COMMAND_LINE_LIMIT = 4096; // 4K
// CheckStyle:VisibilityModifier OFF - bc // CheckStyle:VisibilityModifier OFF - bc


private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
@@ -460,7 +461,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
* POSIX seems to define a lower limit of 4k, so use a temporary * POSIX seems to define a lower limit of 4k, so use a temporary
* file if the total length of the command line exceeds this limit. * file if the total length of the command line exceeds this limit.
*/ */
if (Commandline.toString(args).length() > 4096
if (Commandline.toString(args).length() > COMMAND_LINE_LIMIT
&& firstFileName >= 0) { && firstFileName >= 0) {
PrintWriter out = null; PrintWriter out = null;
try { try {


+ 4
- 0
src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java View File

@@ -149,7 +149,9 @@ class ChangeLogParser {
*/ */
private void processFile(final String line) { private void processFile(final String line) {
if (line.startsWith("Working file:")) { if (line.startsWith("Working file:")) {
// CheckStyle:MagicNumber OFF
file = line.substring(14, line.length()); file = line.substring(14, line.length());
// CheckStyle:MagicNumber ON
status = GET_REVISION; status = GET_REVISION;
} }
} }
@@ -161,7 +163,9 @@ class ChangeLogParser {
*/ */
private void processRevision(final String line) { private void processRevision(final String line) {
if (line.startsWith("revision")) { if (line.startsWith("revision")) {
// CheckStyle:MagicNumber OFF
revision = line.substring(9); revision = line.substring(9);
// CheckStyle:MagicNumber ON
status = GET_DATE; status = GET_DATE;
} else if (line.startsWith("======")) { } else if (line.startsWith("======")) {
//There were no revisions in this changelog //There were no revisions in this changelog


+ 2
- 0
src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java View File

@@ -169,8 +169,10 @@ public class ChangeLogTask extends AbstractCvsTask {
* @param days the number of days of log to process. * @param days the number of days of log to process.
*/ */
public void setDaysinpast(final int days) { public void setDaysinpast(final int days) {
// CheckStyle:MagicNumber OFF
final long time = System.currentTimeMillis() final long time = System.currentTimeMillis()
- (long) days * 24 * 60 * 60 * 1000; - (long) days * 24 * 60 * 60 * 1000;
// CheckStyle:MagicNumber ON


setStart(new Date(time)); setStart(new Date(time));
} }


+ 3
- 1
src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java View File

@@ -39,6 +39,8 @@ import org.apache.tools.ant.util.ClasspathUtils;
* @ant.task name="mail" category="network" * @ant.task name="mail" category="network"
*/ */
public class EmailTask extends Task { public class EmailTask extends Task {
private static final int SMTP_PORT = 25;

/** Constant to show that the best available mailer should be used. */ /** Constant to show that the best available mailer should be used. */
public static final String AUTO = "auto"; public static final String AUTO = "auto";
/** Constant to allow the Mime mailer to be requested */ /** Constant to allow the Mime mailer to be requested */
@@ -65,7 +67,7 @@ public class EmailTask extends Task {
private String encoding = AUTO; private String encoding = AUTO;
/** host running SMTP */ /** host running SMTP */
private String host = "localhost"; private String host = "localhost";
private int port = 25;
private int port = SMTP_PORT;
/** subject field */ /** subject field */
private String subject = null; private String subject = null;
/** any text */ /** any text */


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

@@ -374,7 +374,8 @@ public class ANTLR extends Task {
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
int extendsIndex = line.indexOf(" extends "); int extendsIndex = line.indexOf(" extends ");
if (line.startsWith("class ") && extendsIndex > -1) { if (line.startsWith("class ") && extendsIndex > -1) {
generatedFileName = line.substring(6, extendsIndex).trim();
generatedFileName = line.substring(
"class ".length(), extendsIndex).trim();
break; break;
} }
} }


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

@@ -44,7 +44,7 @@ import org.apache.tools.ant.util.FileUtils;
*/ */


public class Cab extends MatchingTask { public class Cab extends MatchingTask {
private static final int DEFAULT_RESULT = -99;
private File cabFile; private File cabFile;
private File baseDir; private File baseDir;
private Vector filesets = new Vector(); private Vector filesets = new Vector();
@@ -279,7 +279,8 @@ public class Cab extends MatchingTask {
out.flush(); out.flush();
out.close(); out.close();


int result = -99; // A wild default for when the thread is interrupted
// A wild default for when the thread is interrupted
int result = DEFAULT_RESULT;


try { try {
// Wait for the process to finish // Wait for the process to finish


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

@@ -503,9 +503,11 @@ public class SchemaValidate extends XMLValidateTask {
*/ */
public int hashCode() { public int hashCode() {
int result; int result;
// CheckStyle:MagicNumber OFF
result = (namespace != null ? namespace.hashCode() : 0); result = (namespace != null ? namespace.hashCode() : 0);
result = 29 * result + (file != null ? file.hashCode() : 0); result = 29 * result + (file != null ? file.hashCode() : 0);
result = 29 * result + (url != null ? url.hashCode() : 0); result = 29 * result + (url != null ? url.hashCode() : 0);
// CheckStyle:MagicNumber OFF
return result; return result;
} }




+ 6
- 3
src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java View File

@@ -44,6 +44,8 @@ import org.apache.tools.ant.util.depend.DependencyAnalyzer;
* *
*/ */
public class Depend extends MatchingTask { public class Depend extends MatchingTask {
private static final int ONE_SECOND = 1000;

/** /**
* A class (struct) user to manage information about a class * A class (struct) user to manage information about a class
* *
@@ -693,7 +695,7 @@ public class Depend extends MatchingTask {
determineOutOfDateClasses(); determineOutOfDateClasses();
int count = deleteAllAffectedFiles(); int count = deleteAllAffectedFiles();


long duration = (System.currentTimeMillis() - start) / 1000;
long duration = (System.currentTimeMillis() - start) / ONE_SECOND;


final int summaryLogLevel; final int summaryLogLevel;
if (count > 0) { if (count > 0) {
@@ -817,8 +819,9 @@ public class Depend extends MatchingTask {
} else if (file.getName().endsWith(".class")) { } else if (file.getName().endsWith(".class")) {
ClassFileInfo info = new ClassFileInfo(); ClassFileInfo info = new ClassFileInfo();
info.absoluteFile = file; info.absoluteFile = file;
String relativeName = file.getPath().substring(rootLength + 1,
file.getPath().length() - 6);
String relativeName = file.getPath().substring(
rootLength + 1,
file.getPath().length() - ".class".length());
info.className info.className
= ClassFileUtils.convertSlashName(relativeName); = ClassFileUtils.convertSlashName(relativeName);
info.sourceFile = findSourceFile(relativeName); info.sourceFile = findSourceFile(relativeName);


+ 3
- 1
src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java View File

@@ -70,6 +70,8 @@ import org.apache.tools.ant.types.EnumeratedAttribute;
public abstract class DotnetCompile public abstract class DotnetCompile
extends DotnetBaseMatchingTask { extends DotnetBaseMatchingTask {


private static final int DEFAULT_WARN_LEVEL = 3;

/** /**
* list of reference classes. (pretty much a classpath equivalent) * list of reference classes. (pretty much a classpath equivalent)
*/ */
@@ -194,7 +196,7 @@ public abstract class DotnetCompile
win32icon = null; win32icon = null;
srcDir = null; srcDir = null;
mainClass = null; mainClass = null;
warnLevel = 3;
warnLevel = DEFAULT_WARN_LEVEL;
optimize = false; optimize = false;
debug = true; debug = true;
references = null; references = null;


Loading…
Cancel
Save