michael34435/php-ranker
Composer 安装命令:
composer require michael34435/php-ranker
包简介
Grab GPA from your project with phpcs/phpmd/phpcpd violation report
README 文档
README
What's php-ranker?
php-ranker is a command line based parser to parse xml format report file generated by phpmd, phpcs and phpcpd.
All scores calculated by php-ranker are based on codeclimate except duplication report from phpcpd, because codeclimate use their own analysis tool(flay) to identify the code block is identical or similar but phpcpd cannot do it.
What metric do php-ranker use?
There are three dimensions php-ranker taken.
- Checkstyle
- All the things include
PSR-2standard and more
- All the things include
- PMD
- Checkstyle, complexity and code size
- Dry
- Duplication code detected from
phpcpdinstead offlay
- Duplication code detected from
How grades are calculated?
What's GPA(Grade Point Average)?
All grades are following GPA(Grade Point Average) a concept to determine you is good or bad in average in U.S school, most of it are 4-point-rule.
How to calculate it?
In general, GPA is four-point, it means the greatest student gets 4-point while the worst gets 0-point in this subject.
And we'll end up getting an average score from a person.
Like this chart:
| Grade | Point |
|---|---|
| A | 4.0 |
| B | 3.0 |
| C | 2.0 |
| D | 1.0 |
| F | 0.0 |
For example, there is a student who gets two A's(represents 4-point) and one B(represents 3-point) and we will get a formula -> (2 x 4 + 3) / (2 + 1) = 3.67
3.67 is the final score for this student.
How php-ranker get file score
You have to add a config file named .php-ranker(see .php-ranker.example) in your project and composer require php-ranker.
Then php-ranker will read your config file and glob them to compare violation report from phpcs, phpmd or phpcpd.
Finally, php-ranker gives each file a point below.(all rules are following codeclimate)
| Points | Rank |
|---|---|
| 0-2M | A |
| >2M-4M | B |
| >4M-8M | C |
| >8M-16M | D |
| >16M | F |
So your file will get a total point and php-ranker converts it to alphabetic rank finally.
How php-ranker get total GPA
All GPAs are based on file size.
For example, php-ranker finds three files
| Filename | Rank | Lines |
|---|---|---|
| Foo.php | A | 100 |
| FooBar.php | A | 200 |
| Bar.php | F | 1000 |
Foo.php A rank represent 4 point
FooBar.php A rank represent 4 point, too
But Bar.php is too bad to get score and get 0 point.
And we can find a formula -> (4 x 100 + 4 x 200 + 0 x 1000) / (200 + 100 + 1000) = 0.93
0.93 is the total GPA score for these files.
How to use php-ranker
Install
Composer
composer require michael34435/php-ranker
Phar
curl -LOk https://github.com/michael34435/php-ranker/raw/master/build/php-ranker chmod +x php-ranker mv php-ranker /usr/bin/php-ranker
Usage
./vendor/bin/php-ranker
--pmd-report-phpmdviolation report path(xml)--dry-report-phpcpdviolation report path(xml)--checkstyle-report-phpcsviolation report(xml)--export-dir- The path you want to store for the GPA report html
Notice
Version 0.01 and 0.02 only support jenkins report, i would like to recommend you to upgrade to 1.0.0 or dev-master ASAP.
michael34435/php-ranker 适用场景与选型建议
michael34435/php-ranker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 106.96k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2017 年 01 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 michael34435/php-ranker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 michael34435/php-ranker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 106.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-08