11package cz .zcu .fav .kiv .antipatterndetectionapp .detecting .detectors ;
22
33import cz .zcu .fav .kiv .antipatterndetectionapp .detecting .DatabaseConnection ;
4- import cz .zcu .fav .kiv .antipatterndetectionapp .model .AntiPattern ;
5- import cz .zcu .fav .kiv .antipatterndetectionapp .model .Project ;
6- import cz .zcu .fav .kiv .antipatterndetectionapp .model .QueryResultItem ;
7- import cz .zcu .fav .kiv .antipatterndetectionapp .model .ResultDetail ;
4+ import cz .zcu .fav .kiv .antipatterndetectionapp .model .*;
85import org .slf4j .Logger ;
96import org .slf4j .LoggerFactory ;
107
118import java .sql .ResultSet ;
129import java .sql .SQLException ;
1310import java .util .ArrayList ;
11+ import java .util .HashMap ;
1412import java .util .List ;
1513
1614public class VaryingSprintLengthDetectorImpl implements AntiPatternDetector {
@@ -24,19 +22,27 @@ public class VaryingSprintLengthDetectorImpl implements AntiPatternDetector {
2422 "It is clear that iterations will be different " +
2523 "lengths at the beginning and end of the project, " +
2624 "but the length of the sprint should not change " +
27- "during the project." );
25+ "during the project." ,
26+ new HashMap <>() {{
27+ put ("maxDaysDifference" , new Configuration <Integer >("maxDaysDifference" ,
28+ "Max days difference" ,
29+ "Maximum distance of two consecutive iterations in days" , 7 ));
30+ put ("maxIterationChanged" , new Configuration <Integer >("maxIterationChanged" ,
31+ "Max number of iteration changed" ,
32+ "Maximum allowed number of significant changes in iteration lengths" , 2 ));
33+ }});
2834
2935 private final String sqlFileName = "varying_sprint_length.sql" ;
3036 // sql queries loaded from sql file
3137 private List <String > sqlQueries ;
3238
39+ private Integer getMaxDaysDifference (){
40+ return (Integer ) this .antiPattern .getConfigurations ().get ("maxDaysDifference" ).getValue ();
41+ }
3342
34-
35- /**
36- * SETTINGS
37- */
38- private final int MAXIMUM_DAYS_DIFFERENCE = 7 ; // one week
39- private final int MAXIMUM_ITERATION_CHANGE = 2 ; // how many times can iteration significantly change
43+ private Integer getMaxIterationChanged (){
44+ return (Integer ) this .antiPattern .getConfigurations ().get ("maxIterationChanged" ).getValue ();
45+ }
4046
4147 @ Override
4248 public AntiPattern getAntiPatternModel () {
@@ -91,7 +97,7 @@ public QueryResultItem analyze(Project project, DatabaseConnection databaseConne
9197 secondIterationLength = iterationLength ;
9298 }
9399
94- if (Math .abs (firstIterationLength - secondIterationLength ) >= MAXIMUM_DAYS_DIFFERENCE ) {
100+ if (Math .abs (firstIterationLength - secondIterationLength ) >= getMaxDaysDifference () ) {
95101 iterationLengthChanged = iterationLengthChanged + 1 ;
96102 }
97103 firstIterationLength = secondIterationLength ;
@@ -104,12 +110,12 @@ public QueryResultItem analyze(Project project, DatabaseConnection databaseConne
104110 return new QueryResultItem (this .antiPattern , true , resultDetails );
105111 }
106112
107- resultDetails .add (new ResultDetail ("Maximum iteration length change" , String .valueOf (MAXIMUM_ITERATION_CHANGE )));
113+ resultDetails .add (new ResultDetail ("Maximum iteration length change" , String .valueOf (getMaxIterationChanged () )));
108114 resultDetails .add (new ResultDetail ("Count of iterations" , String .valueOf (numberOfIterations )));
109115 resultDetails .add (new ResultDetail ("Iteration length changed" , String .valueOf (iterationLengthChanged )));
110116
111117
112- if (iterationLengthChanged >= MAXIMUM_ITERATION_CHANGE ) {
118+ if (iterationLengthChanged > getMaxIterationChanged () ) {
113119 resultDetails .add (new ResultDetail ("Conclusion" , "Iteration length changed significantly too often" ));
114120 } else {
115121 resultDetails .add (new ResultDetail ("Conclusion" , "Varying iteration length is all right" ));
@@ -118,6 +124,6 @@ public QueryResultItem analyze(Project project, DatabaseConnection databaseConne
118124 LOGGER .info (this .antiPattern .getPrintName ());
119125 LOGGER .info (resultDetails .toString ());
120126
121- return new QueryResultItem (this .antiPattern , (iterationLengthChanged >= MAXIMUM_ITERATION_CHANGE ), resultDetails );
127+ return new QueryResultItem (this .antiPattern , (iterationLengthChanged > getMaxIterationChanged () ), resultDetails );
122128 }
123129}
0 commit comments