Skip to content

Reached maximum number of loops with 0 violations left unfixed . #1336

@vol4onok

Description

@vol4onok

Describe the bug

After upgrading to PHP_CodeSniffer 3.13.0, phpcbf fails to fix files containing a large number of fully qualified namespace violations. The command outputs "*** Reached maximum number of loops with 0 violations left unfixed ***" and reverts all fixes.

I have a PHP file with many fully qualified class names (e.g., \Full\Namespace\Class::class)
Run phpcbf on the file with rules that convert FQCN to short names with use statements
Observe the failure with PHPCS 3.13.0+
The same file fixes correctly with PHPCS 3.12.2
PHPCS 3.13.0+: Fails with loop limit error, no fixes applied
PHPCS 3.12.2: Works correctly, all fixes applied.

Code sample

# many cases when I use the full namespace to create the class, like
$one = new \One\Class();
$two = new \Two\Class();
....
$array = [new \Array\Class(), [new \Array1\Class(), new \Array1\Class()]]
# class has ~100 issues like this, might be some cs issues like withspace, missed docblock, etc.

Custom ruleset

I have a lot of rules.

To reproduce

Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcs test.php ...
  3. See the error message displayed
PHPCS output here

Expected behavior

A clear and concise description of what you expected to happen.

Versions (please complete the following information)

Operating System (e.g., [Ubuntu 22.04.5 LTS)
PHP version (e.g., 7.2, 8.1)
PHP_CodeSniffer version (e.g., 3.13.0)
Standard (dfferent)
Install type (e.g. Composer local

Additional context

Add any other context about the problem here.

Please confirm

  • I have searched the issue list and am not opening a duplicate issue.
  • I have read the Contribution Guidelines and this is not a support question.
  • I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
  • I have verified the issue still exists in the 4.x branch of PHP_CodeSniffer.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions