-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Failures in child processes are not handled by the runner #2142
Comments
A RuntimeException being thrown would end the run if you were not running with the parallel option as well, so you shouldn't expect a clean shutdown or valid report in this case. The real error here is the T_CLASS missing the scope_closer. But in my testing, PHPCS tokenizes the sample code and finds the scope_closer correctly. I don't have time to debug this to see if there is a problem with the custom sniff, but I'd look there first to see what's going on. |
You might also want to try running phpcbf with the |
@gsherwood how do you store the tokens produced from a given file? IIRC, there was an issue where PHPCS had different logic in debug mode. |
I'm not sure what you mean, and I'm not sure what different logic you are referring to. |
How can I produce a list of PHPCS tokens from a file to share it or see if there's the needed attribute? When debugging the custom sniff, I can see that there's no closer in the token.
I'm referring to #903 (comment). |
That's just the ScopeIndent sniff running in debug mode. You aren't using that special debug flag for it, so that's not going to be the issue.
Try running |
@gsherwood here's the interesting fragment from the output of
By the beginning of the loop 2, the closing |
This is true but the output should be the same in both parallel and non-parallel modes. Currently, there's one error in non-parallel mode, and two errors in parallel. This is confusing and requies additional debugging to find the real issue. |
I'm not going to silence the error complaining about childOutput being missing. If I did, I'd possibly not be reporting an error when something else goes wrong with the child process, and it may silently fail but look to succeed. I am going to look into the array sniff and fix it up. |
I didn't mean the errors should be suppressed. What I meant is that the runner should account for the fact the children may fail and not produce any additional unhandled errors. For instance, it could show the available part of the report and additionally say that processes X, Y and Z failed, therefore the report may be incomplete. It also could suggest running the same report without parallel execution. With this approach, once a child process fails, a developer could focus on the error from the child and not debug the error in the runner. |
Sorry, understand you now. |
… a line new after a here/nowdoc (ref #2142)
I've fixed the array sniff issue that was causing the error. I'll leave this open as an improvement to child process handling. Thanks for helping me figure this one out. |
@gsherwood, thank you for helping figure out the root cause. |
Hey @gsherwood, unfortunately, the Rules<?xml version="1.0"?>
<ruleset name="Error">
<rule ref="Squiz.Arrays.ArrayDeclaration"/>
</ruleset> Code<?php
$a = [
"foo",
<<<HEREDOC
HEREDOC
]; "Fixed" Code<?php
$a = [
"foo",
<<<HEREDOC
HEREDOC, // <-- note the ","
]; Debug
|
I have the same issue with slevomat/coding-standard. First, I was thinking an issue with the standard itself: slevomat/coding-standard#644 But according to @kukulich, the class token should always have Here is the log output:
Hope it helps. |
@soullivaneuh your file is using PHP 7.3 nowdoc syntax (the closing identifier When I try running PHPCS over your file with the slevomat coding standard using PHP 7.3, I have no problems. If I try with PHP 7.1, I get the same error you are seeing. Are you using an older PHP version to check this newer code? |
@morozov I suspect this might be the same issue for you as well |
@gsherwood the issue I reported originally is only reproducible with PHP < 7.3 (e.g. 7.2.16) and only with PHP_CodeSniffer 3.3 (not 3.4). However, as you can see in my example, the closing heredoc identifier ( |
Yep, different issue. So is this original issue now resolved? |
Yes, it is. |
This happens for <?php
$a = [
'a' =>
]; |
Thanks for reporting, but this is a completely unrelated issue. I'm going to look into it, but I'm also going to close this issue so it doesn't keep becoming a thread for a range of different issues. If anyone here is having additional problems, please open a new issue in this repo so it can be tracked properly. |
Unfortunately, I don't know how to reproduce this issue with the OOTB standards, but here's the minimal required setup:
The run results in the following error:
This error happens in the child process outside of the PHP_CodeSniffer codebase because the
T_CLASS
token doesn't have thescope_closer
attribute defined.This error happens in PHP_CodeSniffer itself. The parent creates an empty shared file before running the child:
PHP_CodeSniffer/src/Runner.php
Line 418 in 4725c01
but the child dies before writing its contents due to the error above. However, the parent only checks if the file exists:
PHP_CodeSniffer/src/Runner.php
Line 677 in 4725c01
Besides the bug in the runner, is the fact that a
T_CLASS
token doesn't havescope_closer
also a bug?The text was updated successfully, but these errors were encountered: