Skip to content
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

Errors not displayed for phpmd #1142

Closed
esniper opened this issue Mar 20, 2017 · 14 comments
Closed

Errors not displayed for phpmd #1142

esniper opened this issue Mar 20, 2017 · 14 comments

Comments

@esniper
Copy link

esniper commented Mar 20, 2017

Neomake configuration in nvim:

" Neomake - replacement for sytastic
let g:neomake_php_phpcs_extra_args = '--standard=~/phpcs/ruleset.xml'
let g:neomake_php_phpmd_maker = {
    \ 'args': ['%:p', 'text', '~/phpmd/ruleset.xml'],
    \ 'append_file' : 0,
    \ 'errorformat': '%W%f:%l%\s%\s%#%m',
    \ }
let g:neomake_verbose = 3
" let g:neomake_php_enabled_makers = ['php', 'phpmd', 'phpcs']
let g:neomake_php_enabled_makers = ['php', 'phpmd']

Expected behavior

There is one error in the file that I'm running Neomake on. But the error doesn't get displayed in either the status line or airline.

Note: phpcs works as expected.

Steps to reproduce

  1. use the above configuration
  2. run :Neomake in a php file with phpmd errors.

Output from (verbose) NeomakeInfo

Output from :messages:

Neomake [     ]: Not processing output for mode t
"includes/apis/internal/reviews/LocalReviews.php" 1051L, 39449C
Neomake [+6.54]: [1] Running makers: php, phpmd
Neomake [     ]: [1] Starting async job: ['php', '-l', '-d', 'display_errors=1', '-d', 'log_errors=0', '-d', 'xdebug.cli_color=0', 'somefile.php']
Neomake [     ]: [1] Starting async job: ['phpmd', 'somefile.php', 'text', '~/phpmd/ruleset.xml']
Neomake [+0.79]: [1.4] stdout: php: ['No syntax errors detected in somefile.php', '']
Neomake [     ]: [1.5] stdout: phpmd: ['somefile.php^I-^IUnexpected token: ..., line: 894, col: 66, file:somefile.php.', '']
Neomake [     ]: [1.4] exit: php: 0
Neomake [     ]: [1.4] php: processing 1 lines of output.
Neomake [     ]: [1.4] php: completed with exit code 0.
Neomake [     ]: [1.4] Cleaning jobinfo
Neomake [     ]: Skipping User autocmd NeomakeJobFinished: no hooks.
Neomake [     ]: [1.5] exit: phpmd: 0
Neomake [     ]: [1.5] phpmd: processing 1 lines of output.
Neomake [     ]: Skipping User autocmd NeomakeCountsChanged: no hooks.
Neomake [     ]: [1.5] phpmd: completed with exit code 0.
Neomake [     ]: [1.5] Cleaning jobinfo
Neomake [     ]: Skipping User autocmd NeomakeJobFinished: no hooks.
Neomake [     ]: File-level errors cleaned in buffer 1
Neomake [     ]: Skipping User autocmd NeomakeFinished: no hooks.

As you can see above, there is an error in somefile.php. however, none of this gets displayed.

@blueyed
Copy link
Member

blueyed commented Mar 20, 2017

Looks like the output does not match the errorformat ('%W%f:%l%\s%\s%#%m').
Can you provide the output from phpmd on that file? (or some other samples)

@blueyed
Copy link
Member

blueyed commented Mar 20, 2017

/cc @codeinabox

@codeinabox
Copy link
Contributor

If you could create a PHP file that recreates that error I could update the tests.

@blueyed
Copy link
Member

blueyed commented Mar 20, 2017

The output from the issue, but not sure how much it's edited (^I being Tab probably):

somefile.php^I-^IUnexpected token: ..., line: 894, col: 66, file:somefile.php.

@codeinabox
Copy link
Contributor

I've experienced unexpected token errors in the past but I am having trouble recreating one as all the past examples have been fixed in recent versions. @esniper are you using a recent version of phpmd?

@esniper
Copy link
Author

esniper commented Mar 20, 2017

I'm using phpmd version 2.5.0 (which is one older than the latest)

The below code for instance causes an error:

<?php

function test($a, $b) {
    error_log("$a -> $b");
}

$x = [1, 2];

test(...$x);

On line #8, the ... is a PHP 7.0 operator.

The error I get if I run the phpmd on command line is:
/src/myprojects/website/test.php - Unexpected token: ..., line: 9, col: 6, file: /src/myprojects/website/test.php.

As @blueyed mentioned I think I have the wrong errorfomat.

@codeinabox
Copy link
Contributor

Ahhh, I've got version 2.6.0 which doesn't give a token error.

@blueyed
Copy link
Member

blueyed commented Mar 20, 2017

Has the errorformat changed between those versions, too?
Seems to be quite different..

@blueyed
Copy link
Member

blueyed commented Mar 20, 2017

@esniper
The errorformat is configured on the maker, so it would be Neomake having it wrong.
Or is it customized on your side?
Then Neomake should use an expected one by itself probably.

@blueyed
Copy link
Member

blueyed commented Mar 20, 2017

The "unexpected token" error also depends on the PHP version you're using probably?!

@codeinabox
Copy link
Contributor

Not quite. PHP mess detector uses PDepend, which needs to be updated when new language features are introduced for example phpmd/phpmd#347

@esniper
Copy link
Author

esniper commented Mar 21, 2017

From the issue linked, it looks like the merge happened for version 2.5.1. Which means that 2.5.0 (Which I'm using) still can't handle PHP 7.0.

However, I'm still curious as to why the error message (regardless of the root cause of the error) doesn't get processed.

@blueyed
Copy link
Member

blueyed commented Mar 24, 2017

@esniper
Do other errors match the errorformat ('%W%f:%l%\s%\s%#%m') after all?

It would really help to have some examples here.

Maybe it's just an issue that the old version (or phpmd in general) uses an inconsistent error format?

FWIW, Syntastic uses '%E%f:%l%\s%#%m' - which also does not match /src/myprojects/website/test.php - Unexpected token: ..., line: 9, col: 6, file: /src/myprojects/website/test.php..

I think it's an issue with phpmd, and you should file it there - after verifying it with the latest version.

@blueyed
Copy link
Member

blueyed commented Jun 17, 2017

Closing this due to missing feedback - and assuming it might be fixed by updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants