定制 michael34435/php-ranker 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

michael34435/php-ranker

最新稳定版本:1.0.3

Composer 安装命令:

composer require michael34435/php-ranker

包简介

Grab GPA from your project with phpcs/phpmd/phpcpd violation report

README 文档

README

Build Status Code Climate

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-2 standard and more
  • PMD
    • Checkstyle, complexity and code size
  • Dry
    • Duplication code detected from phpcpd instead of flay

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 - phpmd violation report path(xml)
  • --dry-report - phpcpd violation report path(xml)
  • --checkstyle-report - phpcs violation 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.

统计信息

  • 总下载量: 105.18k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-08