A new rule suggestion:
Prevent classes from importing from a sub-package.
Importing from a child or sub-package often indicates coupling to a specific implementation rather than referencing the interface of it. An import from a child package is likely to be a violation of a master-child relation.
- snippet of Noncompliant Code
// ERROR - you must not import from deeper/child packages
- snippet of Compilant Code
// OK - importing from parent is totally fine
// OK - importing from package on same hierachy level is fine
// OK - importing from package on deeper packages in another part of the hierachy level is fine
// OK??? - possible exception to the rule is a sub-package for Exception classes
- type: Code Smell