Skip to content

Commit

Permalink
Implementing min value column and improvements on code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariana Azevedo committed Feb 25, 2019
1 parent 0a617a8 commit 96654af
Show file tree
Hide file tree
Showing 24 changed files with 404 additions and 88 deletions.
5 changes: 5 additions & 0 deletions log4j.properties
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions src/com/o3smeasures/builder/ClassBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,21 @@ 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)) {
addMethodsBuilder(measure, unit, classItem);
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);
Expand Down
1 change: 1 addition & 0 deletions src/com/o3smeasures/builder/MethodBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions src/com/o3smeasures/builder/PackageBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
21 changes: 15 additions & 6 deletions src/com/o3smeasures/measures/CouplingBetweenObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
Expand All @@ -46,15 +49,15 @@ public CouplingBetweenObjects(){
*/
@Override
public String getName() {
return "Coupling between Objects";
return MeasuresEnum.CBO.getName();
}

/**
* @see Measure#getAcronym
*/
@Override
public String getAcronym() {
return "CBO";
return MeasuresEnum.CBO.getAcronym();
}

/**
Expand All @@ -71,7 +74,7 @@ public String getDescription() {
*/
@Override
public double getMinValue() {
return 0d;
return min;
}

/**
Expand Down Expand Up @@ -136,7 +139,6 @@ public boolean isEnable() {
@Override
public void setEnable(boolean isEnable) {
this.isEnable = isEnable;

}

/**
Expand Down Expand Up @@ -172,6 +174,7 @@ public <T> void measure(T unit) {
}

setMaxValue(getCalculatedValue(), elementName);
setMinValue(getCalculatedValue());
}

/**
Expand Down Expand Up @@ -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;
}
}
}
19 changes: 14 additions & 5 deletions src/com/o3smeasures/measures/CyclomaticComplexity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
Expand All @@ -39,15 +42,15 @@ public CyclomaticComplexity(){
*/
@Override
public String getName() {
return "Cyclomatic Complexity";
return MeasuresEnum.CC.getName();
}

/**
* @see Measure#getAcronym
*/
@Override
public String getAcronym() {
return "CC";
return MeasuresEnum.CC.getAcronym();
}

/**
Expand All @@ -64,7 +67,7 @@ public String getDescription() {
*/
@Override
public double getMinValue() {
return 0d;
return min;
}

/**
Expand Down Expand Up @@ -129,7 +132,6 @@ public boolean isEnable() {
@Override
public void setEnable(boolean isEnable) {
this.isEnable = isEnable;

}

/**
Expand All @@ -156,6 +158,7 @@ public <T> void measure(T unit) {
}

setMaxValue(getCalculatedValue(), elementName);
setMinValue(getCalculatedValue());
}

/**
Expand Down Expand Up @@ -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;
}
}
}
17 changes: 13 additions & 4 deletions src/com/o3smeasures/measures/DepthOfInheritanceTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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;

Expand All @@ -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);
Expand All @@ -38,15 +41,15 @@ public DepthOfInheritanceTree(){
*/
@Override
public String getName() {
return "Depth of Inheritance Tree";
return MeasuresEnum.DIT.getName();
}

/**
* @see Measure#getAcronym
*/
@Override
public String getAcronym() {
return "DIT";
return MeasuresEnum.DIT.getAcronym();
}

/**
Expand All @@ -62,7 +65,7 @@ public String getDescription() {
*/
@Override
public double getMinValue() {
return 0d;
return min;
}

/**
Expand Down Expand Up @@ -127,7 +130,6 @@ public boolean isEnable() {
@Override
public void setEnable(boolean isEnable) {
this.isEnable = isEnable;

}

/**
Expand All @@ -143,6 +145,7 @@ public <T> void measure(T unit) {
setCalculatedValue(Math.abs(ditJavaModel.getDitValue()));
setMeanValue(getCalculatedValue());
setMaxValue(getCalculatedValue(), ((ICompilationUnit) unit).getElementName());
setMinValue(getCalculatedValue());
}

/**
Expand Down Expand Up @@ -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;
}
}
}
19 changes: 14 additions & 5 deletions src/com/o3smeasures/measures/FanOut.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
Expand All @@ -39,15 +42,15 @@ public FanOut(){
*/
@Override
public String getName() {
return "Fan-out";
return MeasuresEnum.FAN_OUT.getName();
}

/**
* @see Measure#getAcronym
*/
@Override
public String getAcronym() {
return "FOUT";
return MeasuresEnum.FAN_OUT.getAcronym();
}

/**
Expand All @@ -63,7 +66,7 @@ public String getDescription() {
*/
@Override
public double getMinValue() {
return 0d;
return min;
}

/**
Expand Down Expand Up @@ -128,7 +131,6 @@ public boolean isEnable() {
@Override
public void setEnable(boolean isEnable) {
this.isEnable = isEnable;

}

/**
Expand All @@ -155,6 +157,7 @@ public <T> void measure(T unit) {
}

setMaxValue(getCalculatedValue(), elementName);
setMinValue(getCalculatedValue());
}

/**
Expand Down Expand Up @@ -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;
}
}
}

0 comments on commit 96654af

Please sign in to comment.