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
- 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.
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
orport install graphviz
)
Install Code Health Meter as a development dependency:
npm i -D code-health-meter
To analyze a project, run:
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.
We welcome contributions! 🎉 If you'd like to improve Code Health Meter, follow these steps:
-
Fork the repository and clone it locally:
git clone https://github.com/helabenkhalfallah/code-health-meter.git cd code-health-meter
-
Install dependencies:
npm install
-
Run a local analysis:
npm run scan --srcDir "../../my-path" --outputDir "../../my-output-path" --format "json or html"
Using PNPM? No problem! 🚀
pnpm scan --srcDir "../../my-path" --outputDir "../../my-output-path" --format "json or html"
This project is licensed under the MIT License 📄. See the LICENSE file for details.
💬 If you encounter any issues or have questions, feel free to open an issue or start a discussion in the repository! 🚀