Skip to content

Conversation

@VitalyArt
Copy link
Contributor

@VitalyArt VitalyArt commented Jan 26, 2025

Adoption of the CodeClimate format for GitLab CI integration

Specification: https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#data-types

Example

Run command:

php bin/rector process bin --output-format=gitlab --dry-run

Output:

[
    {
        "fingerprint": "7e5f879fe12ff579e958c9935e9ee034",
        "type": "issue",
        "categories": [
            "Bug Risk"
        ],
        "severity": "blocker",
        "description": "Syntax error, unexpected T_VARIABLE",
        "check_name": "",
        "location": {
            "path": "bin/test-fixture-stats.php",
            "lines": {
                "begin": 17
            }
        }
    },
    {
        "fingerprint": "183de697ac3261bb7f85226e0ef2253a",
        "type": "issue",
        "categories": [
            "Style"
        ],
        "severity": "minor",
        "description": "MultiDirnameRector / AddVoidReturnTypeWhereNoReturnRector",
        "content": {
            "body": "--- Original\n+++ New\n@@ -71,7 +71,7 @@\n         $this->loadIfExistsAndNotLoadedYet('vendor/autoload.php');\n     }\n \n-    public function autoloadFromCommandLine()\n+    public function autoloadFromCommandLine(): void\n     {\n         $cliArgs = $_SERVER['argv'];\n \n"
        },
        "check_name": "MultiDirnameRector / AddVoidReturnTypeWhereNoReturnRector",
        "location": {
            "path": "bin/rector.php",
            "lines": {
                "begin": 70
            }
        }
    }
]

Code Quality widget:

image

@VitalyArt VitalyArt force-pushed the output-format-code-climate branch from fd5bfc4 to 48be2ad Compare January 26, 2025 18:50
@VitalyArt VitalyArt force-pushed the output-format-code-climate branch from 48be2ad to 219df95 Compare January 27, 2025 05:31
@VitalyArt VitalyArt force-pushed the output-format-code-climate branch from 219df95 to 601fe26 Compare January 27, 2025 22:19
@samsonasik
Copy link
Member

Let's give it a try, thank you @VitalyArt

@samsonasik samsonasik merged commit da5685d into rectorphp:main Jan 28, 2025
40 checks passed
@mickverm
Copy link
Contributor

mickverm commented Feb 6, 2025

Is there a way to get console output in CI while also generating a report file in the Gitlab format?

@VitalyArt
Copy link
Contributor Author

Is there a way to get console output in CI while also generating a report file in the Gitlab format?

@mickverm you can use the tee command

Example:

php bin/rector process bin --output-format=gitlab --dry-run | tee output.json

@mickverm
Copy link
Contributor

mickverm commented Feb 7, 2025

I was thinking something more in line of PHPUnit, where I can get the regular output in the CI console and generate a coverage report at the same time.

php bin/phpunit --colors=never --log-junit=report.xml --coverage-text --coverage-cobertura=coverage-cobertura.xml --coverage-clover=coverage-clover.xml

@VitalyArt
Copy link
Contributor Author

@mickverm
Yes, that's a good idea, but we shouldn't do it in this current pull request

@github-actions
Copy link
Contributor

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants