Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 11df4adc

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

Specify nothing refactor

Zobrazit rozdíly:

src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/SpecifyNothingDetectorImpl.java
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
        }
src/main/resources/queries/specify_nothing.sql
15 15
/* Find number of wikipages with some project specification */
16 16
set @numberOfWikiPages = (select count(name) from artifactview where projectId = @projectId and (name like '%DSP%' or name like '%specifikace%' or name like '%specification%' or description like '%DSP%' or description like '%specifikace%' or description like '%specification%'));
17 17
/* Find activities for creating DSP or project specification */
18
set @numberOfActivitiesForSpecification = (SELECT count(id) from workunitview where projectId = @projectId and (name like '%DSP%' or name like '%specifikace%' or name like '%specification%' or description like '%DSP%' or description like '%specifikace%' or description like '%specification%'));
18
set @numberOfActivitiesForSpecification = (SELECT count(id) from workunitview where projectId = @projectId and (name like '%DSP%' or name like '%specifikace%' or name like '%specification%'));
19 19
/* Count average length of issues description */
20 20
set @averageLengthOfIssueDescription = (select AVG(CHAR_LENGTH(workunitview.description)) from workunitview where workunitview.projectId = @projectId);
21 21
/* Show all statistics */

Také k dispozici: Unified diff