ObliviousHarmony / vscode-php-codesniffer

A VS Code extension for integrating PHP_CodeSniffer.
https://marketplace.visualstudio.com/items?itemName=obliviousharmony.vscode-php-codesniffer
Other
38 stars 2 forks source link

Parser Failure Causes Exceptions #25

Closed ObliviousHarmony closed 3 years ago

ObliviousHarmony commented 3 years ago

Description

There seems to be an error that I'm assuming is caused by a failed parse or tokenization.

[2021-4-4 20:2548]: Fatal error: Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: Undefined index:  in /Users/christopherallford/.vscode/extensions/obliviousharmony.vscode-php-codesniffer-1.1.0/dist/phpcs-reports/includes/VSCodeFile.php on line 111 in /Users/christopherallford/Repositories/Automattic/GitHubHealth/vendor/squizlabs/php_codesniffer/src/Runner.php:606
Stack trace:
#0 /Users/christopherallford/.vscode/extensions/obliviousharmony.vscode-php-codesniffer-1.1.0/dist/phpcs-reports/includes/VSCodeFile.php(111): PHP_CodeSniffer\Runner->handleErrors(8, 'Undefined index...', '/Users/christop...', 111, Array)
#1 /Users/christopherallford/.vscode/extensions/obliviousharmony.vscode-php-codesniffer-1.1.0/dist/phpcs-reports/Diagnostic.php(34): VSCode\PHP_CodeSniffer\VSCodeFile->getToken(NULL)
#2 /Users/christopherallford/.vscode/extensions/obliviousharmony.vscode-php-codesniffer-1.1.0/dist/phpcs-reports/includes/VSCodeReport.php(39): VSCode\PHP_CodeSniffer\Reports\Diagnostic->executeReport(Array, Object(VSCode\PHP_CodeSniffer\VSCodeFile), in /Users/christopherallford/Repositories/Automattic/GitHubHealth/vendor/squizlabs/php_codesniffer/src/Runner.php on line 606

Reproduction Steps

  1. Start creating a new PHP file and use a broken require_once as you type.
  2. Note the errors spamming the output log.

Expected Behavior

There should be no errors.

ObliviousHarmony commented 3 years ago

It also looks like diagnostic failures like this may break the parser for a file. Does the error handling not clear the cancellation token or active status or something?