Repository: PHP-CS-Fixer/PHP-CS-Fixer (PHP)

Issue:
Severity missing in Gitlab format
## Version

   * PHP CS Fixer version: 3.4.0 Si!
   * Gitlab : GitLab Enterprise Edition 14.6.0-pre

## Bug report

I do not find a way to make Gitlab merge request show Code quality report from php cs fixer using `gitlab` format.

### Code snippet that reproduces the problem

I simplificated my current Gitlab job to be more understanding but didn't had time to make it working, sorry.

```yaml
code-style:
    image: php
    before_script:
        - # Download and install composer
        - composer install
    script:
        - php vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --dry-run --diff --format=gitlab > php-cs-fixer.json
    artifacts:
        reports:
            codequality: php-cs-fixer.json
        when: always
```

### Test case

1. Volontary add an issue in code style that has been well recognized locally but not fixed
2. Pushed to a new branch and create a merge request toward the main branch (main branch must have same job that had run at least one time)
3. Run job on pipeline
4. Check merge request

### Observed result

Job has failed (good) but no quality report is available in Gitlab merge request (not good) : 

![image](https://user-images.githubusercontent.com/5446081/146052760-4942f550-bb4b-46ec-957b-ae35de44c9d1.png)


### Expected result

Code quality should have been displayed in Gitlab merge request interface.

![image](https://user-images.githubusercontent.com/5446081/146054917-5db2220e-4226-4f0d-bbee-78206e37306c.png)

### Analyze

* The format "gitlab" of php-cs-fixer seems not to generate any `severity` field : https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/00096f01266da9160dadced3421df34369522a86/src/Console/Report/FixReport/GitlabReporter.php#L43-L52
*  `severity` field seems to be mandatory  by Gitlab to be correctly displayed in Gitlab interface : https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html#implementing-a-custom-tool
* Note : Code Climate Engine Specification used by Gitlab do not mark as mandatory `severity` field but others fields required by specification are not used by Gitlab. Therefore, Gitlab do not follow strictly Code Climate Engine Specification : https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#issues

### Examples

1. I generated a simple issue with php-cs-fixer using gitlab format and get this :  

```json
[{"description":"no_unused_imports","fingerprint":"15bc8a9d8b3877bee13ef9c4a3cc94ef","location":{"path":"acme\/src\/Controller\/IndexController.php","lines":{"begin":0}}}]
```

It wasn't recognized by Gitlab.

2. I tried to put content output in a file and manually add severity and pushed it to the merge request :

```json
[{"description":"no_unused_imports","fingerprint":"15bc8a9d8b3877bee13ef9c4a3cc94ef","severity": "major","location":{"path":"acme\/src\/Controller\/IndexController.php","lines":{"begin":0}}}]
```

This time it worked well, 

### Fix ?

I am aware that php-cs-fixer do not have specific severity for each issue but we could generate a default one to all issues for the gitlab format (`info` or `minor`) ?

This way, Gitlab will correclty show Code Quality panel in merge request using gitlab format of php cs fixer.



Discussion:
Hey, thanks for your report!
Sounds like a good topic indeed, would you like to propose a patch with hardcoded `minor` severity?
I have tried to make a patch for this bug in the following merge request #6180 .

Please tell me if I've done something wrong or if I miss something.



Patch:
diff --git a/src/Console/Report/FixReport/GitlabReporter.php b/src/Console/Report/FixReport/GitlabReporter.php
index f78f428e5ee..974d66d1190 100644
--- a/src/Console/Report/FixReport/GitlabReporter.php
+++ b/src/Console/Report/FixReport/GitlabReporter.php
@@ -43,6 +43,7 @@ public function generate(ReportSummary $reportSummary): string
                 $report[] = [
                     'description' => $fixerName,
                     'fingerprint' => md5($fileName.$fixerName),
+                    'severity' => 'minor',
                     'location' => [
                         'path' => $fileName,
                         'lines' => [


Test patch:
diff --git a/tests/Console/Report/FixReport/GitlabReporterTest.php b/tests/Console/Report/FixReport/GitlabReporterTest.php
index 7030cc1f743..5c8c074d224 100644
--- a/tests/Console/Report/FixReport/GitlabReporterTest.php
+++ b/tests/Console/Report/FixReport/GitlabReporterTest.php
@@ -46,6 +46,7 @@ protected function createSimpleReport(): string
             [{
                 "description": "some_fixer_name_here",
                 "fingerprint": "ad098ea6ea7a28dd85dfcdfc9e2bded0",
+                "severity": "minor",
                 "location": {
                     "path": "someFile.php",
                     "lines": {
@@ -67,6 +68,7 @@ protected function createWithAppliedFixersReport(): string
             [{
                 "description": "some_fixer_name_here_1",
                 "fingerprint": "b74e9385c8ae5b1f575c9c8226c7deff",
+                "severity": "minor",
                 "location": {
                     "path": "someFile.php",
                     "lines": {
@@ -76,6 +78,7 @@ protected function createWithAppliedFixersReport(): string
             },{
                 "description": "some_fixer_name_here_2",
                 "fingerprint": "acad4672140c737a83c18d1474d84074",
+                "severity": "minor",
                 "location": {
                     "path": "someFile.php",
                     "lines": {
@@ -97,6 +100,7 @@ protected function createComplexReport(): string
             [{
                 "description": "some_fixer_name_here_1",
                 "fingerprint": "b74e9385c8ae5b1f575c9c8226c7deff",
+                "severity": "minor",
                 "location": {
                     "path": "someFile.php",
                     "lines": {
@@ -106,6 +110,7 @@ protected function createComplexReport(): string
             },{
                 "description": "some_fixer_name_here_2",
                 "fingerprint": "acad4672140c737a83c18d1474d84074",
+                "severity": "minor",
                 "location": {
                     "path": "someFile.php",
                     "lines": {
@@ -115,6 +120,7 @@ protected function createComplexReport(): string
             },{
                 "description": "another_fixer_name_here",
                 "fingerprint": "30e86e533dac0f1b93bbc3a55c6908f8",
+                "severity": "minor",
                 "location": {
                     "path": "anotherFile.php",
                     "lines": {