Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
PathFilters
from detekt-api to detekt-utils (#6866)
* Move test to the correct project * Simplify code * Move PathFilters to detekt-utils
- Loading branch information
1 parent
731735b
commit 60b2413
Showing
8 changed files
with
49 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
detekt-cli/src/test/kotlin/io/gitlab/arturbosch/detekt/cli/PathFiltersSpec.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/util/ConfigExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rbosch/detekt/api/internal/PathFilters.kt → ...lin/io/github/detekt/utils/PathFilters.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
detekt-utils/src/test/kotlin/io/github/detekt/utils/PathFiltersSpec.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.github.detekt.utils | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
import kotlin.io.path.Path | ||
|
||
class PathFiltersSpec { | ||
|
||
@Test | ||
fun `returns an empty path filter when includes are empty and excludes are empty`() { | ||
val pathFilter = PathFilters.of(emptyList(), emptyList()) | ||
assertThat(pathFilter).isNull() | ||
} | ||
|
||
@Test | ||
fun `parses includes correctly`() { | ||
val pathFilter = PathFilters.of(listOf("**/one/**", "**/two/**"), emptyList()) | ||
assertThat(pathFilter).isNotNull | ||
assertThat(pathFilter?.isIgnored(Path("/one/path"))).isFalse | ||
assertThat(pathFilter?.isIgnored(Path("/two/path"))).isFalse | ||
assertThat(pathFilter?.isIgnored(Path("/three/path"))).isTrue | ||
} | ||
|
||
@Test | ||
fun `parses excludes correctly`() { | ||
val pathFilter = PathFilters.of(emptyList(), listOf("**/one/**", "**/two/**")) | ||
assertThat(pathFilter).isNotNull | ||
assertThat(pathFilter?.isIgnored(Path("/one/path"))).isTrue | ||
assertThat(pathFilter?.isIgnored(Path("/two/path"))).isTrue | ||
assertThat(pathFilter?.isIgnored(Path("/three/path"))).isFalse | ||
} | ||
|
||
@Test | ||
fun `parses both includes and excludes correctly`() { | ||
val pathFilter = PathFilters.of(listOf("**/one/**"), listOf("**/two/**")) | ||
assertThat(pathFilter).isNotNull | ||
assertThat(pathFilter?.isIgnored(Path("/one/path"))).isFalse | ||
assertThat(pathFilter?.isIgnored(Path("/two/path"))).isTrue | ||
assertThat(pathFilter?.isIgnored(Path("/three/path"))).isTrue | ||
assertThat(pathFilter?.isIgnored(Path("/one/two/three/path"))).isTrue | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...h/detekt/api/internal/PathMatchersSpec.kt → ...o/github/detekt/utils/PathMatchersSpec.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters