Skip to content

Commit af21514

Browse files
committed
capture and save the technical debt comments
1 parent 0d9dec6 commit af21514

3 files changed

Lines changed: 29 additions & 6 deletions

File tree

src/main/java/ResultsWriter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ private void createClassFile() throws IOException {
5151
"androidTestAndroidTestCase",
5252
"androidTestInstrumentationTestCase",
5353
"orgJunitAssert",
54-
"androidTestActivityInstrumentationTestCase2"
54+
"androidTestActivityInstrumentationTestCase2",
55+
"HasTechnicalDebtComment",
5556
};
5657
fileLines.add(columnNames);
5758

@@ -126,7 +127,7 @@ private void outputClassDetails(ClassEntity classEntity) throws IOException {
126127
List<String[]> fileLines = new ArrayList<String[]>();
127128
String[] dataLine;
128129

129-
dataLine = new String[21];
130+
dataLine = new String[22];
130131
dataLine[0] = classEntity.getAppName();
131132
dataLine[1] = classEntity.getTagName();
132133
dataLine[2] = classEntity.getFilePath();
@@ -148,6 +149,7 @@ private void outputClassDetails(ClassEntity classEntity) throws IOException {
148149
dataLine[18] = String.valueOf(classEntity.getHas_androidtestInstrumentationTestCase());
149150
dataLine[19] = String.valueOf(classEntity.getHas_orgjunitAssert());
150151
dataLine[20] = String.valueOf(classEntity.getHas_androidtestActivityInstrumentationTestCase2());
152+
dataLine[21] = String.valueOf(classEntity.getHasTechnicalDebtComments());
151153

152154
fileLines.add(dataLine);
153155

src/main/java/TestFileDetector.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class TestFileDetector {
2121
private List<MethodEntity> methods;
2222
private ClassEntity classEntity;
2323
private ArrayList<String> imports;
24+
private ArrayList<String> debt;
2425

2526
/**
2627
* Constructor
@@ -41,6 +42,7 @@ public static TestFileDetector createTestFileDetector() {
4142
private void initialize(){
4243
methods = new ArrayList<>();
4344
imports = new ArrayList<>();
45+
debt = new ArrayList<>();
4446
}
4547

4648
public ClassEntity runAnalysis(Path filePath) throws FileNotFoundException {
@@ -58,6 +60,7 @@ public ClassEntity runAnalysis(Path filePath) throws FileNotFoundException {
5860

5961
classEntity.setMethods(methods);
6062
classEntity.setImports(imports);
63+
classEntity.setTechnicalDebtComments(debt);
6164
}
6265

6366
return classEntity;
@@ -74,25 +77,29 @@ public void visit(ClassOrInterfaceDeclaration n, Void arg) {
7477

7578
for (Comment comment:n.getAllContainedComments()) {
7679
if (containsKeyword(comment.getContent())){
77-
System.out.println(comment.getContent());
80+
debt.add(comment.getContent());
81+
//System.out.println(comment.getContent());
7882
}
7983
}
8084

8185
if(n.getComment().isPresent()){
8286
if (containsKeyword(n.getComment().get().getContent())){
83-
System.out.println(n.getComment().get().getContent());
87+
debt.add(n.getComment().get().getContent());
88+
//System.out.println(n.getComment().get().getContent());
8489
}
8590
}
8691

8792
if(n.getJavadocComment().isPresent()){
8893
if (containsKeyword(n.getJavadocComment().get().getContent())){
89-
System.out.println(n.getJavadocComment().get().getContent());
94+
debt.add(n.getJavadocComment().get().getContent());
95+
//System.out.println(n.getJavadocComment().get().getContent());
9096
}
9197
}
9298

9399
for (Comment comment:n.getOrphanComments()) {
94100
if (containsKeyword(comment.getContent())){
95-
System.out.println(comment.getContent());
101+
debt.add(comment.getContent());
102+
//System.out.println(comment.getContent());
96103
}
97104
}
98105

src/main/java/entity/ClassEntity.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class ClassEntity {
1212
// private Map<String, Boolean> imports;
1313
private ArrayList<String> imports;
1414
private String className;
15+
private ArrayList<String> technicalDebtComments;
1516

1617
public ClassEntity(Path path) {
1718
this.path = path;
@@ -133,4 +134,17 @@ public String getTagName() {
133134
String filePath = path.toAbsolutePath().toString();
134135
return filePath.split("\\\\")[4];
135136
}
137+
138+
public ArrayList<String> getTechnicalDebtComments() {
139+
return technicalDebtComments;
140+
}
141+
142+
public void setTechnicalDebtComments(ArrayList<String> technicalDebtComments) {
143+
this.technicalDebtComments = technicalDebtComments;
144+
}
145+
146+
public Boolean getHasTechnicalDebtComments() {
147+
return (technicalDebtComments.size() >=1);
148+
149+
}
136150
}

0 commit comments

Comments
 (0)