Base
base
Base class for project rules — dependency-free module.
This module contains the abstract base class for all rules,
the @register_rule decorator, and the shared _RULE_REGISTRY.
It has no dependencies on concrete rule implementations to avoid circular imports.
COMPLEXITY_THRESHOLD = 10
module-attribute
Cyclomatic complexity ceiling — functions at or above are flagged.
PASS_THRESHOLD = 90
module-attribute
Minimum score (out of 100) for a check to pass.
PERFECT_SCORE = 100
module-attribute
Maximum achievable score.
ProjectRule
Bases: ABC
Base class for project invariants.
Each rule defines a single check that a project must satisfy.
Source code in packages/axm-audit/src/axm_audit/core/rules/base.py
category
property
Scoring category, auto-injected by @register_rule.
Valid values: lint, type, complexity, security,
deps, testing, architecture, practices,
structure, tooling.
rule_id
abstractmethod
property
Unique identifier for this rule.
check(project_path)
abstractmethod
Execute the check against a project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_path
|
Path
|
Root directory of the project to check. |
required |
Returns:
| Type | Description |
|---|---|
CheckResult
|
CheckResult with pass/fail status and message. |
Source code in packages/axm-audit/src/axm_audit/core/rules/base.py
check_src(project_path)
Return an early CheckResult if src/ does not exist.
Call this at the top of check() to eliminate boilerplate::
early = self.check_src(project_path)
if early is not None:
return early
Returns:
| Type | Description |
|---|---|
CheckResult | None
|
|
CheckResult | None
|
A passing |
Source code in packages/axm-audit/src/axm_audit/core/rules/base.py
get_instances()
classmethod
Instantiate this rule.
Override in subclasses that require constructor parameters
(e.g. ToolAvailabilityRule).
Returns:
| Type | Description |
|---|---|
list[ProjectRule]
|
List of rule instances — |
Source code in packages/axm-audit/src/axm_audit/core/rules/base.py
get_registry()
Return the current rule registry (read-only view).
Callers must ensure that rule modules have been imported before
calling this function so that @register_rule decorators have
fired.
Source code in packages/axm-audit/src/axm_audit/core/rules/base.py
register_rule(category)
Class decorator that registers a rule in the auto-discovery registry.
Also injects _registered_category on the class so that
ProjectRule.category resolves automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str
|
Unified category (e.g. |
required |
Returns:
| Type | Description |
|---|---|
Callable[[type[ProjectRule]], type[ProjectRule]]
|
The unmodified class — the decorator only appends to the registry |
Callable[[type[ProjectRule]], type[ProjectRule]]
|
and sets the |