question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The phpcs report contains invalid json

See original GitHub issue

I’m getting this error in the vscode notification interface. "phpcs: The phpcs report contains invalid json. Please review "Diagnosing Common Errors" in the plugin README"

It just appeared recently, I also recently upgraded vscode (10.20.1) but it was working even after that, not sure why it just popped up.

I went to the README file and saw this:

Diagnosing common errors

The phpcs report contains invalid json

This error occurs when something goes wrong in phpcs execution such as PHP Notices, PHP Fatal Exceptions, Other Script Output, etc, most of which can be detected as follows: Execute the phpcs command in your terminal with --report=json and see whether the output contains anything other than valid json.

NOTE: The ‘-q’ parameter is automatically passed on phpcs v.2.6.2 and above to suppress such errors. Please update phpcs to a version >=2.6.2.

I have the latest phpcs

$ phpcs --version
PHP_CodeSniffer version 3.2.3 (stable) by Squiz (http://www.squiz.net) 

I tested the output of phpcs with a json linter and it returned no errors phpcs --report=json index.php >output.json

I am not certain what else I can do from here. Can someone please help me with an idea on how to fix this?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
gregsullivancommented, Mar 12, 2018

I encountered this issue and tracked it down to my global version of phpcs being incompatible with the Drupal standards:

https://www.drupal.org/node/2809335

(Coder requires phpcs version >=2.7.0, ❤️.0. I had the most recent version installed. Downgrading to 2.9.x solved the problem.)

2reactions
frazrascommented, Feb 28, 2018

@ikappas I am using the Drupal coding standard. Here are my settings:

{
   "editor.tabSize": 2,
   "editor.renderWhitespace": "boundary",
   "files.trimTrailingWhitespace": true,
   "files.autoSave": "afterDelay",
   "git.confirmSync": false,
   "phpcs.standard": "/home/frazras/.config/composer/vendor/drupal/coder/coder_sniffer/Drupal",
   "window.zoomLevel": 1,
   "git.autofetch": true,
   "window.menuBarVisibility": "default",
   "gitlens.gitExplorer.files.layout": "tree"
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

PHP CodeSniffer Error: The phpcs report contains invalid json
I want to add PHP CodeSniffer to VScode. Within VScode I am getting the error 'phpcs: The phpcs report contains invalid json'.
Read more >
The phpcs report contains invalid json. - Bountysource
phpcs: The phpcs report contains invalid json. Please review "Diagnosing Common Errors" in the plugin README.
Read more >
Php Codesniffer Error: The Phpcs Report Contains ... - ADocLib
This error as described in the readme means that the output of the phpcs command is not valid json.This can happen when additional...
Read more >
phpcs - Visual Studio Marketplace
The phpcs report contains invalid json. This error occurs when something goes wrong in phpcs execution such as PHP Notices, PHP Fatal ...
Read more >
PHP CodeSniffer Error: The phpcs report contains invalid json
Answer a question I want to add PHP CodeSniffer to VScode. Within VScode I am getting the error 'phpcs: The phpcs report contains...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found