Skip to main content

Source code analyser — part of the analyser family

Project description

code-analyser

Analyses source code files and returns style violations, complexity metrics, and quality indicators. Designed as a low-level tool — feed it a file, get back structured JSON.

Part of the analyser family.

Status: Early development. Currently supports Python via ruff and basic AST metrics. Multi-language support and alignment with the family API pattern is in progress.

Install

pip install code-analyser

Requires Python 3.11+.

Usage

Python

from code_analyser import analyse

result = analyse("submission.py")

print(f"Lines:      {result['metrics']['lines_of_code']}")
print(f"Complexity: {result['metrics']['cyclomatic_complexity']}")
print(f"Issues:     {len(result['issues'])}")

HTTP API

# Start the server
uvicorn code_analyser.main:app --port 8004

curl -X POST http://localhost:8004/api/v1/analyze/python \
  -H "Content-Type: application/json" \
  -d '{"code": "def hello():\n    print(\"Hello\")", "language": "python"}'

Supported languages

Language Status
Python supported (ruff, AST metrics)
JavaScript, Java, others planned

Output

{
  "language": "python",
  "metrics": {
    "lines_of_code": 42,
    "cyclomatic_complexity": 3,
    "maintainability_index": 74.2
  },
  "issues": [
    {"rule": "E501", "line": 12, "message": "line too long (92 > 88 characters)"}
  ],
  "summary": {
    "error_count": 0,
    "warning_count": 1,
    "style_count": 2
  }
}

The analyser family

Low-level analysis tools. Each accepts files directly and returns structured JSON. Build your own UI or pipeline on top.

Package Handles
speech-analyser audio and video files — transcript and speech metrics
video-analyser video files — frames, scenes, and visual quality
document-analyser PDF, DOCX, PPTX, TXT — text and readability
code-analyser source code — style, complexity, and quality metrics
records-analyser CSV, Excel, SQLite, Parquet, JSON — data profiling
auto-analyser any file — detects format and routes to the right tool

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

code_analyser-1.0.3.tar.gz (95.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

code_analyser-1.0.3-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file code_analyser-1.0.3.tar.gz.

File metadata

  • Download URL: code_analyser-1.0.3.tar.gz
  • Upload date:
  • Size: 95.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for code_analyser-1.0.3.tar.gz
Algorithm Hash digest
SHA256 9b301d261359210189b3f7a338521a3bd026575bac49482711b7fe5965cfc6df
MD5 04d6f673ee13e75f05a69e107d2eee50
BLAKE2b-256 1c4b01e0c1ac20655d6ce59ca3ef4c10179910580b259906557d6315b94f0f34

See more details on using hashes here.

File details

Details for the file code_analyser-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: code_analyser-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for code_analyser-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f6a6b54009ecb49596c707d706bc84712f9cbb7ff35b7fe6c0fd3a6caed6d0e6
MD5 31e071103f17389554723d7d80c1b1c0
BLAKE2b-256 17f93fea11ccfbe727848b29b7cd7c7305826933e496e3d0090db57c2fcbcdc1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page