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

validate:phpcs:files fails to find additional violations after an initial violation is found #1855

Closed
bobbygryzynger opened this issue Jul 30, 2017 · 1 comment
Assignees
Labels
Bug Something isn't working

Comments

@bobbygryzynger
Copy link
Contributor

bobbygryzynger commented Jul 30, 2017

My system information:

  • Operating system type: macOS
  • Operating system version: 10.12.5
  • BLT version: 8.9.0

I'm seeing some odd behavior with the validate:phpcs:files task when I attempt to run the command iteratively as part of a Robo watch task. The behavior can essentially be boiled down to this: when the validate:phpcs:files task is run successively and an error is encountered, all subsequent calls to the task fail to turn up violations when violations exist.

To reproduce:

  1. Create a couple of dummy modules with code style violations:
    docroot/modules/custom/one/one.php:
<?php

docroot/modules/custom/two/two.php:

<?php
  1. Create a command that will sniff each of these files successively:
    blt/src/Commands/CustomCommand.php:
 /**
 * @command test:phpcs:files
 */
public function testPhpcsFilesTask() {

  for ($i = 0; $i < 10; $i++) {

    try {
      $this->invokeCommand('validate:phpcs:files', ['file_list' => 'docroot/modules/custom/one/one.php']);
    } catch (\Exception $exception) {
      // Do nothing.
    }

    try {
      $this->invokeCommand('validate:phpcs:files', ['file_list' => 'docroot/modules/custom/two/two.php']);
    } catch (\Exception $exception) {
      // Do nothing.
    }

  }
}

When I run this command:

blt test:phpcs:files

I get the following output:

$ blt test:phpcs:files
> validate:phpcs:files
Sniffing files...
[File\Write] Writing to /Users/<user>/Sites/<project>/tmp/phpcs-fileset.
[ExecStack] '/Users/<user>/Sites/<project>/vendor/bin/phpcs' --file-list='/Users/<user>/Sites/<project>/tmp/phpcs-fileset' --standard='/Users/<user>/Sites/<project>/vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml'

FILE: ...ers/<user>/Sites/<project>/docroot/modules/custom/one/one.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 1 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 43ms; Memory: 6.5Mb

[ExecStack]  Exit code 1 
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...
> validate:phpcs:files
Sniffing files...

And I expected that code violations would continue to be found during each call to validate:phpcs:files.

@grasmash grasmash added the Bug Something isn't working label Jul 31, 2017
grasmash added a commit to grasmash/bolt that referenced this issue Jul 31, 2017
…ations after an initial violation is found.
@grasmash grasmash self-assigned this Jul 31, 2017
@bobbygryzynger
Copy link
Contributor Author

@grasmash I applied cdd5e8a but am still seeing this issue occur using the same steps above. A brief bit of debugging was revealing that the files being sniffed were (inexplicably) missing from the fileset when sniffing failed to be executed. Can this issue be reopened?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants