Skip to content

Commit 96654af

Browse files
author
Mariana Azevedo
committed
Implementing min value column and improvements on code.
1 parent 0a617a8 commit 96654af

24 files changed

+404
-88
lines changed

log4j.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
log4j.rootLogger=INFO, stdout
2+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
3+
log4j.appender.stdout.Target=System.out
4+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5+
log4j.appender.stdout.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n

src/com/o3smeasures/builder/ClassBuilder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,21 @@ public void build(Measure measure, ItemMeasured item) {
5757
classItem.addValue(measure.getCalculatedValue());
5858
classItem.addMean(measure.getMeanValue());
5959
classItem.setMax(measure.getMaxValue());
60+
classItem.setMin(measure.getMinValue());
6061
classItem.setClassWithMax(measure.getClassWithMaxValue());
6162

6263
if (measure.isApplicableGranularity(Granularity.METHOD)) {
6364
addMethodsBuilder(measure, unit, classItem);
6465
item.addValue(classItem.getValue());
6566
item.addMean(classItem.getMean());
6667
item.setMax(classItem.getMax());
68+
item.setMin(classItem.getMin());
6769
item.setClassWithMax(classItem.getClassWithMax());
6870
} else {
6971
item.addValue(measure.getCalculatedValue());
7072
item.addMean(measure.getMeanValue());
7173
item.setMax(measure.getMaxValue());
74+
item.setMin(measure.getMinValue());
7275
item.setClassWithMax(measure.getClassWithMaxValue());
7376
}
7477
item.addChild(classItem);

src/com/o3smeasures/builder/MethodBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public void build(Measure measure, ItemMeasured item) {
4646
item.addValue(measure.getCalculatedValue());
4747
item.addMean(measure.getMeanValue());
4848
item.setMax(measure.getMaxValue());
49+
item.setMin(measure.getMinValue());
4950
item.setClassWithMax(measure.getClassWithMaxValue());
5051
item.addChild(methodItem);
5152
}

src/com/o3smeasures/builder/PackageBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public void build(Measure measure, ItemMeasured item) {
6060
addClassBuilder(measure, myPackage, packageMeasured);
6161
item.addChild(packageMeasured);
6262
item.setMax(packageMeasured.getMax());
63+
item.setMin(packageMeasured.getMin());
6364
item.setClassWithMax(packageMeasured.getClassWithMax());
6465
item.addValue(packageMeasured.getValue());
6566
item.addMean(packageMeasured.getMean());

src/com/o3smeasures/measures/CouplingBetweenObjects.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import com.o3smeasures.astvisitors.ClassVisitor;
1111
import com.o3smeasures.astvisitors.CouplingBetweenObjectsVisitor;
12+
import com.o3smeasures.measures.enumeration.MeasuresEnum;
1213
import com.o3smeasures.structures.Measure;
1314

1415
/**
@@ -28,14 +29,16 @@ public class CouplingBetweenObjects extends Measure{
2829
private double value;
2930
private double mean;
3031
private double max;
32+
private double min;
3133
private String classWithMaxValue;
32-
private boolean isEnable;
33-
34+
private boolean isEnable;
35+
3436
public CouplingBetweenObjects(){
3537
super();
3638
this.value = 0d;
3739
this.mean = 0d;
3840
this.max = 0d;
41+
this.min = 0d;
3942
this.classWithMaxValue = "";
4043
this.isEnable = true;
4144
addApplicableGranularity(Granularity.CLASS);
@@ -46,15 +49,15 @@ public CouplingBetweenObjects(){
4649
*/
4750
@Override
4851
public String getName() {
49-
return "Coupling between Objects";
52+
return MeasuresEnum.CBO.getName();
5053
}
5154

5255
/**
5356
* @see Measure#getAcronym
5457
*/
5558
@Override
5659
public String getAcronym() {
57-
return "CBO";
60+
return MeasuresEnum.CBO.getAcronym();
5861
}
5962

6063
/**
@@ -71,7 +74,7 @@ public String getDescription() {
7174
*/
7275
@Override
7376
public double getMinValue() {
74-
return 0d;
77+
return min;
7578
}
7679

7780
/**
@@ -136,7 +139,6 @@ public boolean isEnable() {
136139
@Override
137140
public void setEnable(boolean isEnable) {
138141
this.isEnable = isEnable;
139-
140142
}
141143

142144
/**
@@ -172,6 +174,7 @@ public <T> void measure(T unit) {
172174
}
173175

174176
setMaxValue(getCalculatedValue(), elementName);
177+
setMinValue(getCalculatedValue());
175178
}
176179

177180
/**
@@ -222,4 +225,10 @@ public void setClassWithMaxValue(String value) {
222225
this.classWithMaxValue = value;
223226
}
224227

228+
@Override
229+
public void setMinValue(double value) {
230+
if (min > value || min == 0d){
231+
this.min = value;
232+
}
233+
}
225234
}

src/com/o3smeasures/measures/CyclomaticComplexity.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import com.o3smeasures.astvisitors.ClassVisitor;
77
import com.o3smeasures.astvisitors.CyclomaticComplexityVisitor;
8+
import com.o3smeasures.measures.enumeration.MeasuresEnum;
89
import com.o3smeasures.structures.Measure;
910

1011
/**
@@ -21,14 +22,16 @@ public class CyclomaticComplexity extends Measure{
2122
private double value;
2223
private double mean;
2324
private double max;
25+
private double min;
2426
private String classWithMaxValue;
2527
private boolean isEnable;
26-
28+
2729
public CyclomaticComplexity(){
2830
super();
2931
this.value = 0d;
3032
this.mean = 0d;
3133
this.max = 0d;
34+
this.min = 0d;
3235
this.classWithMaxValue = "";
3336
this.isEnable = true;
3437
addApplicableGranularity(Granularity.CLASS);
@@ -39,15 +42,15 @@ public CyclomaticComplexity(){
3942
*/
4043
@Override
4144
public String getName() {
42-
return "Cyclomatic Complexity";
45+
return MeasuresEnum.CC.getName();
4346
}
4447

4548
/**
4649
* @see Measure#getAcronym
4750
*/
4851
@Override
4952
public String getAcronym() {
50-
return "CC";
53+
return MeasuresEnum.CC.getAcronym();
5154
}
5255

5356
/**
@@ -64,7 +67,7 @@ public String getDescription() {
6467
*/
6568
@Override
6669
public double getMinValue() {
67-
return 0d;
70+
return min;
6871
}
6972

7073
/**
@@ -129,7 +132,6 @@ public boolean isEnable() {
129132
@Override
130133
public void setEnable(boolean isEnable) {
131134
this.isEnable = isEnable;
132-
133135
}
134136

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

158160
setMaxValue(getCalculatedValue(), elementName);
161+
setMinValue(getCalculatedValue());
159162
}
160163

161164
/**
@@ -207,4 +210,10 @@ public void setClassWithMaxValue(String value) {
207210
this.classWithMaxValue = value;
208211
}
209212

213+
@Override
214+
public void setMinValue(double value) {
215+
if (min > value || min == 0d){
216+
this.min = value;
217+
}
218+
}
210219
}

src/com/o3smeasures/measures/DepthOfInheritanceTree.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import com.o3smeasures.astvisitors.ClassVisitor;
66
import com.o3smeasures.javamodel.DepthOfInheritanceTreeJavaModel;
7+
import com.o3smeasures.measures.enumeration.MeasuresEnum;
78
import com.o3smeasures.structures.Measure;
89

910
/**
@@ -20,6 +21,7 @@ public class DepthOfInheritanceTree extends Measure{
2021
private double value;
2122
private double mean;
2223
private double max;
24+
private double min;
2325
private String classWithMaxValue;
2426
private boolean isEnable;
2527

@@ -28,6 +30,7 @@ public DepthOfInheritanceTree(){
2830
this.value = 0d;
2931
this.mean = 0d;
3032
this.max = 0d;
33+
this.min = 0d;
3134
this.classWithMaxValue = "";
3235
this.isEnable = true;
3336
addApplicableGranularity(Granularity.PACKAGE);
@@ -38,15 +41,15 @@ public DepthOfInheritanceTree(){
3841
*/
3942
@Override
4043
public String getName() {
41-
return "Depth of Inheritance Tree";
44+
return MeasuresEnum.DIT.getName();
4245
}
4346

4447
/**
4548
* @see Measure#getAcronym
4649
*/
4750
@Override
4851
public String getAcronym() {
49-
return "DIT";
52+
return MeasuresEnum.DIT.getAcronym();
5053
}
5154

5255
/**
@@ -62,7 +65,7 @@ public String getDescription() {
6265
*/
6366
@Override
6467
public double getMinValue() {
65-
return 0d;
68+
return min;
6669
}
6770

6871
/**
@@ -127,7 +130,6 @@ public boolean isEnable() {
127130
@Override
128131
public void setEnable(boolean isEnable) {
129132
this.isEnable = isEnable;
130-
131133
}
132134

133135
/**
@@ -143,6 +145,7 @@ public <T> void measure(T unit) {
143145
setCalculatedValue(Math.abs(ditJavaModel.getDitValue()));
144146
setMeanValue(getCalculatedValue());
145147
setMaxValue(getCalculatedValue(), ((ICompilationUnit) unit).getElementName());
148+
setMinValue(getCalculatedValue());
146149
}
147150

148151
/**
@@ -182,4 +185,10 @@ public void setClassWithMaxValue(String value) {
182185
this.classWithMaxValue = value;
183186
}
184187

188+
@Override
189+
public void setMinValue(double value) {
190+
if (min > value || min == 0d){
191+
this.min = value;
192+
}
193+
}
185194
}

src/com/o3smeasures/measures/FanOut.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import com.o3smeasures.astvisitors.ClassVisitor;
77
import com.o3smeasures.astvisitors.FanOutVisitor;
8+
import com.o3smeasures.measures.enumeration.MeasuresEnum;
89
import com.o3smeasures.structures.Measure;
910

1011
/**
@@ -21,14 +22,16 @@ public class FanOut extends Measure{
2122
private double value;
2223
private double mean;
2324
private double max;
25+
private double min;
2426
private String classWithMaxValue;
2527
private boolean isEnable;
26-
28+
2729
public FanOut(){
2830
super();
2931
this.value = 0d;
3032
this.mean = 0d;
3133
this.max = 0d;
34+
this.min = 0d;
3235
this.classWithMaxValue = "";
3336
this.isEnable = true;
3437
addApplicableGranularity(Granularity.PACKAGE);
@@ -39,15 +42,15 @@ public FanOut(){
3942
*/
4043
@Override
4144
public String getName() {
42-
return "Fan-out";
45+
return MeasuresEnum.FAN_OUT.getName();
4346
}
4447

4548
/**
4649
* @see Measure#getAcronym
4750
*/
4851
@Override
4952
public String getAcronym() {
50-
return "FOUT";
53+
return MeasuresEnum.FAN_OUT.getAcronym();
5154
}
5255

5356
/**
@@ -63,7 +66,7 @@ public String getDescription() {
6366
*/
6467
@Override
6568
public double getMinValue() {
66-
return 0d;
69+
return min;
6770
}
6871

6972
/**
@@ -128,7 +131,6 @@ public boolean isEnable() {
128131
@Override
129132
public void setEnable(boolean isEnable) {
130133
this.isEnable = isEnable;
131-
132134
}
133135

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

157159
setMaxValue(getCalculatedValue(), elementName);
160+
setMinValue(getCalculatedValue());
158161
}
159162

160163
/**
@@ -205,4 +208,10 @@ public void setClassWithMaxValue(String value) {
205208
this.classWithMaxValue = value;
206209
}
207210

211+
@Override
212+
public void setMinValue(double value) {
213+
if (min > value || min == 0d){
214+
this.min = value;
215+
}
216+
}
208217
}

0 commit comments

Comments
 (0)