Skip to content

Commit

Permalink
visit a KtFile is not free
Browse files Browse the repository at this point in the history
  • Loading branch information
BraisGabin committed May 8, 2024
1 parent bf3fc6f commit b1f69a4
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import io.gitlab.arturbosch.detekt.api.Rule
import io.gitlab.arturbosch.detekt.api.config
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtPackageDirective
import org.jetbrains.kotlin.psi.KtFile

/**
* Reports when the file location does not match the declared package.
Expand All @@ -29,8 +29,8 @@ class InvalidPackageDeclaration(config: Config) : Rule(
@Configuration("requires the declaration to start with the specified rootPackage")
private val requireRootInDeclaration: Boolean by config(false)

override fun visitPackageDirective(directive: KtPackageDirective) {
super.visitPackageDirective(directive)
override fun visit(root: KtFile) {
val directive = root.packageDirective ?: return
val packageName = directive.fqName
if (!packageName.isRoot) {
val rootPackageName = FqName(rootPackage)
Expand Down

0 comments on commit b1f69a4

Please sign in to comment.