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 SpecifyNothingDetectorImpl implements AntiPatternDetector {
@@ -21,18 +19,34 @@ public class SpecifyNothingDetectorImpl implements AntiPatternDetector {
2119 "Specify Nothing" ,
2220 "SpecifyNothing" ,
2321 "The specification is not done intentionally. Programmers are " +
24- "expected to work better without written specifications." );
22+ "expected to work better without written specifications." ,
23+ new HashMap <>() {{
24+ put ("minNumberOfWikiPagesWithSpecification" , new Configuration <Integer >("minNumberOfWikiPagesWithSpecification" ,
25+ "Minimum number of wiki pages with project specification" ,
26+ "Number of wiki pages" , 1 ));
27+ put ("minNumberOfActivitiesWithSpecification" , new Configuration <Integer >("minNumberOfActivitiesWithSpecification" ,
28+ "Minimum number of activities with project specification" ,
29+ "Number of activities" , 1 ));
30+ put ("minAvgLengthOfActivityDescription" , new Configuration <Integer >("minAvgLengthOfActivityDescription" ,
31+ "Minimum average length of activity description" ,
32+ "Minimum average number of character of activity description" , 150 ));
33+ }});
2534
2635 private final String sqlFileName = "specify_nothing.sql" ;
2736 // sql queries loaded from sql file
2837 private List <String > sqlQueries ;
2938
30- /**
31- * SETTINGS
32- */
33- private final int MINIMUM_NUMBER_OF_WIKI_PAGES = 1 ;
34- private final int MINIMUM_NUMBER_OF_ACTIVITIES = 1 ;
35- private final double MINIMUM_AVERAGE_LENGTH_OF_ACTIVITY_DESCRIPTION = 150 ;
39+ private int getMinNumberOfWikiPagesWithSpecification () {
40+ return (int ) antiPattern .getConfigurations ().get ("minNumberOfWikiPagesWithSpecification" ).getValue ();
41+ }
42+
43+ private int getMinNumberOfActivitiesWithSpecification () {
44+ return (int ) antiPattern .getConfigurations ().get ("minNumberOfActivitiesWithSpecification" ).getValue ();
45+ }
46+
47+ private int getMinAvgLengthOfActivityDescription () {
48+ return (int ) antiPattern .getConfigurations ().get ("minAvgLengthOfActivityDescription" ).getValue ();
49+ }
3650
3751 @ Override
3852 public AntiPattern getAntiPatternModel () {
@@ -89,12 +103,12 @@ public QueryResultItem analyze(Project project, DatabaseConnection databaseConne
89103 resultDetails .add (new ResultDetail ("Number of activities for specification" , String .valueOf (numberOfActivitiesForSpecification )));
90104 resultDetails .add (new ResultDetail ("Number of wiki pages for specification" , String .valueOf (numberOfWikiPages )));
91105
92- if (numberOfActivitiesForSpecification >= MINIMUM_NUMBER_OF_ACTIVITIES ||
93- numberOfWikiPages >= MINIMUM_NUMBER_OF_WIKI_PAGES ) {
106+ if (numberOfActivitiesForSpecification >= getMinNumberOfActivitiesWithSpecification () ||
107+ numberOfWikiPages >= getMinNumberOfWikiPagesWithSpecification () ) {
94108 resultDetails .add (new ResultDetail ("Conclusion" , "Found activities or wiki pages that represents creation of specification" ));
95109 return new QueryResultItem (this .antiPattern , false , resultDetails );
96110 } else {
97- if (averageLengthOfIssueDescription > MINIMUM_AVERAGE_LENGTH_OF_ACTIVITY_DESCRIPTION ) {
111+ if (averageLengthOfIssueDescription > getMinAvgLengthOfActivityDescription () ) {
98112 resultDetails .add (new ResultDetail ("Conclusion" , "Average length of activity description is grater then minimum" ));
99113 return new QueryResultItem (this .antiPattern , false , resultDetails );
100114 } else {
0 commit comments