Skip to content

Undefined index when running in parallel with same paths defined in different styles #3264

@func0der

Description

@func0der

Describe the bug
If you define the same 'file' in two different notations, parallel running of phpcs triggers:

Code sample

<?php

namespace Func0der\PhpCsTest;

class Test
{

}

Custom ruleset

<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
    <rule ref="PSR12"/>
    <file>src</file>
    <file>./src</file>
</ruleset>

To reproduce
Steps to reproduce the behavior:

  1. Create a file called src/Test.php and a phpcs.xml with the code sample above
  2. Run phpcs --parallel=50
  3. See error message displayed
PHP Fatal error:  Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: Undefined index:  in /home/vagrant/phpcs-test/vendor/squizlabs/php_codesniffer/src/Files/FileList.php on line 187 in /home/vagrant/phpcs-test/vendor/squizlabs/php_codesniffer/src/Runner.php:606
Stack trace:
#0 /home/vagrant/phpcs-test/vendor/squizlabs/php_codesniffer/src/Files/FileList.php(187): PHP_CodeSniffer\Runner->handleErrors()
#1 /home/vagrant/phpcs-test/vendor/squizlabs/php_codesniffer/src/Runner.php(487): PHP_CodeSniffer\Files\FileList->current()
#2 /home/vagrant/phpcs-test/vendor/squizlabs/php_codesniffer/src/Runner.php(114): PHP_CodeSniffer\Runner->run()
#3 /home/vagrant/phpcs-test/vendor/squizlabs/php_codesniffer/bin/phpcs(18): PHP_CodeSniffer\Runner->runPHPCS()
#4 {main}
  thrown in /home/vagrant/phpcs-test/vendor/squizlabs/php_codesniffer/src/Runner.php on line 606

Expected behavior
I am not sure what I would expect, because this could be a simple mis-configuration issue.
If this is intended behavior, I would expect a clearer error message.

Versions (please complete the following information):

  • OS: Debian
  • PHP: ^7.4
  • PHPCS: ^3.5.8
  • Standard: PSR12

Additional context
Repo to reproduce the problem: https://github.com/func0der/phpcs-test/blob/main/composer.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions