Skip to content

Commit

Permalink
add a test case, fix minor formatting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mateot1 committed Feb 4, 2022
1 parent 3049054 commit 7beeee0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Expand Up @@ -29,7 +29,7 @@ class InvalidPackageDeclaration(config: Config = Config.empty) : Rule(config) {
private val rootPackage: String by config("")

@Configuration("requires the declaration to start with the specified rootPackage")
private val requireRootInDeclaration : Boolean by config(false)
private val requireRootInDeclaration: Boolean by config(false)

override fun visitPackageDirective(directive: KtPackageDirective) {
super.visitPackageDirective(directive)
Expand Down
Expand Up @@ -120,10 +120,15 @@ internal class InvalidPackageDeclarationSpec : Spek({
class C
"""

val ktFile = compileContentForTest(source, createPath("src/foo/bar/File.kt"))
val findings = InvalidPackageDeclaration(config).lint(ktFile)
val ktFileWithRelativePath = compileContentForTest(source, createPath("src/foo/bar/File.kt"))
val findingsForRelativePath = InvalidPackageDeclaration(config).lint(ktFileWithRelativePath)

assertThat(findings).isEmpty()
assertThat(findingsForRelativePath).isEmpty()

val ktFileWithFullPath = compileContentForTest(source, createPath("src/com/example/foo/bar/File.kt"))
val findingsForFullPath = InvalidPackageDeclaration(config).lint(ktFileWithFullPath)

assertThat(findingsForFullPath).isEmpty()
}

it("should report if root package is missing") {
Expand Down

0 comments on commit 7beeee0

Please sign in to comment.