ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r577364 - in /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs: compilers/ cvslib/ email/ optional/ optional/depend/ optional/dotnet/
Date Wed, 19 Sep 2007 16:53:42 GMT
Author: peterreilly
Date: Wed Sep 19 09:53:41 2007
New Revision: 577364

URL: http://svn.apache.org/viewvc?rev=577364&view=rev
Log:
more magic numbers

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java?rev=577364&r1=577363&r2=577364&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
Wed Sep 19 09:53:41 2007
@@ -45,6 +45,7 @@
  * @since Ant 1.3
  */
 public abstract class DefaultCompilerAdapter implements CompilerAdapter {
+    private static final int COMMAND_LINE_LIMIT = 4096;  // 4K
     // CheckStyle:VisibilityModifier OFF - bc
 
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
@@ -460,7 +461,7 @@
              * 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.
              */
-            if (Commandline.toString(args).length() > 4096
+            if (Commandline.toString(args).length() > COMMAND_LINE_LIMIT
                 && firstFileName >= 0) {
                 PrintWriter out = null;
                 try {

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java?rev=577364&r1=577363&r2=577364&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java Wed
Sep 19 09:53:41 2007
@@ -149,7 +149,9 @@
      */
     private void processFile(final String line) {
         if (line.startsWith("Working file:")) {
+            // CheckStyle:MagicNumber OFF
             file = line.substring(14, line.length());
+            // CheckStyle:MagicNumber ON
             status = GET_REVISION;
         }
     }
@@ -161,7 +163,9 @@
      */
     private void processRevision(final String line) {
         if (line.startsWith("revision")) {
+            // CheckStyle:MagicNumber OFF
             revision = line.substring(9);
+            // CheckStyle:MagicNumber ON
             status = GET_DATE;
         } else if (line.startsWith("======")) {
             //There were no revisions in this changelog

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java?rev=577364&r1=577363&r2=577364&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java Wed Sep
19 09:53:41 2007
@@ -169,8 +169,10 @@
      * @param days the number of days of log to process.
      */
     public void setDaysinpast(final int days) {
+        // CheckStyle:MagicNumber OFF
         final long time = System.currentTimeMillis()
              - (long) days * 24 * 60 * 60 * 1000;
+        // CheckStyle:MagicNumber ON
 
         setStart(new Date(time));
     }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java?rev=577364&r1=577363&r2=577364&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java Wed Sep 19
09:53:41 2007
@@ -39,6 +39,8 @@
  * @ant.task name="mail" category="network"
  */
 public class EmailTask extends Task {
+    private static final int SMTP_PORT = 25;
+
     /** Constant to show that the best available mailer should be used.  */
     public static final String AUTO = "auto";
     /** Constant to allow the Mime mailer to be requested  */
@@ -65,7 +67,7 @@
     private String encoding = AUTO;
     /** host running SMTP  */
     private String host = "localhost";
-    private int port = 25;
+    private int port = SMTP_PORT;
     /** subject field  */
     private String subject = null;
     /** any text  */

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java?rev=577364&r1=577363&r2=577364&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java Wed Sep 19 09:53:41
2007
@@ -374,7 +374,8 @@
             while ((line = in.readLine()) != null) {
                 int extendsIndex = line.indexOf(" extends ");
                 if (line.startsWith("class ") && extendsIndex > -1) {
-                    generatedFileName = line.substring(6, extendsIndex).trim();
+                    generatedFileName = line.substring(
+                        "class ".length(), extendsIndex).trim();
                     break;
                 }
             }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java?rev=577364&r1=577363&r2=577364&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java Wed Sep 19 09:53:41
2007
@@ -44,7 +44,7 @@
  */
 
 public class Cab extends MatchingTask {
-
+    private static final int DEFAULT_RESULT = -99;
     private File cabFile;
     private File baseDir;
     private Vector filesets = new Vector();
@@ -279,7 +279,8 @@
                 out.flush();
                 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 {
                     // Wait for the process to finish

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java?rev=577364&r1=577363&r2=577364&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java Wed
Sep 19 09:53:41 2007
@@ -503,9 +503,11 @@
          */
         public int hashCode() {
             int result;
+            // CheckStyle:MagicNumber OFF
             result = (namespace != null ? namespace.hashCode() : 0);
             result = 29 * result + (file != null ? file.hashCode() : 0);
             result = 29 * result + (url != null ? url.hashCode() : 0);
+            // CheckStyle:MagicNumber OFF
             return result;
         }
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java?rev=577364&r1=577363&r2=577364&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java Wed
Sep 19 09:53:41 2007
@@ -44,6 +44,8 @@
  *
  */
 public class Depend extends MatchingTask {
+    private static final int ONE_SECOND = 1000;
+
     /**
      * A class (struct) user to manage information about a class
      *
@@ -693,7 +695,7 @@
             determineOutOfDateClasses();
             int count = deleteAllAffectedFiles();
 
-            long duration = (System.currentTimeMillis() - start) / 1000;
+            long duration = (System.currentTimeMillis() - start) / ONE_SECOND;
 
             final int summaryLogLevel;
             if (count > 0) {
@@ -817,8 +819,9 @@
             } else if (file.getName().endsWith(".class")) {
                 ClassFileInfo info = new ClassFileInfo();
                 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
                     = ClassFileUtils.convertSlashName(relativeName);
                 info.sourceFile = findSourceFile(relativeName);

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java?rev=577364&r1=577363&r2=577364&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java
Wed Sep 19 09:53:41 2007
@@ -70,6 +70,8 @@
 public abstract class DotnetCompile
          extends DotnetBaseMatchingTask {
 
+    private static final int DEFAULT_WARN_LEVEL = 3;
+
     /**
      *  list of reference classes. (pretty much a classpath equivalent)
      */
@@ -194,7 +196,7 @@
         win32icon = null;
         srcDir = null;
         mainClass = null;
-        warnLevel = 3;
+        warnLevel = DEFAULT_WARN_LEVEL;
         optimize = false;
         debug = true;
         references = null;



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message