Skip to content

Should importing a parent package from a sub package trigger pointless-import? #1759

@sascha-cariad

Description

@sascha-cariad

Description

When running regal lint . the linter flags an import of a parent-package from a sub-package as "pointless."
I’m unsure if this is intended behavior or a false positive. OPA allows this, however, I understand that this pattern can be discouraged for maintainability reasons.
Is this import pattern considered a bad practice by Regal’s standards?
What is the recommended way to share rules or data between parent and sub-packages?

Linter Output

Rule:           pointless-import
Description:    Importing own package is pointless
Category:       imports
Location:       validation/helpers/helpers.rego:3:8
Text:           import data.validation
Documentation:  https://www.openpolicyagent.org/projects/regal/rules/imports/pointless-import

Example

I have the following structure:

└── validation
    ├── helpers
    │   └── helpers.rego
    └── validation.rego
# validation/helpers/helpers.rego:
package validation.helpers

import data.validation

allowed := false
allowed if {
	validation.is_allowed
}
# validation/validation.rego:
package validation

is_allowed if {
	input != null
	input.user == "admin"
}

Environment:

  • Regal version: 0.37.0
  • OPA version: 1.10.1
  • OS: macOS 26.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions