PHPackages                             savinmikhail/comments-density - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. savinmikhail/comments-density

ActiveComposer-plugin[Testing &amp; Quality](/categories/testing)

savinmikhail/comments-density
=============================

CommentDensityAnalyzer is a tool designed to analyze the comment density and quality in source code files in php. It helps maintain and improve the quality of code documentation by evaluating different types of comments and providing insights into their effectiveness and appropriateness.

v0.5.9(1y ago)506171MITPHPPHP &gt;=8.2CI failing

Since May 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/savinmikhail/Comments-Density)[ Packagist](https://packagist.org/packages/savinmikhail/comments-density)[ RSS](/packages/savinmikhail-comments-density/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (21)Versions (30)Used By (1)

 [ ![Quality Score](https://camo.githubusercontent.com/3245d22d46d05accfdf7ac809b8041a4719cd5da2054b02336621775fb5e3d35/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736176696e6d696b6861696c2f436f6d6d656e74732d44656e736974792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e) ](https://scrutinizer-ci.com/g/savinmikhail/Comments-Density/?branch=main) [ ![Code Coverage](https://camo.githubusercontent.com/8d86fd367955b002b1ec8cfb9b458261a027a4f151fbb501050c60a78b14461a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736176696e6d696b6861696c2f436f6d6d656e74732d44656e736974792f6261646765732f636f7665726167652e706e673f623d6d61696e) ](https://scrutinizer-ci.com/g/savinmikhail/Comments-Density/?branch=main) [ ![Build Status](https://camo.githubusercontent.com/3a670a287dbbd90dc3620b07751245c033a4c7eec602b180739022e8b64df445/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736176696e6d696b6861696c2f436f6d6d656e74732d44656e736974792f6261646765732f6275696c642e706e673f623d6d61696e) ](https://scrutinizer-ci.com/g/savinmikhail/Comments-Density/?branch=main) [ ![Mutation Testing Badge](https://camo.githubusercontent.com/6ec1f77496158319516f08ea34c837c08f8629894e59c1af76532fa185abba86/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d253246736176696e6d696b6861696c253246436f6d6d656e74732d44656e736974792532466d61696e) ](https://dashboard.stryker-mutator.io/reports/github.com/savinmikhail/Comments-Density/main)

Comments Density Analyzer
=========================

[](#comments-density-analyzer)

The **Comments Density Analyzer** is a tool to help you monitor and manage comments in your codebase.

### Why Use It?

[](#why-use-it)

- **Control TODOs and FIXMEs in CI/CD**: Ensure these comments are not proliferating unchecked in your codebase.
- **Spot Problematic Comments**: Identify regular comments explaining "shitty code" or remnants of commented-out code.
- **Enforce Documentation Standards**: Require docblocks for classes and methods to maintain clear, consistent documentation.

All of this is made possible with a powerful **plugin system** (see the documentation for examples).

Features
--------

[](#features)

- **Multiple Comment Types**: Detect and analyze regular comments, docblocks, TODOs, FIXMEs, and license headers.
- **Plugin Support**: Extend functionality by creating custom plugins via a simple interface.
- **Detailed Reporting**: Quickly identify areas of your code that need attention.
- **Thresholds and Exit Codes**: Set thresholds for comment types and return an exit code when they are exceeded.
- **Configurable Reports**: Output results to the console or as an HTML report.
- **Baseline Support**: Filter out known technical debt using a baseline file and focus on new issues.

### Output Example

[](#output-example)

[![Output Example](./example_for_readme.png)](./example_for_readme.png)

---

Installation
------------

[](#installation)

Install **Comments Density Analyzer** as a development dependency via Composer:

```
composer require --dev savinmikhail/comments-density
```

---

Usage
-----

[](#usage)

Analyze the comments in your PHP files:

```
php vendor/bin/comments_density analyze
```

Generate a baseline to ignore existing technical debt:

```
php vendor/bin/comments_density baseline
```

---

Configuration
-------------

[](#configuration)

During installation, the tool can generate a default configuration file. Customize your analysis by editing the `comments_density.php` file:

```
