Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidPackageDeclaration doesn't enforce that the rootPackage is present #4483

Closed
mateot1 opened this issue Jan 11, 2022 · 3 comments
Closed
Labels

Comments

@mateot1
Copy link
Contributor

mateot1 commented Jan 11, 2022

The rootPackage config for InvalidPackageDeclaration allows us to account for a file path that doesn't include the root part of the package, but it doesn't check that the package declaration contains this rootPackage. This can lead to inconsistency, for example:

with config rootPackage: 'my.root.package'
file/path containing a file with package my.root.package.file.path passes as expected
file/path containing a file with package file.path also passes

Expected Behavior of the rule

The rule should ensure that all classes in a given file path have the same package declaration. This means that if a rootPackage is defined, it should also enforce that it is present in the package declaration.

Context

For bettor or worse I work in a codebase that has a file structure that does not contain the root directories for kotlin src files which allows these inconsistencies to arise...

@cortinico
Copy link
Member

I think this is a nice improvement. However, I would like to point out how this is a behavior change. Specifically, before the rootPackage was used just to ignore part of the package declaration.

Please also note how this is explained in the documentation:

@Configuration("if specified this part of the package structure is ignored")
private val rootPackage: String by config("")

If we end up merging #4484, we should also update that documentation to clarify this behavioral change.

@mateot1
Copy link
Contributor Author

mateot1 commented Jan 12, 2022

updated!

@cortinico
Copy link
Member

Fixed by #4484

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants