Skip to content

Commit

Permalink
fix(spoon): Fix whitespaces in ruleIDs for spoon analyzer (#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWitt committed Jul 16, 2023
1 parent 5452a96 commit b7245a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.flogger.FluentLogger;
import com.mongodb.client.model.Filters;
import com.mongodb.client.result.DeleteResult;
import io.github.martinwitt.laughing_train.domain.entity.Project;
import io.github.martinwitt.laughing_train.domain.entity.ProjectConfig;
import io.github.martinwitt.laughing_train.persistence.impl.MongoBadSmellRepository;
Expand Down Expand Up @@ -67,6 +68,7 @@ private void migrateDataBase(Promise<Object> promise) {
removeProjectHashesWithoutResults();
removeProjectsWithOutHashes();
removeDuplicatedProjects();
removeRuleIdsWithSpaces();
logger.atInfo().log("Finished migrating database");
promise.complete();
}
Expand Down Expand Up @@ -120,4 +122,11 @@ private void removeDuplicatedProjects() {
.forEach(project -> projectRepository.deleteByProjectUrl(project.getProjectUrl()));
logger.atInfo().log("Finished removing duplicated projects");
}

private void removeRuleIdsWithSpaces() {
DeleteResult deleteMany = badSmellRepositoryImpl
.mongoCollection()
.deleteMany(Filters.and(Filters.regex("ruleID", ".*\s.*"), Filters.eq("analyzer", "Spoon")));

Check warning on line 129 in github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/DataBaseMigration.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Non-terminal use of '\s' escape sequence

Use of '\\s' escape sequence in the middle of line is discouraged
logger.atInfo().log("Removed %d bad smells with ruleId containing spaces", deleteMany.getDeletedCount());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class InnerClassMayBeStatic implements BadSmell {

private final CtType<?> affectedType;
private final CtType<?> innerClass;
private static final String name = "Inner Class May Be Static";
private static final String name = "InnerClassMayBeStatic";
private static final String description =
"This class is an inner class and may be static. Static inner classes dont need the reference to the outer class.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class UnnecessaryImplements implements BadSmell {

private final String name = "Unnecessary Implements";
private final String name = "UnnecessaryImplements";
private final String description = "This class has 1 or more interfaces which are already implemented.";

private final CtTypeReference<?> lowerType;
Expand Down

0 comments on commit b7245a9

Please sign in to comment.