Skip to content

Commit 920b037

Browse files
committed
Add readme
1 parent e017dfc commit 920b037

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
Gitlab Report for PHP_CodeSniffer
3+
---------------------------------
4+
5+
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.
6+
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.
7+
8+
## Installation
9+
10+
Install this library using [Composer](https://getcomposer.org):
11+
12+
```shell script
13+
composer require --dev micheh/phpcs-gitlab
14+
```
15+
16+
Then adjust your `.gitlab-ci.yml` to run PHP_CodeSniffer with the custom reporter and to gather the codequality artifacts:
17+
18+
```yaml
19+
phpcs:
20+
script: vendor/bin/phpcs --report=emacs --report-\\Micheh\\PhpCodeSniffer\\Report\\Gitlab=phpcs-quality-report.json
21+
artifacts:
22+
reports:
23+
codequality: phpcs-quality-report.json
24+
```
25+
26+
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.
27+
28+
> **Note:** Gitlab currently does not support multiple codequality artifacts.
29+
> You will not be able to display the violations of multiple tools (e.g. PHP Code Sniffer & PHPStan) in the Code Quality report.
30+
31+
32+
## References
33+
34+
- [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)
35+
- [Gitlab CI/CD Code Quality](https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html)
36+
- [Code Climate Specification](https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#data-types)
37+
38+
39+
## License
40+
41+
The files in this archive are licensed under the BSD-3-Clause license.
42+
You can find a copy of this license in [LICENSE.md](LICENSE.md).

src/Report/GitlabReport.php renamed to src/Report/Gitlab.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
use const PHP_EOL;
1919

20-
class GitlabReport implements Report
20+
class Gitlab implements Report
2121
{
2222
/**
2323
* @param File $phpcsFile

0 commit comments

Comments
 (0)