Skip to content

This is a code quality tool for PHP, aiming to improve quality of comments in your code

License

Notifications You must be signed in to change notification settings

savinmikhail/Comments-Density

Repository files navigation

Quality Score Code Coverage Build status

Comments Density Analyzer

A tool to analyze the comment density and quality in PHP source code files, helping to maintain and improve code documentation quality.

Features

  • Multiple Comment Types: Supports identification and analysis of several comment types including regular, docblocks, TODOs, FIXMEs, and license information. You can configure the set of them to be evaluated.
  • Detailed Reporting: Quickly find code spots where changes might be necessary.
  • Quality Check: Set up a configuration file, and if thresholds aren't met, the exit code will be returned with the report.
  • Configurable Reports: Get results in either console or HTML file.
  • Pre-commit hook: Validate only the files that are about to be committed.

Output Example

Output Example

Installation

To install Comment Density Analyzer, run the following command in your terminal:

composer require --dev savinmikhail/comments-density

Usage

Analyze the comment density in your PHP files with:

php vendor/bin/comments_density analyze:comments

Configuration

On installation, you can allow plugin to create its configuration file. Customize your analysis by editing a comments_density.php configuration file:

d<?php

return [
    'directories' => [
        'vendor',
    ],
    'exclude' => [
        'src/DTO',
    ],
    'thresholds' => [
        'docBlock' => 90,
        'regular' => 5,
        'todo' => 5,
        'fixme' => 5,
        'missingDocBlock' => 10,
        'Com/LoC' => 0.1,
        'CDS' => 0.1,
    ],
    'only' => [
        'missingDocblock'
    ],
    'output' => [
        'type' => 'console', // "console" or 'html'
        'file' => 'output.html', // file path for HTML output
    ],
    'missingDocblock' => [
        'class' => true,
        'interface' => true,
        'trait' => true,
        'enum' => true,
        'property' => true,
        'constant' => true,
        'function' => true,
    ]
];

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This library is released under the MIT license.


About

This is a code quality tool for PHP, aiming to improve quality of comments in your code

Topics

Resources

License

Stars

Watchers

Forks

Languages