Skip to content

Commit

Permalink
refactor: Common static analysis issues
Browse files Browse the repository at this point in the history
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.staticanalysis.CommonStaticAnalysis?organizationId=T3BlblJld3JpdGU%3D

Co-authored-by: Moderne <team@moderne.io>
  • Loading branch information
jkschneider and TeamModerne committed Jan 18, 2024
1 parent b10982f commit 0746ec8
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public File getProjectDirectory(File sourceFile, String projectName) {
}

public List<File> getSrcDirectories(SourceFile sourceFile) {
List<File> srcDirs = new ArrayList<File>();
List<File> srcDirs = new ArrayList<>();
Path sourcePath = sourceFile.getSourcePath();

String projectName = sourceFile.getMarkers()
Expand All @@ -65,7 +65,7 @@ public List<File> getSrcDirectories(SourceFile sourceFile) {
if (subDirs != null) {
for (File subDir : subDirs) {
String dirName = subDir.getName().toLowerCase();
if (dirName.endsWith("src") || dirName.equals("source")) {
if (dirName.endsWith("src") || "source".equals(dirName)) {
srcDirs.add(subDir);
}
}
Expand All @@ -82,10 +82,10 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
@Override
public Tree visit(@Nullable Tree tree, ExecutionContext ctx) {
if (tree instanceof SourceFile) {
SourceFile sourceFile = ((SourceFile) tree);
SourceFile sourceFile = (SourceFile) tree;

Path sourcePath = ((SourceFile) tree).getSourcePath();
if (sourcePath.getFileName().toString().equals("persistence.xml")) {
if ("persistence.xml".equals(sourcePath.getFileName().toString())) {
String projectName = sourceFile.getMarkers()
.findFirst(JavaProject.class)
.map(JavaProject::getProjectName)
Expand Down

0 comments on commit 0746ec8

Please sign in to comment.