Index
rules
Rules subpackage — modular project rule implementations.
BareExceptRule
dataclass
Bases: ProjectRule
Detect bare except clauses (except: without type).
Source code in packages/axm-audit/src/axm_audit/core/rules/practices.py
rule_id
property
Unique identifier for this rule.
check(project_path)
Check for bare except clauses in the project.
Source code in packages/axm-audit/src/axm_audit/core/rules/practices.py
BlockingIORule
dataclass
Bases: ProjectRule
Detect blocking I/O anti-patterns.
Finds:
- time.sleep() inside async def functions.
- HTTP calls (requests.* / httpx.*) without timeout= kwarg.
Source code in packages/axm-audit/src/axm_audit/core/rules/practices.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
rule_id
property
Unique identifier for this rule.
check(project_path)
Check for blocking I/O patterns in the project.
Source code in packages/axm-audit/src/axm_audit/core/rules/practices.py
CircularImportRule
dataclass
Bases: ProjectRule
Detect circular imports via import graph + Tarjan's SCC algorithm.
Source code in packages/axm-audit/src/axm_audit/core/rules/architecture.py
rule_id
property
Unique identifier for this rule.
check(project_path)
Check for circular imports in the project.
Source code in packages/axm-audit/src/axm_audit/core/rules/architecture.py
ComplexityRule
dataclass
Bases: ProjectRule
Analyse cyclomatic complexity via radon Python API.
Scoring: 100 - (high_complexity_count * 10), min 0. High complexity = CC >= 10 (industry standard).
Falls back to radon cc --json subprocess when the Python API
is not importable (e.g. auditing a project that does not declare
radon in its own dev dependencies).
Source code in packages/axm-audit/src/axm_audit/core/rules/complexity.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 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 | |
rule_id
property
Unique identifier for this rule.
check(project_path)
Check project complexity with radon.
Source code in packages/axm-audit/src/axm_audit/core/rules/complexity.py
CouplingMetricRule
dataclass
Bases: ProjectRule
Measure module coupling via fan-in/fan-out analysis.
Scores based on the number of modules whose fan-out exceeds
the threshold: score = 100 - N(over) * 5.
Source code in packages/axm-audit/src/axm_audit/core/rules/architecture.py
rule_id
property
Unique identifier for this rule.
check(project_path)
Check coupling metrics for the project.
Source code in packages/axm-audit/src/axm_audit/core/rules/architecture.py
DeadCodeRule
Bases: ProjectRule
Detect dead (unreferenced) code using axm-ast.
Gracefully skips if axm-ast is not available in the environment.
Scoring: 100 - (dead_symbols_count * 5), min 0.
Source code in packages/axm-audit/src/axm_audit/core/rules/dead_code.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
rule_id
property
Unique identifier for this rule.
check(project_path)
Check for dead code using axm-ast dead-code via subprocess.
Source code in packages/axm-audit/src/axm_audit/core/rules/dead_code.py
DependencyAuditRule
dataclass
Bases: ProjectRule
Scan dependencies for known vulnerabilities via pip-audit.
Scoring: 100 - (vuln_count * 15), min 0.
Source code in packages/axm-audit/src/axm_audit/core/rules/dependencies.py
rule_id
property
Unique identifier for this rule.
check(project_path)
Check dependencies for known CVEs.
Source code in packages/axm-audit/src/axm_audit/core/rules/dependencies.py
DependencyHygieneRule
dataclass
Bases: ProjectRule
Check for unused/missing/transitive dependencies via deptry.
Scoring: 100 - (issue_count * 10), min 0.
Source code in packages/axm-audit/src/axm_audit/core/rules/dependencies.py
rule_id
property
Unique identifier for this rule.
check(project_path)
Check dependency hygiene with deptry.
Source code in packages/axm-audit/src/axm_audit/core/rules/dependencies.py
DiffSizeRule
dataclass
Bases: ProjectRule
Warn when uncommitted changes are too large.
Encourages smaller, focused commits/PRs.
Scoring: 100 if ≤ ideal lines changed, linear degrade to 0 at max
lines. Defaults: ideal=400, max=1200. Overridable via
[tool.axm-audit] in pyproject.toml.
Gracefully skips if not in a git repository or git is not installed.
Source code in packages/axm-audit/src/axm_audit/core/rules/quality.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
rule_id
property
Unique identifier for this rule.
check(project_path)
Check uncommitted diff size.
Source code in packages/axm-audit/src/axm_audit/core/rules/quality.py
DocstringCoverageRule
dataclass
Bases: ProjectRule
Calculate docstring coverage for public functions.
Public functions are those not starting with underscore.
Source code in packages/axm-audit/src/axm_audit/core/rules/practices.py
rule_id
property
Unique identifier for this rule.
check(project_path)
Check docstring coverage in the project.
Source code in packages/axm-audit/src/axm_audit/core/rules/practices.py
DuplicationRule
dataclass
Bases: ProjectRule
Detect copy-pasted code via AST structure hashing.
Extracts function and method bodies, normalises them by stripping variable names and locations, hashes each body, and reports groups whose hash appears more than once.
Scoring: 100 - (dup_groups * 10), min 0.
Source code in packages/axm-audit/src/axm_audit/core/rules/duplication.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
rule_id
property
Unique identifier for this rule.
check(project_path)
Check for code duplication in the project.
Source code in packages/axm-audit/src/axm_audit/core/rules/duplication.py
FormattingRule
dataclass
Bases: ProjectRule
Run ruff format --check and score based on unformatted file count.
Scoring: 100 - (unformatted_count * 5), min 0.
Source code in packages/axm-audit/src/axm_audit/core/rules/quality.py
rule_id
property
Unique identifier for this rule.
check(project_path)
Check project formatting with ruff format --check.
Source code in packages/axm-audit/src/axm_audit/core/rules/quality.py
GodClassRule
dataclass
Bases: ProjectRule
Detect god classes (too many lines or methods).
Source code in packages/axm-audit/src/axm_audit/core/rules/architecture.py
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 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
rule_id
property
Unique identifier for this rule.
check(project_path)
Check for god classes in the project.
Source code in packages/axm-audit/src/axm_audit/core/rules/architecture.py
LintingRule
dataclass
Bases: ProjectRule
Run ruff and score based on issue count.
Scoring: 100 - (issue_count * 2), min 0.
Source code in packages/axm-audit/src/axm_audit/core/rules/quality.py
rule_id
property
Unique identifier for this rule.
check(project_path)
Check project linting with ruff on src/ and tests/.
Source code in packages/axm-audit/src/axm_audit/core/rules/quality.py
LoggingPresenceRule
dataclass
Bases: ProjectRule
Verify that substantial source modules import logging.
Exempts __init__.py, _version.py, and modules with fewer
than 5 top-level definitions (functions + classes).
Source code in packages/axm-audit/src/axm_audit/core/rules/practices.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | |
rule_id
property
Unique identifier for this rule.
check(project_path)
Check logging presence in source modules.
Source code in packages/axm-audit/src/axm_audit/core/rules/practices.py
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
PyprojectCompletenessRule
dataclass
Bases: ProjectRule
Validate PEP 621 field completeness in pyproject.toml.
Checks 9 fields: name, version/dynamic, description, requires-python, license, authors, classifiers, urls, readme. Scoring: (fields_present / 9) x 100.
Source code in packages/axm-audit/src/axm_audit/core/rules/structure.py
rule_id
property
Unique identifier for this rule.
check(project_path)
Check pyproject.toml completeness.
Source code in packages/axm-audit/src/axm_audit/core/rules/structure.py
SecurityPatternRule
dataclass
Bases: ProjectRule
Detect hardcoded secrets via regex patterns.
Source code in packages/axm-audit/src/axm_audit/core/rules/practices.py
rule_id
property
Unique identifier for this rule.
check(project_path)
Check for hardcoded secrets in the project.
Source code in packages/axm-audit/src/axm_audit/core/rules/practices.py
SecurityRule
dataclass
Bases: ProjectRule
Run Bandit and score based on vulnerability severity.
Scoring: 100 - (high_count * 15 + medium_count * 5), min 0.
Source code in packages/axm-audit/src/axm_audit/core/rules/security.py
rule_id
property
Unique identifier for this rule.
check(project_path)
Check project security with Bandit.
Source code in packages/axm-audit/src/axm_audit/core/rules/security.py
TestCoverageRule
dataclass
Bases: ProjectRule
Check test coverage via pytest-cov.
Scoring: coverage percentage directly (e.g., 90% → score 90). Pass threshold: 90%.
Source code in packages/axm-audit/src/axm_audit/core/rules/coverage.py
rule_id
property
Unique identifier for this rule.
check(project_path)
Check test coverage and capture failures with pytest-cov.
Delegates to run_tests(mode='compact') from the shared
test runner for structured output, then converts the result
to a CheckResult.
Source code in packages/axm-audit/src/axm_audit/core/rules/coverage.py
TestMirrorRule
dataclass
Bases: ProjectRule
Check that every source module has a corresponding test file.
For each src/<pkg>/foo.py, looks for tests/**/test_foo.py
anywhere in the test tree (supports flat and nested layouts).
Private modules (leading underscores) are matched with the prefix
stripped: _facade.py matches test_facade.py or
test__facade.py.
Scoring: 100 - (missing_count * 15), min 0.
Source code in packages/axm-audit/src/axm_audit/core/rules/practices.py
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | |
rule_id
property
Unique identifier for this rule.
check(project_path)
Check test file coverage for source modules.
Source code in packages/axm-audit/src/axm_audit/core/rules/practices.py
ToolAvailabilityRule
dataclass
Bases: ProjectRule
Check if a required CLI tool is available on PATH.
Source code in packages/axm-audit/src/axm_audit/core/rules/tooling.py
rule_id
property
Unique identifier for this rule.
check(project_path)
Check if the tool is available on the system PATH.
Source code in packages/axm-audit/src/axm_audit/core/rules/tooling.py
get_instances()
classmethod
TypeCheckRule
dataclass
Bases: ProjectRule
Run mypy with zero-tolerance for errors.
Scoring: 100 - (error_count * 5), min 0. Pass/fail: any error means failure (matches pre-commit mypy hook).
Source code in packages/axm-audit/src/axm_audit/core/rules/quality.py
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 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
rule_id
property
Unique identifier for this rule.
check(project_path)
Check project type hints with mypy on src/ and tests/.
Source code in packages/axm-audit/src/axm_audit/core/rules/quality.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 |