Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Severity missing in Gitlab format #6175

Closed
Clement-B opened this issue Dec 14, 2021 · 2 comments · Fixed by #6180
Closed

Severity missing in Gitlab format #6175

Clement-B opened this issue Dec 14, 2021 · 2 comments · Fixed by #6180
Labels

Comments

@Clement-B
Copy link

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.

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

Expected result

Code quality should have been displayed in Gitlab merge request interface.

image

Analyze

Examples

  1. I generated a simple issue with php-cs-fixer using gitlab format and get this :
[{"description":"no_unused_imports","fingerprint":"15bc8a9d8b3877bee13ef9c4a3cc94ef","location":{"path":"acme\/src\/Controller\/IndexController.php","lines":{"begin":0}}}]

It wasn't recognized by Gitlab.

  1. I tried to put content output in a file and manually add severity and pushed it to the merge request :
[{"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.

@keradus
Copy link
Member

keradus commented Dec 14, 2021

Hey, thanks for your report!
Sounds like a good topic indeed, would you like to propose a patch with hardcoded minor severity?

@Clement-B
Copy link
Author

Clement-B commented Dec 15, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants