Kotlin

Kotlin

Made by DeepSource

File location does not match the declared package KT-W1044

Anti-pattern
Major

Having the file location not matching the declared package is considered bad practice in software development. It can lead to confusion, make code harder to locate and navigate to, hinder collaboration among team members, cause issues with build systems and tools, reduce code portability and reusability, and negatively impact code readability and understanding. It is important to adhere to the convention of matching file locations with package declarations for a well-organized and maintainable codebase.

Bad Practice

package otherpack

// This class file is located at src/main/kotlin/mypack
class MyClass {
    // ...
}

Recommended

Make sure that package declaration complies with the location of the source file.

package mypack

// This class file is located at src/main/kotlin/mypack
class MyClass {
    // ...
}

References