TestSmellDetector
TestSmellDetector copied to clipboard
Update JavaParser version and fix configured smells being ignored
This updates the JavaParser dependency to the most recent version to enable support for newer Java versions (up to 17 preview).
Also fixes a bug introduced in the fix to #19, where configured smells from setTestSmells()
were overwritten.
Note that this changes TestSmellDetector::setTestSmells(List<AbstractSmell> testSmells)
to TestSmellDetector::setTestSmells(List<SmellFactory> testSmells)
to ensure smells can be re-initialized.
Hi. Sorry for positing this PR with no context at all. I was in a bit of a hurry when I opened it, so let me elaborate a bit:
We use TestSmellDetector over at Code Defenders to analyze user-submitted test cases and I'm currently updating our analysis to support newer Java Versions. This made it incompatible with TestSmellDetector, because our internal JavaParser version clashed with TestSmellDetector's. I don't know if you're interested in updating to a newer JavaParser version, but since I already updated it for Code Defenders I thought I might as well open an PR.
The other changes have to do with b7e1aaf (the fix to #19), which re-initialized the smells every time detectSmells()
is called, ignoring which smells were configured by setTestSmells()
. To fix this, I changed TestSmellDetector
to save smell factories instead of smells, so it can re-initialize only the configured smells. Smells can then be set with e.g
List<SmellFactory> testSmells = new ArrayList<>();
testSmells.add(AssertionRoulette::new);
testSmells.add(DuplicateAssert::new);
detector.setTestSmells(testSmells);
instead of
List<AbstractSmell> testSmells = new ArrayList<>();
testSmells.add(new AssertionRoulette());
testSmells.add(new DuplicateAssert());
detector.setTestSmells(testSmells);