Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
helabenkhalfallah authored May 26, 2024
1 parent 94edf54 commit c853c0f
Showing 1 changed file with 45 additions and 5 deletions.
50 changes: 45 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,53 @@
# Code Health Meter

This repository contains a set of tools and utilities for analyzing the quality of JavaScript and TypeScript code. It uses various metrics and methodologies to provide a comprehensive overview of the code's complexity, maintainability, and other important aspects.
CodeHealthMeter is a comprehensive tool designed to measure and monitor the health of a codebase.
It provides a **quantitative evaluation** of your code's maintainability, complexity, and size using a variety of established software metrics.

## Features
Quantitative software quality analysis involves a mathematical approach to analyzing the source code and architecture of a software system.
By applying formulas like the Halstead metrics and the Maintainability Index, we can obtain precise, objective measures of various aspects of the software’s quality.

- **Code Complexity Analysis**: Analyze the cyclomatic complexity, Halstead complexity, and maintainability index of your code.
- **File Filtering**: Exclude specific files or directories from the analysis.
- **Customizable Reporting**: Generate detailed reports in various formats (JSON, HTML).
```js
SLOC: This is a simple metric that counts the number of lines in the source code.

Cyclomatic Complexity (M) = EN + 2P
// where E is the number of edges in the flow graph, N is the number of nodes, and P is the number of connected components.

Halstead Metrics:
- The number of operators (`n1`) and operands (`n2`) in the program's source code
- Program length (`N`): `N = n1 + n2`
- Program vocabulary (`n`): `n = N1 + N2`
- Volume (`V`): `V = N * log2(n)`
- Difficulty (`D`): `D = (n1/2) * (N2/n2)`
- Effort (`E`): `E = D * V`
Maintainability Index (MI) = 171 - 5.2 * ln(V) - 0.23 * v(g) - 16.2 * ln(SLOC)
```
These metrics, among others, allow us to quantify attributes of the software that might otherwise be difficult to measure.
This quantitative approach provides a more precise and objective assessment of software quality compared to more subjective methods.
Subjective methods for evaluating software quality often involve human judgment and interpretation. Here are a few examples:
- Peer Review: This involves having one or more colleagues review your code. They can provide feedback on various aspects such as coding style, logic, and potential bugs. However, the feedback can vary greatly depending on the reviewer’s experience, knowledge, and personal preferences.
- User Feedback: Collecting feedback from users is another subjective method. Users can provide valuable insights into the usability and functionality of the software. However, user feedback can be highly subjective and may not always reflect the technical quality of the software.
- Heuristic Evaluation: This involves having a small set of evaluators examine the user interface against a list of heuristic principles (e.g., Nielsen’s Heuristics). It’s subjective as it heavily relies on the expertise of the evaluators.
- Expert Opinion: An expert in the field provides their assessment of the software quality. This can be beneficial due to the expert’s deep knowledge, but again, it’s subjective and can be influenced by personal bias.
While these methods can provide valuable insights, they lack the objectivity and precision of quantitative methods like Halstead metrics or cyclomatic complexity. Therefore, a combination of both subjective and objective methods is often used in practice for a comprehensive evaluation of software quality.
## Key Features
- **Maintainability Index**: This metric provides a single score that reflects the maintainability of your code. It takes into account factors such as cyclomatic complexity, Halstead volume, and lines of code.
- **Cyclomatic Complexity**: This metric measures the number of linearly independent paths through a program's source code. It is a quantitative measure of the number of logical decisions a program can make, providing insights into its complexity.

- **Halstead Metrics**: Developed by Maurice Howard Halstead, these metrics provide insights into the complexity and understandability of your code. They measure aspects such as the number of unique operators and operands, program length, and program volume.

- **Source Lines of Code (SLOC)**: SLOC is a simple yet effective metric for estimating the size of a software program. It counts the number of lines in the source code, providing a measure of the program's length.
- **Report Generation**: CodeHealthMeter generates detailed reports in both HTML and JSON formats. These reports provide a visual and structured view of the metrics, making it easy to understand the health of your codebase at a glance.
By leveraging these metrics, CodeHealthMeter allows you to gain a deeper understanding of your code's health.
It helps you identify potential areas for improvement, making it an invaluable tool for maintaining high-quality, efficient, and maintainable code.

## More information about metrics

Expand Down

0 comments on commit c853c0f

Please sign in to comment.