-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Verbose test smell threshold set to 123? #3
Comments
Hi Davide, |
Yep, the implementation of the VerboseTest sounds odd. Here my suggestion on how it could be fixed: diff --git a/src/main/java/testsmell/smell/VerboseTest.java b/src/main/java/testsmell/smell/VerboseTest.java
index 13b9344..94ae202 100644
--- a/src/main/java/testsmell/smell/VerboseTest.java
+++ b/src/main/java/testsmell/smell/VerboseTest.java
@@ -40,9 +40,7 @@ public class VerboseTest extends AbstractSmell {
}
private class ClassVisitor extends VoidVisitorAdapter<Void> {
- final int MAX_STATEMENTS = 123;
private MethodDeclaration currentMethod = null;
- private int verboseCount = 0;
TestMethod testMethod;
// examine all methods in the test class
@@ -54,23 +52,21 @@ public class VerboseTest extends AbstractSmell {
testMethod.setSmell(false); //default value is false (i.e. no smell)
//method should not be abstract
+ int numberOfStatements = 0;
if (!currentMethod.isAbstract()) {
if (currentMethod.getBody().isPresent()) {
//get the total number of statements contained in the method
- if (currentMethod.getBody().get().getStatements().size() >= MAX_STATEMENTS) {
- verboseCount++;
- }
+ numberOfStatements = currentMethod.getBody().get().getStatements().size();
}
}
- boolean isSmelly = verboseCount > thresholds.getVerboseTest();
+ boolean isSmelly = numberOfStatements > thresholds.getVerboseTest();
testMethod.setSmell(isSmelly);
- testMethod.addDataItem("VerboseCount", String.valueOf(verboseCount));
+ testMethod.addDataItem("VerboseCount", String.valueOf(isSmelly ? 1 : 0));
smellyElementsSet.add(testMethod);
//reset values for next method
currentMethod = null;
- verboseCount = 0;
}
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! Thanks for the tool!
I was looking at the threshold of Verbose Test, and it's currently set to 123 statements. I think this is an error, it seems waaay to high, and also it's kind of a magic number (first 3 numbers of the keyboard). Is it a leftover? What's the correct threshold?
TestSmellDetector/src/main/java/testsmell/smell/VerboseTest.java
Line 61 in 08be07d
The text was updated successfully, but these errors were encountered: