regal icon indicating copy to clipboard operation
regal copied to clipboard

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

Open sascha-cariad opened this issue 2 months ago • 1 comments

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

sascha-cariad avatar Nov 07 '25 16:11 sascha-cariad

Hey, and thanks for raising this. No, that doesn't look like intended behavior. I'm trying to understand why we haven't seen that before, but I'm sure there are reasons for that. Just ignore the rule for the time being, and we'll look into it next week and report back. Enjoy your weekend!

anderseknert avatar Nov 07 '25 16:11 anderseknert