Skip to content

Commit 8e2806d

Browse files
fix: return statements should be less than 2
1 parent bd70f7d commit 8e2806d

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

shared/src/main/kotlin/org/javacs/kt/SourceExclusions.kt

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,21 @@ class SourceExclusions(
5353
.mapNotNull { if (file.startsWith(it)) it.relativize(file) else null }
5454
.flatten()
5555

56-
// Check if we're in a target directory
57-
if (relativePaths.contains(Path.of("target"))) {
58-
val pathList = relativePaths.toList()
59-
val targetIndex = pathList.indexOf(Path.of("target"))
60-
61-
// Allow only target directory itself or if next directory is generated-sources
62-
return pathList.size <= targetIndex + 1 ||
63-
pathList[targetIndex + 1] == Path.of("generated-sources")
56+
val isIncluded = when {
57+
// Check if we're in a target directory
58+
relativePaths.contains(Path.of("target")) -> {
59+
val pathList = relativePaths.toList()
60+
val targetIndex = pathList.indexOf(Path.of("target"))
61+
// Allow only target directory itself or if next directory is generated-sources
62+
pathList.size <= targetIndex + 1 || pathList[targetIndex + 1] == Path.of("generated-sources")
63+
}
64+
// Check exclusion patterns
65+
exclusionMatchers.any { matcher -> relativePaths.any(matcher::matches) } -> false
66+
// Include paths outside target directory by default
67+
else -> true
6468
}
6569

66-
// If path matches any exclusion pattern, exclude it
67-
if (exclusionMatchers.any { matcher ->
68-
relativePaths.any(matcher::matches)
69-
}) {
70-
return false
71-
}
72-
73-
// Include paths outside target directory by default
74-
return true
70+
return isIncluded
7571
}
76-
7772
}
7873

0 commit comments

Comments
 (0)