Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

code-auditor

A zero-dependency Python code analysis suite — complexity, security, style, and dependency checking.

Features

  • Cyclomatic Complexity — McCabe-style calculation for every function/method
  • Security Audit — detects eval, exec, subprocess with shell=True, unsafe pickle, hardcoded passwords, SQL injection patterns
  • Style Check — line length, naming conventions (snake_case, PascalCase, ALL_CAPS), docstring presence, trailing whitespace
  • Dependency Analysis — categorises imports as stdlib / third-party / local
  • All-in-One — run every check in a single pass
  • TUI mode (--tui) — interactive curses-based interface
  • Colour-coded output — red for security warnings, yellow for style warnings, green for OK

Installation

pip install -e /path/to/code-auditor

Or from PyPI (future):

pip install code-auditor

Usage

# Cyclomatic complexity
code-auditor complexity myfile.py

# Security audit
code-auditor security myproject/

# Style check
code-auditor style myfile.py

# Dependency analysis
code-auditor deps myproject/

# All checks at once
code-auditor all myproject/

# TUI mode (interactive curses interface)
code-auditor --tui

Python module invocation

python -m code_auditor complexity myfile.py
python -m code_auditor --tui

Example output

$ code-auditor all sample.py
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
code-auditor — all checks
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

[COMPLEXITY] ────────────────────────────────────────
  calculate_score (line 23)  complexity: 5  OK
  process_data   (line 42)  complexity: 8  WARN (threshold: 10)

[SECURITY] ──────────────────────────────────────────
  Line 15:  WARNING  Use of 'eval()' detected
  Line 31:  WARNING  Hardcoded password pattern detected

[STYLE] ─────────────────────────────────────────────
  Line 80:  Line 81 exceeds 79 characters
  Line 12:  Missing docstring for function 'do_thing'

[DEPENDENCIES] ──────────────────────────────────────
  stdlib:      os, sys, json, re, hashlib
  third-party: requests, numpy
  local:       mymodule.utils

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
All checks complete.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Exit codes

  • 0 — all clear
  • 1 — warnings found
  • 2 — security issues found

License

MIT