Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/micheh/phpcs-gitlab
Gitlab Report for PHP_CodeSniffer (display the violations in the Gitlab CI/CD Code Quality Report)
https://github.com/micheh/phpcs-gitlab
code-quality gitlab gitlab-report php-codesniffer phpcs
Last synced: 3 days ago
JSON representation
Gitlab Report for PHP_CodeSniffer (display the violations in the Gitlab CI/CD Code Quality Report)
- Host: GitHub
- URL: https://github.com/micheh/phpcs-gitlab
- Owner: micheh
- License: bsd-3-clause
- Created: 2020-05-21T12:19:29.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-01T19:00:33.000Z (almost 2 years ago)
- Last Synced: 2024-11-11T10:49:32.880Z (3 days ago)
- Topics: code-quality, gitlab, gitlab-report, php-codesniffer, phpcs
- Language: PHP
- Homepage:
- Size: 44.9 KB
- Stars: 38
- Watchers: 2
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Gitlab Report for PHP_CodeSniffer
---------------------------------
![Main workflow](https://github.com/micheh/phpcs-gitlab/workflows/Main%20workflow/badge.svg)
[![codecov](https://codecov.io/gh/micheh/phpcs-gitlab/branch/master/graph/badge.svg)](https://codecov.io/gh/micheh/phpcs-gitlab)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=full --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 (full) 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.Inside the codequality artifact, Gitlab expects relative paths to the files with violations.
To generate relative paths with PHP Code Sniffer, set the `basepath` argument in your `phpcs.xml.dist` configuration file with `` or run phpcs with `--basepath=.` (adjust the base path as necessary).## 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).