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.
- Host: GitHub
- URL: https://github.com/helabenkhalfallah/code-health-meter
- Owner: helabenkhalfallah
- License: mit
- Created: 2024-05-24T09:51:59.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-24T08:29:24.000Z (3 months ago)
- Last Synced: 2025-04-12T23:53:49.676Z (3 months ago)
- Topics: code-analysis, code-analysis-tool, cyclomatic-complexity, halstead-metrics, javascript, maintenability-index, typescript
- Language: JavaScript
- Homepage:
- Size: 2.61 MB
- Stars: 27
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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! π