An open API service indexing awesome lists of open source software.

https://github.com/helabenkhalfallah/code-health-meter

code-health-meter is a comprehensive tool designed to measure and monitor the health of a codebase (JavaScript/TypeScript). It provides a quantitative evaluation of your code's maintainability, complexity, and size using a variety of established software metrics.
https://github.com/helabenkhalfallah/code-health-meter

code-analysis code-analysis-tool cyclomatic-complexity halstead-metrics javascript maintenability-index typescript

Last synced: 3 months ago
JSON representation

code-health-meter is a comprehensive tool designed to measure and monitor the health of a codebase (JavaScript/TypeScript). It provides a quantitative evaluation of your code's maintainability, complexity, and size using a variety of established software metrics.

Awesome Lists containing this project

README

        

# πŸ“Š Code Health Meter

## πŸ“– Table of Contents

1. [πŸ“’ Presentation](#-presentation)
2. [βš™οΈ Installation and Usage](#️-installation-and-usage)
3. [🀝 Contributing](#-contributing)
4. [πŸ“œ License](#-license)

---

## πŸ“’ Presentation

**Code Health Meter** is a **powerful and intelligent tool** 🧠 designed to analyze and enhance code quality. It evaluates key software metrics such as:

- **Maintainability** πŸ”„ – How easy the code is to update and extend.
- **Complexity** πŸ” – Measures the difficulty of understanding and modifying the code.
- **Duplication** πŸ” – Detects repeated code blocks that can be optimized.
- **Coupling** πŸ”— – Analyzes dependencies between modules to assess modularity.

By leveraging well-established methodologies, including **Halstead Metrics, Cyclomatic Complexity, Maintainability Index, and Graph-Based Metrics**, this tool helps developers **identify potential risks** ⚠️ and **refactoring opportunities** ✨ in their codebase.

### πŸš€ Key Features:

- **Quantitative Code Quality Analysis** – Uses mathematical models to assess maintainability, difficulty, and potential bugs.
- **Cyclomatic Complexity Calculation** – Evaluates control flow to determine function complexity.
- **Maintainability Index Assessment** – Provides insights into how easy the code is to maintain and extend.
- **Code Duplication Detection** – Implements the **Rabin–Karp algorithm** to identify redundant code blocks.
- **Graph-Based Software Metrics** – Analyzes dependencies and modularity using **Louvain Communities** and centrality measures.
- **Automated Report Generation** – Outputs results in **JSON and HTML formats** for easy visualization.

---

## βš™οΈ Installation and Usage

### πŸ“Œ Prerequisites
Before installing **Code Health Meter**, make sure you have the following dependencies installed:

- **Node.js** 🌐 – Required for running the tool.
- **Graphviz** πŸ“ˆ – Needed for graph-based analysis. (On macOS, install via `brew install graphviz` or `port install graphviz`)

### πŸ“₯ Installation
Install **Code Health Meter** as a development dependency:

```sh
npm i -D code-health-meter
```

### 🚦 Running the Analysis
To analyze a project, run:

```sh
npx code-health-meter --srcDir "../../my-path" --outputDir "../../my-output-path" --format "json or html"
```

After execution, you will find all generated reports inside the specified `outputDir`.

πŸ“‚ **Example Reports:** A sample project analysis with JSON and HTML reports is available in the `tests` folder.

---

## 🀝 Contributing

We welcome contributions! πŸŽ‰ If you'd like to improve **Code Health Meter**, follow these steps:

1. **Fork the repository and clone it locally:**
```sh
git clone https://github.com/helabenkhalfallah/code-health-meter.git
cd code-health-meter
```

2. **Install dependencies:**
```sh
npm install
```

3. **Run a local analysis:**
```sh
npm run scan --srcDir "../../my-path" --outputDir "../../my-output-path" --format "json or html"
```

**Using PNPM?** No problem! πŸš€
```sh
pnpm scan --srcDir "../../my-path" --outputDir "../../my-output-path" --format "json or html"
```

---

## πŸ“œ License

This project is licensed under the **MIT License** πŸ“„. See the [LICENSE](LICENSE) file for details.

---

### ❓ Need Help?

πŸ’¬ If you encounter any issues or have questions, feel free to open an [issue](https://github.com/helabenkhalfallah/code-health-meter/issues) or start a discussion in the repository! πŸš€