Download the PHP package michael34435/php-ranker without Composer
On this page you can find all versions of the php package michael34435/php-ranker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-ranker
php-ranker
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
- All the things include
- PMD
- Checkstyle, complexity and code size
- Dry
- Duplication code detected from
phpcpd
instead 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
Phar
Usage
--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.