{"id":20684354,"url":"https://github.com/michael34435/php-ranker","last_synced_at":"2025-04-22T12:46:18.658Z","repository":{"id":62528005,"uuid":"76656313","full_name":"michael34435/php-ranker","owner":"michael34435","description":"Grab GPA from your project with phpcs/phpmd/phpcpd violation report 👏","archived":false,"fork":false,"pushed_at":"2017-07-06T09:18:57.000Z","size":1378,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T15:21:05.711Z","etag":null,"topics":["checkstyle","code-quality","duplication","grades","pmd","score","violation-report"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michael34435.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-16T13:36:24.000Z","updated_at":"2023-05-31T15:21:48.000Z","dependencies_parsed_at":"2022-11-02T16:15:37.626Z","dependency_job_id":null,"html_url":"https://github.com/michael34435/php-ranker","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael34435%2Fphp-ranker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael34435%2Fphp-ranker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael34435%2Fphp-ranker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael34435%2Fphp-ranker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michael34435","download_url":"https://codeload.github.com/michael34435/php-ranker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249341903,"owners_count":21254200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["checkstyle","code-quality","duplication","grades","pmd","score","violation-report"],"created_at":"2024-11-16T22:21:12.890Z","updated_at":"2025-04-22T12:46:18.634Z","avatar_url":"https://github.com/michael34435.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-ranker\n[![Build Status](https://travis-ci.org/michael34435/php-ranker.svg?branch=master)](https://travis-ci.org/michael34435/php-ranker)\n[![Code Climate](https://codeclimate.com/github/michael34435/php-ranker/badges/gpa.svg)](https://codeclimate.com/github/michael34435/php-ranker)\n\n## What's php-ranker?\n`php-ranker` is a command line based parser to parse `xml` format report file generated by `phpmd`, `phpcs` and `phpcpd`.  \nAll 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.\n\n## What metric do php-ranker use?\nThere are three dimensions `php-ranker` taken.  \n\n* Checkstyle\n  * All the things include `PSR-2` standard and more\n* PMD\n  * Checkstyle, complexity and code size\n* Dry\n  * Duplication code detected from `phpcpd` instead of `flay`\n\n## How grades are calculated?\n### What's GPA(Grade Point Average)?\nAll 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.  \n\n### How to calculate it?\nIn general, GPA is **four-point**, it means the greatest student gets 4-point while the worst gets 0-point in this subject.  \nAnd we'll end up getting an average score from a person.  \nLike this chart:  \n\n\n|Grade|Point|\n|---|---|\n|A|4.0|\n|B|3.0|\n|C|2.0|\n|D|1.0|\n|F|0.0||\n\n\nFor 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 -\u003e *(2 x 4 + 3) / (2 + 1) = 3.67*  \n`3.67` is the final score for this student.\n\n### How php-ranker get file score\nYou have to add a config file named `.php-ranker`(see `.php-ranker.example`) in your project and composer require `php-ranker`.  \nThen `php-ranker` will read your config file and glob them to compare violation report from `phpcs`, `phpmd` or `phpcpd`.  \nFinally, `php-ranker` gives each file a point below.(all rules are following `codeclimate`)\n\n\n|Points|Rank|\n|---|---|\n|0-2M|A|\n|\u003e2M-4M|B|\n|\u003e4M-8M|C|\n|\u003e8M-16M|D|\n|\u003e16M|F||\n\n\nSo your file will get a total point and `php-ranker` converts it to alphabetic rank finally.\n\n### How php-ranker get total GPA\nAll GPAs are based on file size.  \nFor example, `php-ranker` finds three files  \n\n|Filename|Rank|Lines|\n|---|---|---|\n|Foo.php|A|100|\n|FooBar.php|A|200|\n|Bar.php|F|1000||\n\n`Foo.php` A rank represent 4 point  \n`FooBar.php` A rank represent 4 point, too  \nBut `Bar.php` is too bad to get score and get 0 point.  \n\nAnd we can find a formula -\u003e *(4 x 100 + 4 x 200 + 0 x 1000) / (200 + 100 + 1000) = 0.93*\n\n`0.93` is the total GPA score for these files.\n\n## How to use php-ranker\n### Install\n#### Composer\n```sh\ncomposer require michael34435/php-ranker\n```\n#### Phar\n```sh\ncurl -LOk https://github.com/michael34435/php-ranker/raw/master/build/php-ranker\nchmod +x php-ranker\nmv php-ranker /usr/bin/php-ranker\n```\n\n### Usage\n```sh\n./vendor/bin/php-ranker\n```\n\n* `--pmd-report`        - `phpmd` violation report path(xml)\n* `--dry-report`        - `phpcpd` violation report path(xml)  \n* `--checkstyle-report` - `phpcs` violation report(xml)\n* `--export-dir`        - The path you want to store for the GPA report html\n\n### Notice\nVersion `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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichael34435%2Fphp-ranker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichael34435%2Fphp-ranker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichael34435%2Fphp-ranker/lists"}