Skip to content

Home

Codefang

The heavy lifter for your codebase — deep code analysis through structure and history.

CI Go Reference License: Apache 2.0


┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Codefang Overview                                              Score: 10/10 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

Codefang ships two binaries — uast for universal syntax-tree parsing across 60+ languages, and codefang for deep static and historical analysis of entire repositories. One tool, one config, complete understanding.


Key Metrics

60+

Languages Supported

14

Built-in Analyzers

6

Output Formats

MCP

AI-Agent Ready

Distribution

  Capabilities
  ──────────────────────────────────────────────────────────────────────────────
  UAST Parsing         ████████████████████  60+ languages via Tree-sitter
  Static Analysis      ████████████████████  5 analyzers (complexity, cohesion, …)
  History Analysis     ████████████████████  9 analyzers (burndown, devs, …)
  Output Formats       ████████████████████  JSON, YAML, text, compact, plot, binary
  Streaming Pipeline   ████████████████████  Bounded-memory, checkpointed
  Observability        ████████████████████  OpenTelemetry traces + metrics

Quick Install

go install github.com/Sumatoshi-tech/codefang/cmd/codefang@latest
go install github.com/Sumatoshi-tech/codefang/cmd/uast@latest
git clone https://github.com/Sumatoshi-tech/codefang.git
cd codefang
make build
make install
docker build -t codefang .
docker run --rm -v "$(pwd):/repo" codefang run -a static/complexity /repo

Verify the installation:

codefang --version
uast --version

Quick Example

$ codefang run -a static/complexity,static/halstead --format text .

codefang (v2):
  version: 2
  hash: abc123def456

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Complexity                                                     Score: 8/10  ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

  Summary: Good overall code structure with some complex functions

  Key Metrics
  ──────────────────────────────────────────────────────────────────────────────
  Average Complexity   6.2           Max Complexity       18

  Distribution
  ──────────────────────────────────────────────────────────────────────────────
  Simple              ████████████████░░░░  65%  (42)
  Complex             ████░░░░░░░░░░░░░░░░  20%  (13)
  Critical            ██░░░░░░░░░░░░░░░░░░  15%  (10)

  Top Issues
  ──────────────────────────────────────────────────────────────────────────────
  ProcessPayment       src/payment.go:245              HIGH
  ValidateInput        src/utils.go:89                 MEDIUM

Analyzers at a Glance

Static Analyzers

Analyzer Description Key Metric
complexity Cyclomatic and cognitive complexity per function Score 0–10
cohesion Class/module cohesion metrics (LCOM) LCOM ratio
halstead Halstead software science metrics Volume, Difficulty
comments Comment density and documentation ratios Density %
imports Import/dependency graph analysis Coupling score

History Analyzers

Analyzer Description Key Metric
burndown Code age and survival analysis over time Survival %
devs Per-developer contribution metrics LOC, commits
couples File and developer coupling patterns Coupling matrix
file-history Per-file change history and churn Churn rate
sentiment Commit message sentiment trends Sentiment score
shotness Function-level change frequency Hotspot rank
typos Identifier typo detection across history Typo count
anomaly Automated anomaly detection in metrics Z-score

Explore the Docs