A code quality control tool for PHP that will give you an idea of the composition of comments in the codebase, and help improve documentation
The Comments Density Analyzer is a tool to help you monitor and manage comments in your codebase.
All of this is made possible with a powerful plugin system (see the documentation for examples).
Install Comments Density Analyzer as a development dependency via Composer:
composer require --dev savinmikhail/comments-density
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
During installation, the tool can generate a default configuration file. Customize your analysis by editing the comments_density.php
file:
<?php
declare(strict_types=1);
use SavinMikhail\CommentsDensity\AnalyzeComments\Comments\FixMeComment;
use SavinMikhail\CommentsDensity\AnalyzeComments\Comments\RegularComment;
use SavinMikhail\CommentsDensity\AnalyzeComments\Comments\TodoComment;
use SavinMikhail\CommentsDensity\AnalyzeComments\Config\DTO\Config;
return new Config(
directories: [
'src',
],
thresholds: [
RegularComment::NAME => 0,
TodoComment::NAME => 0,
FixMeComment::NAME => 0,
],
);
This project was inspired by Yegor Bugayenko. See Open Source Ideas.
Contributions are always welcome! Feel free to submit a pull request with improvements or new features.
This library is licensed under the MIT License.