audit_code_quality
Audit source code for complexity, code smells, duplicate blocks, and hallucinated imports to improve maintainability before refactoring or PR submission.
Instructions
Performs AST static code smell analysis, cyclomatic complexity profiling, duplicate code block detection, and AI coding hallucination validation, distinguishing from 'verify_security_guard' and 'analyze_code_dependencies' by scanning code maintainability and complexity rather than checking for credential leaks or analyzing module dependencies.
Parameters:
project_root(str, optional, default='.'): Root directory of the repository to audit (default: current directory).check_type(str, optional, default='all'): Audit scope: 'all' for complete check, 'smells' for code complexity/smells, 'duplicity' for copy-paste blocks, 'hallucinations' for invalid imports/signatures.file_path(str, optional, default=''): Optional path to a single file to audit.
Behavior:
Read-only: Inspects source syntax trees; does not modify or delete files.
Idempotent: Consistent diagnostic findings for the same code state.
100% Offline: Pure AST inspection without network calls.
Auth & Rate Limits: Zero credentials or external linters required; completes in <500ms.
Error Handling: Gracefully skips unparseable binary files and continues scanning source trees.
Usage Guidelines:
When to use: Run before submitting PRs or executing refactors to catch long methods (>30 lines), excessive arguments (>5), missing docstrings, copy-pasted blocks (6+ lines), or hallucinated imports.
When NOT to use: Do not use for scanning hardcoded secrets or installing git pre-commit security guards (use 'verify_security_guard' instead); do not use for analyzing module import dependencies (use 'analyze_code_dependencies' instead).
Returns: Comprehensive diagnostic report with severity ratings (T-001 to T-004), exact file line references, and remediation guidance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | No | Optional path to a single file to audit. | |
| check_type | No | Audit scope: 'all' for complete check, 'smells' for code complexity/smells, 'duplicity' for copy-paste blocks, 'hallucinations' for invalid imports/signatures. | all |
| project_root | No | Root directory of the repository to audit (default: current directory). | . |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |