Projekt

Obecné

Profil

« Předchozí | Další » 

Revize f3d2d8c8

Přidáno uživatelem Ondřej Váně před téměř 4 roky(ů)

Configuration - Varying Sprint Length

Zobrazit rozdíly:

src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/VaryingSprintLengthDetectorImpl.java
1 1
package cz.zcu.fav.kiv.antipatterndetectionapp.detecting.detectors;
2 2

  
3 3
import 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.*;
8 5
import org.slf4j.Logger;
9 6
import org.slf4j.LoggerFactory;
10 7

  
11 8
import java.sql.ResultSet;
12 9
import java.sql.SQLException;
13 10
import java.util.ArrayList;
11
import java.util.HashMap;
14 12
import java.util.List;
15 13

  
16 14
public class VaryingSprintLengthDetectorImpl implements AntiPatternDetector {
......
24 22
                    "It is clear that iterations will be different " +
25 23
                    "lengths at the beginning and end of the project, " +
26 24
                    "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
            }});
28 34

  
29 35
    private final String sqlFileName = "varying_sprint_length.sql";
30 36
    // sql queries loaded from sql file
31 37
    private List<String> sqlQueries;
32 38

  
39
    private Integer getMaxDaysDifference(){
40
        return (Integer) this.antiPattern.getConfigurations().get("maxDaysDifference").getValue();
41
    }
33 42

  
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
    }
40 46

  
41 47
    @Override
42 48
    public AntiPattern getAntiPatternModel() {
......
91 97
                        secondIterationLength = iterationLength;
92 98
                    }
93 99

  
94
                    if (Math.abs(firstIterationLength - secondIterationLength) >= MAXIMUM_DAYS_DIFFERENCE) {
100
                    if (Math.abs(firstIterationLength - secondIterationLength) >= getMaxDaysDifference()) {
95 101
                        iterationLengthChanged = iterationLengthChanged + 1;
96 102
                    }
97 103
                    firstIterationLength = secondIterationLength;
......
104 110
            return new QueryResultItem(this.antiPattern, true, resultDetails);
105 111
        }
106 112

  
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())));
108 114
        resultDetails.add(new ResultDetail("Count of iterations", String.valueOf(numberOfIterations)));
109 115
        resultDetails.add(new ResultDetail("Iteration length changed", String.valueOf(iterationLengthChanged)));
110 116

  
111 117

  
112
        if (iterationLengthChanged >= MAXIMUM_ITERATION_CHANGE) {
118
        if (iterationLengthChanged > getMaxIterationChanged()) {
113 119
            resultDetails.add(new ResultDetail("Conclusion", "Iteration length changed significantly too often"));
114 120
        } else {
115 121
            resultDetails.add(new ResultDetail("Conclusion", "Varying iteration length is all right"));
......
118 124
        LOGGER.info(this.antiPattern.getPrintName());
119 125
        LOGGER.info(resultDetails.toString());
120 126

  
121
        return new QueryResultItem(this.antiPattern, (iterationLengthChanged >= MAXIMUM_ITERATION_CHANGE), resultDetails);
127
        return new QueryResultItem(this.antiPattern, (iterationLengthChanged > getMaxIterationChanged()), resultDetails);
122 128
    }
123 129
}

Také k dispozici: Unified diff