Metadata-Version: 2.4
Name: code-analytics
Version: 0.1.0
Summary: Unified code analysis for TypeScript/JavaScript: duplicates, dead code, dependency cycles
Author: DecSec2030
License: MIT
Project-URL: Homepage, https://github.com/DecSec2030/code-analytics
Project-URL: Source, https://github.com/DecSec2030/code-analytics
Project-URL: Issues, https://github.com/DecSec2030/code-analytics/issues
Keywords: code-quality,duplicate-code,dead-code,circular-dependencies,typescript,javascript,react,vue,svelte
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# code-analytics

Unified CLI for TypeScript/JavaScript code analysis.  Combines duplicate detection and dead-code finding in one tool.

## Features

- **Duplicate analysis** — structural duplicate detection (normalize → hash → group)
- **Dead code analysis** — unused exports, unused locals (variables, functions, types, interfaces, classes, enums)
- **Multiple output formats** — text, JSON, Markdown
- **Suggest-fix mode** — concrete refactoring suggestions for each finding
- **Cross-project** — works on any TS/JS codebase

## Installation

```bash
git clone https://github.com/DecSec2030/code-analytics.git
cd code-analytics
```

The tool expects `find_duplicates.py` and `find-dead-code/` as sibling directories.

## Usage

```bash
# Run all analyses
python3 code-analytics.py --path /path/to/project --all

# Run specific analyses
python3 code-analytics.py --path /path/to/project --duplicates
python3 code-analytics.py --path /path/to/project --dead-code

# JSON output
python3 code-analytics.py --path /path/to/project --all --json

# Markdown report
python3 code-analytics.py --path /path/to/project --all --markdown > report.md

# With refactoring suggestions
python3 code-analytics.py --path /path/to/project --all --suggest-fix

# With options per analyzer
python3 code-analytics.py --path /path/to/project --duplicates \
  --duplicates-min-lines 5 --duplicates-min-occurrences 3
```

## Example output

```
$ python3 code-analytics.py --path my-project --all
============================================================
CODE ANALYTICS REPORT
============================================================

Duplicates Analysis
----------------------------------------
  Files scanned:      42
  Duplicate groups:   7
  Duplicate ratio:    16.7%

Dead Code Analysis
----------------------------------------
  Files scanned:      42
  Unused exports:     3
  Unused locals:      7
  Total dead code:    10
```

## Architecture

```
code-analytics/
├── code-analytics.py       # CLI entry point
├── analyzers/
│   ├── base.py             # Abstract base class
│   ├── duplicates.py       # Calls find_duplicates.py
│   └── dead_code.py        # Calls find-dead-code/find_dead_code.py
├── reporters/
│   ├── base.py             # Abstract base class
│   ├── text.py             # Text output
│   ├── json.py             # JSON output
│   └── markdown.py         # Markdown output
└── tests/
```

## Dependencies

- Python ≥ 3.10
- [find-duplicates](https://github.com/DecSec2030/find-duplicates) (sibling directory)
- [find-dead-code](https://github.com/DecSec2030/find-dead-code) (sibling directory)
- Node.js (for TypeScript parsing, via find-dead-code)

## License

MIT
