Login | Register
My pages Projects Community openCollabNet

Discussions > Commits > svn commit: r126 - trunk/externalTools/MetricsGather/src/metrics

argouml-spl
Discussion topic

Back to topic list

svn commit: r126 - trunk/externalTools/MetricsGather/src/metrics

Author marcusvnac
Full name Marcus Vinícius de Ávila Couto
Date 2010-09-25 13:50:31 PDT
Message Author: marcusvnac
Date: 2010-09-25 13:50:30-0700
New Revision: 126

Modified:
   trunk/externalTools/​MetricsGather/src/me​trics/GatherMetrics.​java
   trunk/externalTools/​MetricsGather/src/me​trics/MetricsProcess​or.java

Log:
Review package counter.

Modified: trunk/externalTools/​MetricsGather/src/me​trics/GatherMetrics.​java
Url: http://argouml-spl.t​igris.org/source/bro​wse/argouml-spl/trun​k/externalTools/Metr​icsGather/src/metric​s/GatherMetrics.java​?view=diff&pathr​ev=126&r1=125​&r2=126
====================​====================​====================​==================
--- trunk/externalTools/​MetricsGather/src/me​trics/GatherMetrics.​java (original)
+++ trunk/externalTools/​MetricsGather/src/me​trics/GatherMetrics.​java 2010-09-25 13:50:30-0700
@@ -9,9 +9,6 @@
 
 import util.Log;
 
-
-
-
 public class GatherMetrics {
 
     /**
@@ -29,6 +26,8 @@
      */
     private static Integer PACKAGE_COUNTER;
     
+ private static Boolean HasValidJavaFile;
+
     
     /**
      * Filtro de diretórios.
@@ -56,6 +55,7 @@
     FilenameFilter javaFileFilter = new FilenameFilter() {
         public boolean accept(File dir, String name) {
             return name.endsWith(".java");
+// && name.equals("Agency.java");
             }
         };
         
@@ -67,6 +67,7 @@
         this.rootDir = rootDir.replace("\\", File.separator);
         metricsProcessor = new MetricsProcessor();
         PACKAGE_COUNTER = 0;
+ HasValidJavaFile = false;
     }
     
     /**
@@ -99,16 +100,18 @@
             processFile(new File(dir, children[i]));
         }
         // Se foi processado algum arquivo do diretório, considerar o pacote
- if (i > 0) {
+ if (HasValidJavaFile && (i > 0)) {
             PACKAGE_COUNTER++;
         }
     }
     
     private void processFile(File file) {
         try {
- BufferedReader br = new BufferedReader(new FileReader(file));
+ BufferedReader br = new BufferedReader(new FileReader(file));
+ HasValidJavaFile = br.ready();
             while (br.ready()) {
                 metricsProcessor.ins​ertMetric(br.readLin​e().trim());
+
             }
             br.close();
         } catch (FileNotFoundException e) {

Modified: trunk/externalTools/​MetricsGather/src/me​trics/MetricsProcess​or.java
Url: http://argouml-spl.t​igris.org/source/bro​wse/argouml-spl/trun​k/externalTools/Metr​icsGather/src/metric​s/MetricsProcessor.j​ava?view=diff&pa​threv=126&r1=125​&r2=126
====================​====================​====================​==================
--- trunk/externalTools/​MetricsGather/src/me​trics/MetricsProcess​or.java (original)
+++ trunk/externalTools/​MetricsGather/src/me​trics/MetricsProcess​or.java 2010-09-25 13:50:30-0700
@@ -118,18 +118,19 @@
         if (line.startsWith("/*")) {
             if (line.endsWith("*/")) {
                 return true;
- }
- startComment = true;
- return true;
+ } else if (!line.contains("*/")) {
+ startComment = true;
+ return true;
+ }
         } else if (startComment && line.endsWith("*/")) {
             startComment = false;
             return true;
- }
- if (startComment) {
+ } else if (startComment) {
             return true;
         } else {
             return (line.startsWith("//") || line.startsWith("*") || line.isEmpty());
         }
+ return false;
     }
     
     /**
@@ -161,14 +162,15 @@
         else if (value.matches("//#if defined\\(.*\\) (and|or) defined\\(.*\\)")) {
             String feature1 = value.substring(valu​e.indexOf("(")+1, value.indexOf(")"));
             String feature2 = value.substring(valu​e.lastIndexOf("(")+1​, value.lastIndexOf(")"));
-
- if (value.toLowerCase()​.contains(MetricType​.OR.getIdentifier().​toLowerCase())) {
- insertMetric(String.​format(FAKEMETRICIDE​NTIFIER, feature1, MetricType.OR.getIdentifier()), MetricType.OR);
- insertMetric(String.​format(FAKEMETRICIDE​NTIFIER, feature2, MetricType.OR.getIdentifier()), MetricType.OR);
+
+ MetricType type;
+ if (value.toLowerCase()​.contains(MetricType​.OR.getIdentifier().​toLowerCase())) {
+ type = MetricType.OR;
             } else {
- insertMetric(String.​format(FAKEMETRICIDE​NTIFIER, feature1, MetricType.AND.getId​entifier()), MetricType.AND);
- insertMetric(String.​format(FAKEMETRICIDE​NTIFIER, feature2, MetricType.AND.getId​entifier()), MetricType.AND);
+ type = MetricType.AND;
             }
+ insertMetric(String.​format(FAKEMETRICIDE​NTIFIER, feature1, type.getIdentifier()), type);
+ insertMetric(String.​format(FAKEMETRICIDE​NTIFIER, feature2, type.getIdentifier()), type);
         }
         // LOC Metric
         else if (!isCommentOrBlankLine(value)) {
@@ -178,8 +180,6 @@
                 CLASS_COUNTER++;
             }
         }
-
-
     }
     
     /**

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r126 - trunk/externalTools/MetricsGather/src/metrics marcusvnac Marcus Vinícius de Ávila Couto 2010-09-25 13:50:31 PDT
Messages per page: