-
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
Proposal: treat deprecations/notices/warnings coming from sniffs in a more end-user friendly manner #3844
Comments
jrfnl
added a commit
to jrfnl/slevomat-coding-standard
that referenced
this issue
Sep 28, 2023
The config as it was, was hiding 6 `Undefined array key`/`Trying to access array offset on null` notices. As any notice caused by a sniff will stop a PHPCS scan of a file dead, these should be discovered when running the tests and then fixed. Better yet: the tests should fail on them. This change in the configuration makes it so. Note: this does mean you now have a bug to fix. Also see: squizlabs/PHP_CodeSniffer#3844
jrfnl
added a commit
to jrfnl/slevomat-coding-standard
that referenced
this issue
Oct 3, 2023
The config as it was, was hiding 6 `Undefined array key`/`Trying to access array offset on null` notices. As any notice caused by a sniff will stop a PHPCS scan of a file dead, these should be discovered when running the tests and then fixed. Better yet: the tests should fail on them. This change in the configuration makes it so. Note: this does mean you now have a bug to fix. Also see: squizlabs/PHP_CodeSniffer#3844
kukulich
pushed a commit
to slevomat/coding-standard
that referenced
this issue
Oct 4, 2023
The config as it was, was hiding 6 `Undefined array key`/`Trying to access array offset on null` notices. As any notice caused by a sniff will stop a PHPCS scan of a file dead, these should be discovered when running the tests and then fixed. Better yet: the tests should fail on them. This change in the configuration makes it so. Note: this does mean you now have a bug to fix. Also see: squizlabs/PHP_CodeSniffer#3844
kukulich
pushed a commit
to slevomat/coding-standard
that referenced
this issue
Oct 4, 2023
The config as it was, was hiding 6 `Undefined array key`/`Trying to access array offset on null` notices. As any notice caused by a sniff will stop a PHPCS scan of a file dead, these should be discovered when running the tests and then fixed. Better yet: the tests should fail on them. This change in the configuration makes it so. Note: this does mean you now have a bug to fix. Also see: squizlabs/PHP_CodeSniffer#3844
Related #2871 |
Closing as replaced by PHPCSStandards/PHP_CodeSniffer#30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current situation
As things currently are, when a PHP deprecation/notice/warning/error is received during the scanning of a file, PHPCS turns this into an
Internal.Exception
and kills the scan of that particular file.Example 1:
Internal.exception
on line 1 of the file.Example 2:
Internal.exception
on line 1 of the file.The problem
While it is important for sniff authors to have access to this information (to allow them to fix the sniff), this is not user-friendly for end-users who cannot do anything with that information, other than report it to the relevant standard and in the mean time, their code is not fully scanned.
So... I'm wondering if we cannot find a way to make this more user-friendly for end-users, while still keeping the information available for sniff authors.
Important caveat: while the scan results for the "rest of the file" will be fine for PHP deprecations/notices/warnings caused by a logic oversight in the sniff or a change in PHP, if the file being scanned contains a parse error, chances are high that the scan results for the "rest of the file" are unreliable (at best) or even complete nonsense (at worst).
Proposal
I haven't thought this through completely yet, but these are some thoughts I have around this which I'm sharing to receive feedback on them.
Rough outline of proposal:
1
if any were seen (same as before as previously theInternal.Exception
would cause an exit code of1
).-v
and exit with1
if any were seen (same as before).--ignore-php-notices
(or something along those lines) to allow the exit code to be0
if there were deprecations/notices/warnings.1
, but will exit with0
instead. Replace the--ignore-php-notices
CLI argument with a--fail-on-php-notices
CLI argument to still get a1
exit code when there are notices.We also may need to make some accommodation in the test framework to allow test runs to still always report those deprecations/notices/warnings and fail a test run if any are encountered.
Thoughts ?
The text was updated successfully, but these errors were encountered: