diff --git a/log4j.properties b/log4j.properties new file mode 100644 index 0000000..b10ba2b --- /dev/null +++ b/log4j.properties @@ -0,0 +1,5 @@ +log4j.rootLogger=INFO, stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n \ No newline at end of file diff --git a/src/com/o3smeasures/builder/ClassBuilder.java b/src/com/o3smeasures/builder/ClassBuilder.java index 4ace4e1..0ab29d4 100644 --- a/src/com/o3smeasures/builder/ClassBuilder.java +++ b/src/com/o3smeasures/builder/ClassBuilder.java @@ -57,6 +57,7 @@ public void build(Measure measure, ItemMeasured item) { classItem.addValue(measure.getCalculatedValue()); classItem.addMean(measure.getMeanValue()); classItem.setMax(measure.getMaxValue()); + classItem.setMin(measure.getMinValue()); classItem.setClassWithMax(measure.getClassWithMaxValue()); if (measure.isApplicableGranularity(Granularity.METHOD)) { @@ -64,11 +65,13 @@ public void build(Measure measure, ItemMeasured item) { item.addValue(classItem.getValue()); item.addMean(classItem.getMean()); item.setMax(classItem.getMax()); + item.setMin(classItem.getMin()); item.setClassWithMax(classItem.getClassWithMax()); } else { item.addValue(measure.getCalculatedValue()); item.addMean(measure.getMeanValue()); item.setMax(measure.getMaxValue()); + item.setMin(measure.getMinValue()); item.setClassWithMax(measure.getClassWithMaxValue()); } item.addChild(classItem); diff --git a/src/com/o3smeasures/builder/MethodBuilder.java b/src/com/o3smeasures/builder/MethodBuilder.java index 5f86898..64c9499 100644 --- a/src/com/o3smeasures/builder/MethodBuilder.java +++ b/src/com/o3smeasures/builder/MethodBuilder.java @@ -46,6 +46,7 @@ public void build(Measure measure, ItemMeasured item) { item.addValue(measure.getCalculatedValue()); item.addMean(measure.getMeanValue()); item.setMax(measure.getMaxValue()); + item.setMin(measure.getMinValue()); item.setClassWithMax(measure.getClassWithMaxValue()); item.addChild(methodItem); } diff --git a/src/com/o3smeasures/builder/PackageBuilder.java b/src/com/o3smeasures/builder/PackageBuilder.java index a43cb79..abe4135 100644 --- a/src/com/o3smeasures/builder/PackageBuilder.java +++ b/src/com/o3smeasures/builder/PackageBuilder.java @@ -60,6 +60,7 @@ public void build(Measure measure, ItemMeasured item) { addClassBuilder(measure, myPackage, packageMeasured); item.addChild(packageMeasured); item.setMax(packageMeasured.getMax()); + item.setMin(packageMeasured.getMin()); item.setClassWithMax(packageMeasured.getClassWithMax()); item.addValue(packageMeasured.getValue()); item.addMean(packageMeasured.getMean()); diff --git a/src/com/o3smeasures/measures/CouplingBetweenObjects.java b/src/com/o3smeasures/measures/CouplingBetweenObjects.java index 2f0b47e..531120e 100644 --- a/src/com/o3smeasures/measures/CouplingBetweenObjects.java +++ b/src/com/o3smeasures/measures/CouplingBetweenObjects.java @@ -9,6 +9,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.astvisitors.CouplingBetweenObjectsVisitor; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -28,14 +29,16 @@ public class CouplingBetweenObjects extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; - private boolean isEnable; - + private boolean isEnable; + public CouplingBetweenObjects(){ super(); this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.CLASS); @@ -46,7 +49,7 @@ public CouplingBetweenObjects(){ */ @Override public String getName() { - return "Coupling between Objects"; + return MeasuresEnum.CBO.getName(); } /** @@ -54,7 +57,7 @@ public String getName() { */ @Override public String getAcronym() { - return "CBO"; + return MeasuresEnum.CBO.getAcronym(); } /** @@ -71,7 +74,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -136,7 +139,6 @@ public boolean isEnable() { @Override public void setEnable(boolean isEnable) { this.isEnable = isEnable; - } /** @@ -172,6 +174,7 @@ public void measure(T unit) { } setMaxValue(getCalculatedValue(), elementName); + setMinValue(getCalculatedValue()); } /** @@ -222,4 +225,10 @@ public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/CyclomaticComplexity.java b/src/com/o3smeasures/measures/CyclomaticComplexity.java index 3f7f74c..93305aa 100644 --- a/src/com/o3smeasures/measures/CyclomaticComplexity.java +++ b/src/com/o3smeasures/measures/CyclomaticComplexity.java @@ -5,6 +5,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.astvisitors.CyclomaticComplexityVisitor; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -21,14 +22,16 @@ public class CyclomaticComplexity extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; - + public CyclomaticComplexity(){ super(); this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.CLASS); @@ -39,7 +42,7 @@ public CyclomaticComplexity(){ */ @Override public String getName() { - return "Cyclomatic Complexity"; + return MeasuresEnum.CC.getName(); } /** @@ -47,7 +50,7 @@ public String getName() { */ @Override public String getAcronym() { - return "CC"; + return MeasuresEnum.CC.getAcronym(); } /** @@ -64,7 +67,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -129,7 +132,6 @@ public boolean isEnable() { @Override public void setEnable(boolean isEnable) { this.isEnable = isEnable; - } /** @@ -156,6 +158,7 @@ public void measure(T unit) { } setMaxValue(getCalculatedValue(), elementName); + setMinValue(getCalculatedValue()); } /** @@ -207,4 +210,10 @@ public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/DepthOfInheritanceTree.java b/src/com/o3smeasures/measures/DepthOfInheritanceTree.java index 79e14d2..7cc5a7f 100644 --- a/src/com/o3smeasures/measures/DepthOfInheritanceTree.java +++ b/src/com/o3smeasures/measures/DepthOfInheritanceTree.java @@ -4,6 +4,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.javamodel.DepthOfInheritanceTreeJavaModel; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -20,6 +21,7 @@ public class DepthOfInheritanceTree extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; @@ -28,6 +30,7 @@ public DepthOfInheritanceTree(){ this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.PACKAGE); @@ -38,7 +41,7 @@ public DepthOfInheritanceTree(){ */ @Override public String getName() { - return "Depth of Inheritance Tree"; + return MeasuresEnum.DIT.getName(); } /** @@ -46,7 +49,7 @@ public String getName() { */ @Override public String getAcronym() { - return "DIT"; + return MeasuresEnum.DIT.getAcronym(); } /** @@ -62,7 +65,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -127,7 +130,6 @@ public boolean isEnable() { @Override public void setEnable(boolean isEnable) { this.isEnable = isEnable; - } /** @@ -143,6 +145,7 @@ public void measure(T unit) { setCalculatedValue(Math.abs(ditJavaModel.getDitValue())); setMeanValue(getCalculatedValue()); setMaxValue(getCalculatedValue(), ((ICompilationUnit) unit).getElementName()); + setMinValue(getCalculatedValue()); } /** @@ -182,4 +185,10 @@ public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/FanOut.java b/src/com/o3smeasures/measures/FanOut.java index a9f7c0e..067c442 100644 --- a/src/com/o3smeasures/measures/FanOut.java +++ b/src/com/o3smeasures/measures/FanOut.java @@ -5,6 +5,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.astvisitors.FanOutVisitor; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -21,14 +22,16 @@ public class FanOut extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; - + public FanOut(){ super(); this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.PACKAGE); @@ -39,7 +42,7 @@ public FanOut(){ */ @Override public String getName() { - return "Fan-out"; + return MeasuresEnum.FAN_OUT.getName(); } /** @@ -47,7 +50,7 @@ public String getName() { */ @Override public String getAcronym() { - return "FOUT"; + return MeasuresEnum.FAN_OUT.getAcronym(); } /** @@ -63,7 +66,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -128,7 +131,6 @@ public boolean isEnable() { @Override public void setEnable(boolean isEnable) { this.isEnable = isEnable; - } /** @@ -155,6 +157,7 @@ public void measure(T unit) { } setMaxValue(getCalculatedValue(), elementName); + setMinValue(getCalculatedValue()); } /** @@ -205,4 +208,10 @@ public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/LackCohesionMethods.java b/src/com/o3smeasures/measures/LackCohesionMethods.java index c99d7d1..9279309 100644 --- a/src/com/o3smeasures/measures/LackCohesionMethods.java +++ b/src/com/o3smeasures/measures/LackCohesionMethods.java @@ -4,6 +4,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.javamodel.LackCohesionMethodsJavaModel; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -19,14 +20,16 @@ public class LackCohesionMethods extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; - + public LackCohesionMethods(){ super(); this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.CLASS); @@ -37,7 +40,7 @@ public LackCohesionMethods(){ */ @Override public String getName() { - return "Lack of Cohesion of Methods"; + return MeasuresEnum.LCOM.getName(); } /** @@ -45,7 +48,7 @@ public String getName() { */ @Override public String getAcronym() { - return "LCOM"; + return MeasuresEnum.LCOM.getAcronym(); } /** @@ -61,7 +64,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -142,6 +145,7 @@ public void measure(T unit) { setCalculatedValue(lcomJavaModel.getLcomValue()); setMeanValue(getCalculatedValue()); setMaxValue(getCalculatedValue(), ((ICompilationUnit) unit).getElementName()); + setMinValue(getCalculatedValue()); } /** @@ -180,4 +184,11 @@ public String getClassWithMaxValue() { public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/LackCohesionMethodsFour.java b/src/com/o3smeasures/measures/LackCohesionMethodsFour.java index db04c54..508f80b 100644 --- a/src/com/o3smeasures/measures/LackCohesionMethodsFour.java +++ b/src/com/o3smeasures/measures/LackCohesionMethodsFour.java @@ -4,6 +4,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.javamodel.LackCohesionMethodsJavaModel; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -22,14 +23,16 @@ public class LackCohesionMethodsFour extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; - + public LackCohesionMethodsFour(){ super(); this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.CLASS); @@ -40,7 +43,7 @@ public LackCohesionMethodsFour(){ */ @Override public String getName() { - return "Lack of Cohesion of Methods 4"; + return MeasuresEnum.LCOM4.getName(); } /** @@ -48,7 +51,7 @@ public String getName() { */ @Override public String getAcronym() { - return "LCOM4"; + return MeasuresEnum.LCOM4.getAcronym(); } /** @@ -68,7 +71,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -149,6 +152,7 @@ public void measure(T unit) { setCalculatedValue(lcomJavaModel.getLcom4Value()); setMeanValue(getCalculatedValue()); setMaxValue(getCalculatedValue(), ((ICompilationUnit) unit).getElementName()); + setMinValue(getCalculatedValue()); } /** @@ -187,4 +191,11 @@ public String getClassWithMaxValue() { public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/LackCohesionMethodsTwo.java b/src/com/o3smeasures/measures/LackCohesionMethodsTwo.java index 9c10c3d..90f0591 100644 --- a/src/com/o3smeasures/measures/LackCohesionMethodsTwo.java +++ b/src/com/o3smeasures/measures/LackCohesionMethodsTwo.java @@ -4,6 +4,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.javamodel.LackCohesionMethodsJavaModel; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -21,14 +22,16 @@ public class LackCohesionMethodsTwo extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; - + public LackCohesionMethodsTwo(){ super(); this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.CLASS); @@ -39,7 +42,7 @@ public LackCohesionMethodsTwo(){ */ @Override public String getName() { - return "Lack of Cohesion of Methods 2"; + return MeasuresEnum.LCOM2.getName(); } /** @@ -47,7 +50,7 @@ public String getName() { */ @Override public String getAcronym() { - return "LCOM2"; + return MeasuresEnum.LCOM2.getAcronym(); } /** @@ -66,7 +69,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -147,6 +150,7 @@ public void measure(T unit) { setCalculatedValue(lcomJavaModel.getLcom2Value()); setMeanValue(getCalculatedValue()); setMaxValue(getCalculatedValue(), ((ICompilationUnit) unit).getElementName()); + setMinValue(getCalculatedValue()); } /** @@ -186,4 +190,10 @@ public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/LinesOfCode.java b/src/com/o3smeasures/measures/LinesOfCode.java index 76293a1..1db92ea 100644 --- a/src/com/o3smeasures/measures/LinesOfCode.java +++ b/src/com/o3smeasures/measures/LinesOfCode.java @@ -5,6 +5,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.astvisitors.LinesOfCodeVisitor; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -20,14 +21,16 @@ public class LinesOfCode extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; - + public LinesOfCode(){ super(); this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.PROJECT); @@ -38,7 +41,7 @@ public LinesOfCode(){ */ @Override public String getName() { - return "Lines of Code"; + return MeasuresEnum.LOC.getName(); } /** @@ -46,7 +49,7 @@ public String getName() { */ @Override public String getAcronym() { - return "LOC"; + return MeasuresEnum.LOC.getAcronym(); } /** @@ -62,7 +65,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -153,6 +156,7 @@ public void measure(T unit) { } setMaxValue(getCalculatedValue(), elementName); + setMinValue(getCalculatedValue()); } /** @@ -203,4 +207,10 @@ public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/LooseClassCohesion.java b/src/com/o3smeasures/measures/LooseClassCohesion.java index d2ad40c..87f5f9c 100644 --- a/src/com/o3smeasures/measures/LooseClassCohesion.java +++ b/src/com/o3smeasures/measures/LooseClassCohesion.java @@ -5,6 +5,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.astvisitors.LooseClassCohesionVisitor; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -21,14 +22,16 @@ public class LooseClassCohesion extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; - + public LooseClassCohesion(){ super(); this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.CLASS); @@ -39,7 +42,7 @@ public LooseClassCohesion(){ */ @Override public String getName() { - return "Loose Class Cohesion"; + return MeasuresEnum.LCC.getName(); } /** @@ -47,7 +50,7 @@ public String getName() { */ @Override public String getAcronym() { - return "LCC"; + return MeasuresEnum.LCC.getAcronym(); } /** @@ -64,7 +67,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -129,7 +132,6 @@ public boolean isEnable() { @Override public void setEnable(boolean isEnable) { this.isEnable = isEnable; - } /** @@ -156,6 +158,7 @@ public void measure(T unit) { } setMaxValue(getCalculatedValue(), elementName); + setMinValue(getCalculatedValue()); } /** @@ -206,4 +209,10 @@ public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/NumberOfAttributes.java b/src/com/o3smeasures/measures/NumberOfAttributes.java index e3db2e1..b528938 100644 --- a/src/com/o3smeasures/measures/NumberOfAttributes.java +++ b/src/com/o3smeasures/measures/NumberOfAttributes.java @@ -5,6 +5,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.astvisitors.NumberOfAttributesVisitor; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -20,14 +21,16 @@ public class NumberOfAttributes extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; - + public NumberOfAttributes(){ super(); this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.PROJECT); @@ -38,7 +41,7 @@ public NumberOfAttributes(){ */ @Override public String getName() { - return "Number of Attributes"; + return MeasuresEnum.NOA.getName(); } /** @@ -46,7 +49,7 @@ public String getName() { */ @Override public String getAcronym() { - return "NOA"; + return MeasuresEnum.NOA.getAcronym(); } /** @@ -62,7 +65,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -154,6 +157,7 @@ public void measure(T unit) { } setMaxValue(getCalculatedValue(), elementName); + setMinValue(getCalculatedValue()); } /** @@ -204,4 +208,10 @@ public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/NumberOfChildren.java b/src/com/o3smeasures/measures/NumberOfChildren.java index 3ea4916..44dd953 100644 --- a/src/com/o3smeasures/measures/NumberOfChildren.java +++ b/src/com/o3smeasures/measures/NumberOfChildren.java @@ -4,6 +4,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.javamodel.NumberOfChildrenJavaModel; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -20,14 +21,16 @@ public class NumberOfChildren extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; - + public NumberOfChildren(){ super(); this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.CLASS); @@ -38,7 +41,7 @@ public NumberOfChildren(){ */ @Override public String getName() { - return "Number of Children"; + return MeasuresEnum.NOC.getName(); } /** @@ -46,7 +49,7 @@ public String getName() { */ @Override public String getAcronym() { - return "NOC"; + return MeasuresEnum.NOC.getAcronym(); } /** @@ -62,7 +65,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -142,6 +145,7 @@ public void measure(T unit) { setCalculatedValue(Math.abs(nocJavaModel.getNocValue())); setMeanValue(getCalculatedValue()); setMaxValue(getCalculatedValue(), ((ICompilationUnit) unit).getElementName()); + setMinValue(getCalculatedValue()); } /** @@ -181,4 +185,10 @@ public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/NumberOfClasses.java b/src/com/o3smeasures/measures/NumberOfClasses.java index d819cf5..ef5fe25 100644 --- a/src/com/o3smeasures/measures/NumberOfClasses.java +++ b/src/com/o3smeasures/measures/NumberOfClasses.java @@ -4,6 +4,7 @@ import org.eclipse.jdt.core.dom.TypeDeclaration; import com.o3smeasures.astvisitors.ClassVisitor; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -20,14 +21,16 @@ public class NumberOfClasses extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; - + public NumberOfClasses(){ super(); this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.PROJECT); @@ -38,7 +41,7 @@ public NumberOfClasses(){ */ @Override public String getName() { - return "Number of Classes"; + return MeasuresEnum.NC.getName(); } /** @@ -46,7 +49,7 @@ public String getName() { */ @Override public String getAcronym() { - return "NC"; + return MeasuresEnum.NC.getAcronym(); } /** @@ -70,7 +73,7 @@ public String getProperty() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -162,6 +165,7 @@ public void measure(T unit) { } setMaxValue(getCalculatedValue(), elementName); + setMinValue(getCalculatedValue()); } /** @@ -202,4 +206,10 @@ public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/NumberOfMethods.java b/src/com/o3smeasures/measures/NumberOfMethods.java index 5207c0a..5897244 100644 --- a/src/com/o3smeasures/measures/NumberOfMethods.java +++ b/src/com/o3smeasures/measures/NumberOfMethods.java @@ -5,6 +5,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.astvisitors.NumberOfMethodsVisitor; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -21,6 +22,7 @@ public class NumberOfMethods extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; @@ -29,6 +31,7 @@ public NumberOfMethods(){ this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.PROJECT); @@ -39,7 +42,7 @@ public NumberOfMethods(){ */ @Override public String getName() { - return "Number of Methods"; + return MeasuresEnum.NOM.getName(); } /** @@ -47,7 +50,7 @@ public String getName() { */ @Override public String getAcronym() { - return "NOM"; + return MeasuresEnum.NOM.getAcronym(); } /** @@ -63,7 +66,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -155,6 +158,7 @@ public void measure(T unit) { } setMaxValue(getCalculatedValue(), elementName); + setMinValue(getCalculatedValue()); } /** @@ -204,4 +208,11 @@ public String getClassWithMaxValue() { public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/ResponseForClass.java b/src/com/o3smeasures/measures/ResponseForClass.java index d929e99..366ee91 100644 --- a/src/com/o3smeasures/measures/ResponseForClass.java +++ b/src/com/o3smeasures/measures/ResponseForClass.java @@ -10,6 +10,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.astvisitors.ResponseForClassVisitor; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -28,14 +29,16 @@ public class ResponseForClass extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; - + public ResponseForClass(){ super(); this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.CLASS); @@ -46,7 +49,7 @@ public ResponseForClass(){ */ @Override public String getName() { - return "Response for Class"; + return MeasuresEnum.RFC.getName(); } /** @@ -54,7 +57,7 @@ public String getName() { */ @Override public String getAcronym() { - return "RFC"; + return MeasuresEnum.RFC.getAcronym(); } /** @@ -74,7 +77,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -178,6 +181,7 @@ public void measure(T unit) { } setMaxValue(getCalculatedValue(), elementName); + setMinValue(getCalculatedValue()); } /** @@ -228,4 +232,10 @@ public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/TightClassCohesion.java b/src/com/o3smeasures/measures/TightClassCohesion.java index ec43cf5..1fb5ec6 100644 --- a/src/com/o3smeasures/measures/TightClassCohesion.java +++ b/src/com/o3smeasures/measures/TightClassCohesion.java @@ -5,6 +5,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.astvisitors.TightClassCohesionVisitor; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -21,14 +22,16 @@ public class TightClassCohesion extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; - + public TightClassCohesion(){ super(); this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.CLASS); @@ -39,7 +42,7 @@ public TightClassCohesion(){ */ @Override public String getName() { - return "Tight Class Cohesion"; + return MeasuresEnum.TCC.getName(); } /** @@ -47,7 +50,7 @@ public String getName() { */ @Override public String getAcronym() { - return "TCC"; + return MeasuresEnum.TCC.getAcronym(); } /** @@ -64,7 +67,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -155,6 +158,7 @@ public void measure(T unit) { } setMaxValue(getCalculatedValue(), elementName); + setMinValue(getCalculatedValue()); } /** @@ -205,4 +209,10 @@ public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/WeightMethodsPerClass.java b/src/com/o3smeasures/measures/WeightMethodsPerClass.java index ba63f67..3961426 100644 --- a/src/com/o3smeasures/measures/WeightMethodsPerClass.java +++ b/src/com/o3smeasures/measures/WeightMethodsPerClass.java @@ -5,6 +5,7 @@ import com.o3smeasures.astvisitors.ClassVisitor; import com.o3smeasures.astvisitors.WeightMethodsPerClassVisitor; +import com.o3smeasures.measures.enumeration.MeasuresEnum; import com.o3smeasures.structures.Measure; /** @@ -21,6 +22,7 @@ public class WeightMethodsPerClass extends Measure{ private double value; private double mean; private double max; + private double min; private String classWithMaxValue; private boolean isEnable; @@ -29,6 +31,7 @@ public WeightMethodsPerClass(){ this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; this.isEnable = true; addApplicableGranularity(Granularity.CLASS); @@ -39,7 +42,7 @@ public WeightMethodsPerClass(){ */ @Override public String getName() { - return "Weight Methods per Class"; + return MeasuresEnum.WMC.getName(); } /** @@ -47,7 +50,7 @@ public String getName() { */ @Override public String getAcronym() { - return "WMC"; + return MeasuresEnum.WMC.getAcronym(); } /** @@ -63,7 +66,7 @@ public String getDescription() { */ @Override public double getMinValue() { - return 0d; + return min; } /** @@ -154,6 +157,7 @@ public void measure(T unit) { } setMaxValue(getCalculatedValue(), elementName); + setMinValue(getCalculatedValue()); } /** @@ -204,4 +208,11 @@ public void setClassWithMaxValue(String value) { this.classWithMaxValue = value; } + + @Override + public void setMinValue(double value) { + if (min > value || min == 0d){ + this.min = value; + } + } } diff --git a/src/com/o3smeasures/measures/enumeration/MeasuresEnum.java b/src/com/o3smeasures/measures/enumeration/MeasuresEnum.java new file mode 100644 index 0000000..ec4fea3 --- /dev/null +++ b/src/com/o3smeasures/measures/enumeration/MeasuresEnum.java @@ -0,0 +1,38 @@ +package com.o3smeasures.measures.enumeration; + +public enum MeasuresEnum { + + CBO("CBO", "Coupling between Objects"), + CC("CC", "Cyclomatic Complexity"), + DIT("DIT", "Depth of Inheritance Tree"), + FAN_OUT("FOUT", "Fan-out"), + LCOM("LCOM", "Lack of Cohesion of Methods"), + LCOM2("LCOM2", "Lack of Cohesion of Methods 2"), + LCOM4("LCOM4", "Lack of Cohesion of Methods 4"), + LOC("LOC", "Lines of Code"), + LCC("LCC", "Loose Class Cohesion"), + NOA("NOA", "Number of Attributes"), + NOC("NOC", "Number of Children"), + NC("NC", "Number of Classes"), + NOM("NOM", "Number of Methods"), + RFC("RFC", "Response for Class"), + TCC("TCC", "Tight and Loose Class Cohesion"), + WMC("WMC", "Weight Methods per Class"); + + private String acronym; + private String name; + + private MeasuresEnum(String acronym, String name) { + this.acronym = acronym; + this.name = name; + } + + public String getAcronym() { + return acronym; + } + + public String getName() { + return name; + } + +} diff --git a/src/com/o3smeasures/plugin/views/SampleView.java b/src/com/o3smeasures/plugin/views/SampleView.java index ffcebfc..e7af129 100644 --- a/src/com/o3smeasures/plugin/views/SampleView.java +++ b/src/com/o3smeasures/plugin/views/SampleView.java @@ -139,30 +139,56 @@ public String getText(Object element) { return element.toString(); } }); - + column = fulfillColumn(100, "Value"); + createLabelProviderValueColumn(column); + + column = fulfillColumn(100, "Mean Value per Class"); + createLabelProviderMeanColumn(column); + + column = fulfillColumn(100, "Min Value"); + createLabelProviderMinColumn(column); + + column = fulfillColumn(100, "Max Value"); + createLabelProviderMaxColumn(column); + + column = fulfillColumn(100, "Resource with Max Value"); + createLabelProviderResourceMaxValueColumn(column); + + column = fulfillColumn(100, "Description"); + createLabelProviderDescriptionColumn(column); + + viewer.setContentProvider(new MyContentProvider()); + + createMenuManager(); + } + + private void createLabelProviderDescriptionColumn(TreeViewerColumn column) { + column.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { - if (element instanceof ItemMeasured) { - return formatter.format(((ItemMeasured)element).getValue()); + if ((element instanceof ItemMeasured) && ((ItemMeasured) element).getMeasure() != null) { + return ((ItemMeasured) element).getMeasure().getDescription(); } return ""; } }); - - column = fulfillColumn(100, "Mean Value per Class"); + } + + private void createLabelProviderResourceMaxValueColumn(TreeViewerColumn column) { column.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { - if (element instanceof ItemMeasured) { - return formatter.format(((ItemMeasured)element).getMean()); + if ((element instanceof ItemMeasured) && ((ItemMeasured) element).getParent() != null) { + return ((ItemMeasured) element).getClassWithMax(); } return ""; } }); - - column = fulfillColumn(100, "Max Value"); + } + + private void createLabelProviderMaxColumn(TreeViewerColumn column) { column.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { @@ -172,34 +198,45 @@ public String getText(Object element) { return ""; } }); - - column = fulfillColumn(100, "Resource with Max Value"); + } + + private void createLabelProviderMinColumn(TreeViewerColumn column) { column.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if ((element instanceof ItemMeasured) && ((ItemMeasured) element).getParent() != null) { - return ((ItemMeasured) element).getClassWithMax(); + return formatter.format(((ItemMeasured) element).getMin()); } return ""; } }); + } - column = fulfillColumn(100, "Description"); + private void createLabelProviderMeanColumn(TreeViewerColumn column) { column.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { - if ((element instanceof ItemMeasured) && ((ItemMeasured) element).getMeasure() != null) { - return ((ItemMeasured) element).getMeasure().getDescription(); + if (element instanceof ItemMeasured) { + return formatter.format(((ItemMeasured)element).getMean()); } return ""; } }); - - viewer.setContentProvider(new MyContentProvider()); - - createMenuManager(); } + private void createLabelProviderValueColumn(TreeViewerColumn column) { + column.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + if (element instanceof ItemMeasured) { + return formatter.format(((ItemMeasured)element).getValue()); + } + return ""; + } + }); + } + + /** * Method to fulfill column basic informations * @param width diff --git a/src/com/o3smeasures/structures/ItemMeasured.java b/src/com/o3smeasures/structures/ItemMeasured.java index 5a856b1..7f1ee1b 100644 --- a/src/com/o3smeasures/structures/ItemMeasured.java +++ b/src/com/o3smeasures/structures/ItemMeasured.java @@ -25,8 +25,10 @@ public class ItemMeasured { @XmlElement(pos = 3) private Double mean; @XmlElement(pos = 4) - private Double max; + private Double min; @XmlElement(pos = 5) + private Double max; + @XmlElement(pos = 6) private String classWithMaxValue; private ItemMeasured parent; private List children; @@ -41,11 +43,13 @@ public ItemMeasured(String name, ItemMeasured parent) { this.value = 0d; this.mean = 0d; this.max = 0d; + this.min = 0d; this.classWithMaxValue = ""; } /** * Method to get the name of the item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @return String @@ -56,6 +60,7 @@ public String getName(){ /** * Method to get the parent of the item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @return ItemMeasured @@ -66,6 +71,7 @@ public ItemMeasured getParent(){ /** * Method to set the parent of the item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @param item @@ -76,6 +82,7 @@ public void setParent(ItemMeasured item){ /** * Method to get the children of the item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @return List @@ -86,6 +93,7 @@ public List getChildren(){ /** * Method to add a child in a list of item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @param item @@ -96,6 +104,7 @@ public void addChild(ItemMeasured item){ /** * Method to get the value of the item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @return double @@ -106,6 +115,7 @@ public double getValue(){ /** * Method to set the value of the item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @param value @@ -116,6 +126,7 @@ public void setValue(double value){ /** * Method to add a value in the list of item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @param value @@ -126,6 +137,7 @@ public void addValue(double value){ /** * Method to get the mean of the item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @return double @@ -136,6 +148,7 @@ public double getMean(){ /** * Method to set the mean of the item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @param mean @@ -146,6 +159,7 @@ public void setMean(double mean){ /** * Method to add the mean in the list of item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @param mean @@ -156,6 +170,7 @@ public void addMean(double mean){ /** * Method to get the max value of the item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @return double @@ -166,6 +181,7 @@ public double getMax(){ /** * Method to set the max value of the item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @param max @@ -176,6 +192,7 @@ public void setMax(double max){ /** * Method to get the class with the max value of the item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @return double @@ -186,6 +203,7 @@ public String getClassWithMax(){ /** * Method to set the class with the max value of the item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @param classWithMaxValue @@ -196,6 +214,7 @@ public void setClassWithMax(String classWithMaxValue){ /** * Method to get the measure represented by the item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @return Measure @@ -206,6 +225,7 @@ public Measure getMeasure() { /** * Method to set the measure represented by the item measured. + * * @author Mariana Azevedo * @since 13/07/2014 * @param measure @@ -213,6 +233,28 @@ public Measure getMeasure() { public void setMeasure(Measure measure) { this.measure = measure; } + + /** + * Method to get the min value of the item measured. + * + * @author Mariana Azevedo + * @since 23/02/2019 + * @return double + */ + public double getMin() { + return min; + } + + /** + * Method to set the min value of the item measured. + * + * @author Mariana Azevedo + * @since 23/02/2019 + * @param measure + */ + public void setMin(double min) { + this.min = min; + } /** * @see String#toString() diff --git a/src/com/o3smeasures/structures/Measure.java b/src/com/o3smeasures/structures/Measure.java index 0ce40f9..8b588cb 100644 --- a/src/com/o3smeasures/structures/Measure.java +++ b/src/com/o3smeasures/structures/Measure.java @@ -41,6 +41,7 @@ public Measure(){ /** * Method to apply the granularity in a measure. + * * @author Mariana Azevedo * @since 13/07/2014 * @param granularity @@ -53,6 +54,7 @@ public void addApplicableGranularity(Granularity granularity){ /** * Method to get all granularities. + * * @author Mariana Azevedo * @since 13/07/2014 * @return List @@ -63,6 +65,7 @@ public List getAllApplicableGranularities(){ /** * Method to verify the measurs granularities. + * * @author Mariana Azevedo * @since 13/07/2014 * @param granularity @@ -75,6 +78,7 @@ public boolean isApplicableGranularity(Granularity granularity){ /** * Reads a ICompilationUnit and creates the AST DOM for manipulating the * java source file. + * * @author Mariana Azevedo * @since 13/07/2014 * @param @@ -110,6 +114,7 @@ public CompilationUnit parse(T unit) { /** * Method to get the measure's name. + * * @author Mariana Azevedo * @since 13/07/2014 * @return String @@ -118,6 +123,7 @@ public CompilationUnit parse(T unit) { /** * Method to get the measure's acronym. + * * @author Mariana Azevedo * @since 13/07/2014 * @return String @@ -126,6 +132,7 @@ public CompilationUnit parse(T unit) { /** * Method to get the measure's description. + * * @author Mariana Azevedo * @since 13/07/2014 * @return String @@ -134,6 +141,7 @@ public CompilationUnit parse(T unit) { /** * Method to get the measure's property. + * * @author Mariana Azevedo * @since 13/07/2014 * @return String @@ -142,6 +150,7 @@ public CompilationUnit parse(T unit) { /** * Method to get the measure's minimum value. + * * @author Mariana Azevedo * @since 13/07/2014 * @return double @@ -150,6 +159,7 @@ public CompilationUnit parse(T unit) { /** * Method to get the measure's maximum value. + * * @author Mariana Azevedo * @since 13/07/2014 * @return double @@ -158,6 +168,7 @@ public CompilationUnit parse(T unit) { /** * Method to get the measure's maximum value. + * * @author Mariana Azevedo * @since 13/07/2014 * @return double @@ -166,6 +177,7 @@ public CompilationUnit parse(T unit) { /** * Method to get the measure's mean value (average value). + * * @author Mariana Azevedo * @since 13/07/2014 * @return double @@ -174,6 +186,7 @@ public CompilationUnit parse(T unit) { /** * Method to get the measure's reference value. + * * @author Mariana Azevedo * @since 13/07/2014 * @return double @@ -182,6 +195,7 @@ public CompilationUnit parse(T unit) { /** * Method to get the measure's calculated value. + * * @author Mariana Azevedo * @since 13/07/2014 * @return double @@ -190,6 +204,7 @@ public CompilationUnit parse(T unit) { /** * Method to set the measure's calculated value. + * * @author Mariana Azevedo * @since 13/07/2014 * @param value @@ -198,6 +213,7 @@ public CompilationUnit parse(T unit) { /** * Method to set the measure's mean value (average value). + * * @author Mariana Azevedo * @since 13/07/2014 * @param value @@ -206,6 +222,7 @@ public CompilationUnit parse(T unit) { /** * Method to set the measure's max value. + * * @author Mariana Azevedo * @since 13/07/2014 * @param value @@ -213,8 +230,18 @@ public CompilationUnit parse(T unit) { */ public abstract void setMaxValue(double value, String className); + /** + * Method to set the measure's max value. + * + * @author Mariana Azevedo + * @since 23/02/2019 + * @param value + */ + public abstract void setMinValue(double value); + /** * Method to set the measure's class with the max value. + * * @author Mariana Azevedo * @since 13/07/2014 * @param value @@ -223,6 +250,7 @@ public CompilationUnit parse(T unit) { /** * Method to get if the measure is enable on the plugin. + * * @author Mariana Azevedo * @since 13/07/2014 * @return boolean @@ -231,14 +259,16 @@ public CompilationUnit parse(T unit) { /** * Method to set if the measure is enable on the plugin. + * * @author Mariana Azevedo * @since 13/07/2014 * @param isEnable */ public abstract void setEnable(boolean isEnable); - + /** * Method to create the AST for the ICompilationUnits. + * * @author Mariana Azevedo * @since 13/07/2014 * @param unit