Skip to content

Structure Mismatch

Rule ID: structure-mismatch

What it does

Detect unit test files that do not mirror the expected source-relative path layout. In multi-target mode, evaluation is scoped to the active target package path and excludes sibling configured target roots.

Why this matters

Structure drift makes tests harder to find, weakens navigability, and increases refactor friction.

Default severity

warning

Trigger conditions

  • A unit test file is discovered.
  • The file belongs to the active target package path.
  • The file resolves to a source target but lives in a different path.
  • Integration and e2e paths are excluded from this rule.

Examples

  • Source module: src/app/engine/runner.py
  • Test module: tests/app/test_runner.py

How to address

  • Move the unit test to mirror source structure.
  • Keep the filename aligned with the targeted module.
  • --target
  • --select structure-mismatch
  • --ignore structure-mismatch
  • [tool.tq].targets
  • [tool.tq].select / [tool.tq].ignore

Added in

pre-1.0

Behavior changes

None to date.