5 |
5 |
import cz.zcu.fav.kiv.antipatterndetectionapp.model.Project;
|
6 |
6 |
import cz.zcu.fav.kiv.antipatterndetectionapp.model.QueryResultItem;
|
7 |
7 |
import cz.zcu.fav.kiv.antipatterndetectionapp.model.ResultDetail;
|
8 |
|
import cz.zcu.fav.kiv.antipatterndetectionapp.utils.Utils;
|
9 |
8 |
import org.slf4j.Logger;
|
10 |
9 |
import org.slf4j.LoggerFactory;
|
11 |
10 |
|
12 |
11 |
import java.sql.ResultSet;
|
13 |
12 |
import java.sql.SQLException;
|
|
13 |
import java.util.ArrayList;
|
14 |
14 |
import java.util.List;
|
15 |
15 |
|
16 |
16 |
public class SpecifyNothingDetectorImpl extends AntiPatternDetector {
|
... | ... | |
57 |
57 |
public QueryResultItem analyze(Project project, DatabaseConnection databaseConnection, List<String> queries) {
|
58 |
58 |
|
59 |
59 |
/* Init values */
|
|
60 |
List<ResultDetail> resultDetails = new ArrayList<>();
|
60 |
61 |
int numberOfWikiPages = 0;
|
61 |
62 |
int numberOfActivitiesForSpecification = 0;
|
62 |
63 |
double averageLengthOfIssueDescription = 0;
|
... | ... | |
72 |
73 |
}
|
73 |
74 |
|
74 |
75 |
} catch (SQLException e) {
|
75 |
|
e.printStackTrace();
|
|
76 |
LOGGER.error("Cannot read results from db");
|
|
77 |
resultDetails.add(new ResultDetail("Problem in reading database", e.toString()));
|
|
78 |
return new QueryResultItem(this.antiPattern, true, resultDetails);
|
76 |
79 |
}
|
77 |
80 |
|
78 |
|
LOGGER.info("Project id: " + project.getId());
|
79 |
|
LOGGER.info("actvitiy:" + numberOfActivitiesForSpecification);
|
80 |
|
LOGGER.info("wiki:" + numberOfWikiPages);
|
81 |
|
LOGGER.info("average:" + averageLengthOfIssueDescription);
|
82 |
|
|
83 |
|
List<ResultDetail> resultDetails = Utils.createResultDetailsList(
|
84 |
|
new ResultDetail("Project id", project.getId().toString()));
|
|
81 |
resultDetails.add(new ResultDetail("Number of activities for specification", String.valueOf(numberOfActivitiesForSpecification)));
|
|
82 |
resultDetails.add(new ResultDetail("Number of wiki pages for specification", String.valueOf(numberOfWikiPages)));
|
85 |
83 |
|
86 |
84 |
if (numberOfActivitiesForSpecification >= MINIMUM_NUMBER_OF_ACTIVITIES ||
|
87 |
85 |
numberOfWikiPages >= MINIMUM_NUMBER_OF_WIKI_PAGES) {
|
|
86 |
resultDetails.add(new ResultDetail("Conclusion", "Found activities or wiki pages that represents creation of specification"));
|
88 |
87 |
return new QueryResultItem(this.antiPattern, false, resultDetails);
|
89 |
88 |
} else {
|
90 |
89 |
if (averageLengthOfIssueDescription > MINIMUM_AVERAGE_LENGTH_OF_ACTIVITY_DESCRIPTION) {
|
|
90 |
resultDetails.add(new ResultDetail("Conclusion", "Average length of activity description is grater then minimum"));
|
91 |
91 |
return new QueryResultItem(this.antiPattern, false, resultDetails);
|
92 |
92 |
} else {
|
|
93 |
resultDetails.add(new ResultDetail("Conclusion", "Average length of activity description is smaller then minimum"));
|
93 |
94 |
return new QueryResultItem(this.antiPattern, true, resultDetails);
|
94 |
95 |
}
|
95 |
96 |
}
|
Specify nothing refactor