Skip to content
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

Update JavaParser version and fix configured smells being ignored #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

marvinkreis
Copy link

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.

Save smell factories instead of smells in TestSmellDetector, so the
configured tests can be re-initialized whenever needed. (See TestSmells#19)
@marvinkreis
Copy link
Author

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);

gofraser pushed a commit to CodeDefenders/CodeDefenders that referenced this pull request Oct 31, 2022
Created forked version of TestSmellDetector to update it to JavaParser version 3.24.4.
See TestSmells/TestSmellDetector#26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant