degraciamathieu/php-line-length-detector

PHP代码异味检测器

v0.1.0 2023-07-15 16:09 UTC

This package is auto-updated.

Last update: 2024-09-15 18:41:06 UTC


README

testing Packagist Version Packagist PHP Version

php-line-length-detector

一种简单的方法来分析您的PHP文件的行长度。

安装

Requires >= PHP 8.1

Phar

此工具以PHP存档(PHAR)的形式分发

wget https://github.com/DeGraciaMathieu/php-line-length-detector/raw/master/builds/php-line-length-detector
php php-line-length-detector --version

Composer

或者,您可以直接使用Composer

composer require degraciamathieu/php-line-length-detector --dev

使用

php php-line-length-detector inspect {path}
$ php php-line-length-detector inspect app

❀ PHP Line Lenght Detector ❀
+-------------+--------------+--------------+
| total lines | largest line | average line |
+-------------+--------------+--------------+
| 1068        | 197          | 37           |
+-------------+--------------+--------------+
+--------+------------+---------+
| length | occurrence | percent |
+--------+------------+---------+
| > 160  | 2          | 0 %     |
| > 120  | 5          | 0 %     |
| > 80   | 29         | 2 %     |
| > 60   | 111        | 10 %    |
| > 30   | 618        | 57 %    |
+--------+------------+---------+

您可以使用--thresholds=选项配置阈值(默认:160,120,80,60,30)

$ php php-line-length-detector inspect app --thresholds=120,60

❀ PHP Line Lenght Detector ❀
+-------------+--------------+--------------+
| total lines | largest line | average line |
+-------------+--------------+--------------+
| 1068        | 197          | 37           |
+-------------+--------------+--------------+
+--------+------------+---------+
| length | occurrence | percent |
+--------+------------+---------+
| > 120  | 5          | 0 %     |
| > 60   | 111        | 10 %    |
+--------+------------+---------+