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.
LINT_PASS_THRESHOLD = 100
module-attribute
Minimum lint score — zero tolerance for lint issues.
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
| Python | |
|---|---|
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
category
property
Scoring category, auto-injected by @register_rule.
Valid values: lint, type, complexity, security,
deps, testing, architecture, practices,
structure, tooling.
framework
property
Ecosystem this rule applies to, auto-injected by @register_rule.
Defaults to :attr:Framework.PYTHON for rules registered before the
framework dimension existed.
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
|
or multi-package workspace ( |
CheckResult | None
|
should continue. |
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
| Python | |
|---|---|
get_registry()
Return the Python rule registry as a category -> classes view.
Backwards-compatible accessor: it exposes only the python framework
rules, keyed by category, exactly as before the framework dimension was
introduced. New framework-aware callers use :func:get_registry_for.
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
get_registry_for(framework)
Return the rule registry for a single framework, keyed by category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
framework
|
Framework
|
Ecosystem whose rules to expose. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, list[type[ProjectRule]]]
|
Mapping |
Source code in packages/axm-audit/src/axm_audit/core/rules/base.py
register_rule(category, framework=Framework.PYTHON)
Class decorator that registers a rule in the auto-discovery registry.
Also injects _registered_category and _registered_framework on the
class so that ProjectRule.category / ProjectRule.framework resolve
automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str
|
Unified category (e.g. |
required |
framework
|
Framework | str
|
Ecosystem the rule applies to (default |
PYTHON
|
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 |