Skip to content

enhancement: orphan_detection — add configurable exclusion list for test entry points #87

@egouilliard-leyton

Description

@egouilliard-leyton

Context

Discovered while validating the orphan_detection implementation (issue #17).

Description

The function orphan query currently hardcodes exclusions for pytest-style entry points only:

AND NOT f.name STARTS WITH 'test_'
AND NOT f.name IN ['setup_module', 'teardown_module',
                   'setup_function', 'teardown_function',
                   'setup_class', 'teardown_class',
                   'setup_method', 'teardown_method']

Users on unittest (setUp, tearDown, setUpClass, tearDownClass), nose (setup, teardown), or custom naming conventions will get false positives with no escape hatch short of disabling the policy entirely.

Suggested approach

Add two optional config fields to [policies.orphan_detection] in .arch-policies.toml:

[policies.orphan_detection]
enabled           = true
exclude_prefixes  = ["test_"]          # function names starting with these are excluded
exclude_names     = ["setUp", "tearDown", "setUpClass", "tearDownClass"]  # exact names

OrphanDetectionConfig gains exclude_prefixes: list[str] and exclude_names: list[str] with sensible pytest defaults. The Cypher builder in _check_orphans injects them into the AND NOT f.name STARTS WITH ... / AND NOT f.name IN [...] clauses dynamically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions