ikappas / vscode-phpcs

PHP CodeSniffer for Visual Studio Code
MIT License
128 stars 56 forks source link

can not show error message #132

Closed elricli closed 4 years ago

elricli commented 5 years ago

In vs code, phpcs cannot show error message.

VS Code About

Version: 1.28.2
Commit: 7f3ce96ff4729c91352ae6def877e59c561f4850
Date: 2018-10-17T00:20:56.183Z
Electron: 2.0.9
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64

php version And phpcs version

image

app.php

<?php

function a()
{
    return '11';

}//end a()
echo(a());

In Terminal image

In VS Code image

Output

[Trace - 10:43:02 AM] Sending notification '$/setTraceNotification'.
Params: {
    "value": "verbose"
}

[Trace - 10:43:02 AM] Sending notification 'workspace/didChangeConfiguration'.
Params: {
    "settings": null
}

[Trace - 10:43:02 AM] Received request 'workspace/configuration - (3)'.
Params: {
    "items": [
        {
            "scopeUri": "file:///home/ayden/Project/php/mvc-demo/app.php"
        }
    ]
}

[Trace - 10:43:02 AM] Sending response 'workspace/configuration - (3)'. Processing request took 1ms
Result: [
    {
        "enable": true,
        "workspaceRoot": "/home/ayden/Project/php/mvc-demo",
        "executablePath": "/usr/local/bin/phpcs",
        "composerJsonPath": "composer.json",
        "standard": null,
        "autoConfigSearch": true,
        "showSources": true,
        "showWarnings": true,
        "ignorePatterns": [],
        "warningSeverity": 5,
        "errorSeverity": 5
    }
]

[Trace - 10:43:02 AM] Received notification 'textDocument/didStartValidate'.
Params: {
    "textDocument": {
        "uri": "file:///home/ayden/Project/php/mvc-demo/app.php"
    }
}

[Trace - 10:43:02 AM] Linting started on: file:///home/ayden/Project/php/mvc-demo/app.php
[Trace - 10:43:02 AM] Received notification 'textDocument/didEndValidate'.
Params: {
    "textDocument": {
        "uri": "file:///home/ayden/Project/php/mvc-demo/app.php"
    }
}

[Trace - 10:43:02 AM] Linting completed on: file:///home/ayden/Project/php/mvc-demo/app.php
[Trace - 10:43:02 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///home/ayden/Project/php/mvc-demo/app.php",
    "diagnostics": []
}

settings

{
    "phpcs.trace.server": "verbose",
    "phpcs.showSources": true
}
Blake-C commented 5 years ago

Looking at your screenshot, this might be similar to the issue I was having in: https://github.com/ikappas/vscode-phpcs/issues/128

If you have basepath in your phpcs.xml file, try removing it and see if that provides the expected output from the plugin: <arg name="basepath" value="./"/>

elricli commented 5 years ago

Looking at your screenshot, this might be similar to the issue I was having in:

128

If you have basepath in your phpcs.xml file try removing it and see if that provides the expected out put from the plugin: <arg name="basepath" value="./"/>

Thank you so much, I resolve it by remove <arg name="basepath" value="./"/>

josephfusco commented 5 years ago

Thank you @Blake-C - I had the same issue & that solved it!

rizkysyazuli commented 4 years ago

Not seeing any errors either. no <arg name="basepath" value="./"/> in my config. I used the example config from the WordPress Standards example.

I specifically instruct the extension to use the locally installed phpcs:

{
    "phpcs.executablePath": "./vendor/bin/phpcs",
    "phpcs.standard": "WordPress"
}

All the standards also seems to be installed:

$ ./vendor/bin/phpcs -i       
The installed coding standards are PEAR, Zend, PSR2, MySource, Squiz, PSR1, PSR12, PHPCompatibility, PHPCompatibility, PHPCompatibilityParagonieRandomCompat, PHPCompatibilityParagonieSodiumCompat, PHPCompatibilityWP, WordPress, WordPress-Extra, WordPress-Docs and WordPress-Core
shadyvb commented 4 years ago

~This helped fix the extension for me, didn't work at all before it: "phpcs.autoConfigSearch": false,~

Discard that, it was one of my included rulesets that also have the basepath arg as well 🤦‍♂