PHP-CS-Fixer: GitLab Reporter does not report correctly the lines of the errors

Bug report

Description

GitLab reporter does not report correctly the lines of the errors

Runtime version

PHP CS Fixer 3.22.0 Chips & Pizza by Fabien Potencier and Dariusz Ruminski. PHP runtime: 8.1.21

Used command

IFS='
'
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "${CI_MERGE_REQUEST_DIFF_BASE_SHA}..HEAD")
EXTRA_ARGS=$(printf -- '--path-mode=intersection\n--\n%s' "${CHANGED_FILES}")
./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --dry-run --using-cache=no --format=gitlab --diff ${EXTRA_ARGS} > php-cs-fixer.json

Configuration file

<?php

$finder = PhpCsFixer\Finder::create()
    ->in(__DIR__.'/src/')
    ->in(__DIR__.'/tests/');

$config = new PhpCsFixer\Config();
return $config->setRules([
    '@PSR12' => true,
    '@Symfony' => true,
])
    ->setFinder($finder)
;

Code snippet that reproduces the problem

pUbLiC fUnCtIoN TeStCsFiXeR():void { /* ça devrait trigger de ZIN-ZIN */ $i=0;$i++; }

When missing --diff, reports as L0 instead of L49, updated docs image image

Reports as L46 instead of L49 image image

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 21 (15 by maintainers)

Most upvoted comments

I would say it would make more sense to aggregate all the applied rule names per file and print it as 1 violation in GL reporter.