Skip to content

Commit

Permalink
Add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
micheh committed May 22, 2020
1 parent e017dfc commit 920b037
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

Gitlab Report for PHP_CodeSniffer
---------------------------------

This library adds a custom report to [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) (phpcs) to generate a codequality artifact, which can be used by Gitlab CI/CD.
The custom report will be generated in the Code Climate format and allows Gitlab CI/CD to display the violations in the Code Quality report.

## Installation

Install this library using [Composer](https://getcomposer.org):

```shell script
composer require --dev micheh/phpcs-gitlab
```

Then adjust your `.gitlab-ci.yml` to run PHP_CodeSniffer with the custom reporter and to gather the codequality artifacts:

```yaml
phpcs:
script: vendor/bin/phpcs --report=emacs --report-\\Micheh\\PhpCodeSniffer\\Report\\Gitlab=phpcs-quality-report.json
artifacts:
reports:
codequality: phpcs-quality-report.json
```
The example above uses two reports, one to display in the build log (emacs) and one to generate the codequality artifact file in the Code Climate format.
> **Note:** Gitlab currently does not support multiple codequality artifacts.
> You will not be able to display the violations of multiple tools (e.g. PHP Code Sniffer & PHPStan) in the Code Quality report.
## References
- [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)
- [Gitlab CI/CD Code Quality](https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html)
- [Code Climate Specification](https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#data-types)
## License
The files in this archive are licensed under the BSD-3-Clause license.
You can find a copy of this license in [LICENSE.md](LICENSE.md).
2 changes: 1 addition & 1 deletion src/Report/GitlabReport.php → src/Report/Gitlab.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use const PHP_EOL;

class GitlabReport implements Report
class Gitlab implements Report
{
/**
* @param File $phpcsFile
Expand Down

0 comments on commit 920b037

Please sign in to comment.