vim-phpcs icon indicating copy to clipboard operation
vim-phpcs copied to clipboard

ErrorFormat not Taking

Open eethann opened this issue 13 years ago • 7 comments
trafficstars

I don't have a lot to go on here, but the short of it is that the errorformat setting is not taking across files. Results from CodeSniff are not being parsed correctly, and appear like

|| "/mnt/sda9/echoditto/greenstreets/sites/greenstreets/index.php",24,1,error,"Break statement indented incorrectly; expected 6 spaces, found 0",DrupalCodingStandard.

until I run the command

set errorformat+="%f",%l,%c,%t%[a-zA-Z],"%m",%[a-zA-Z0-9_.-],%*[0-9]

from the vim command prompt, in each file.

I tried copying that command into .vimrc as a quickfix, with no luck. I've seen with both PEAR and DrupalCodingStandard standards.

Any ideas what might be going on here and how to fix? Perhaps something around the scoping of that setting for particular filetypes?

eethann avatar Dec 14 '11 16:12 eethann

One additional thought: I am using Syntastic. I'll look into whether that might be the culprit.

eethann avatar Dec 14 '11 16:12 eethann

What version of PHP CodeSniffer are you using? It looks like you are running an older version (based on the error), can you try using:

set errorformat+="%f",%l,%c,%t%[a-zA-Z],"%m",%[a-zA-Z0-9_.-]

instead, and let me know if this works?

If it does not, can you run: phpcs --standard={YOUR STANDARD] --report=csv [ANY FILE] | head -n 2

Paste in the output, please? I am thinking that vim could have stripped the ending of the error and there might be something I am missing.

bpearson avatar Dec 14 '11 22:12 bpearson

When I run the set errorformat from the vim command prompt, CodeSniff works from then on for that file. The command has to be re-run for each file, unforuntately. I tried adding to the end of my .vimrc, but no luck. I also just tried disabling Syntastic, to see if it was the culprit, but again no luck.

PHP_CodeSniffer 1.3.2 stable is installed, just installed via Pear a few days ago.

Command-line output of phpcs with CSV report is:

File,Line,Column,Type,Message,Source,Severity
"/home/ethan/projects/drupal/freegeoip/code/end7_geoip/end7_geoip.module",3,1,error,"The second line in the file doc comment must be \" * @file\"",DrupalCodingStandard.Commenting.FileComment,5

As an additional note, it is worth noting that Syntastic now supports PHPCS as well, so there is a bit of a collision here. There are some things I like better about this modules implementation, namely the use of the QuickFix buffer.

eethann avatar Dec 15 '11 06:12 eethann

Does any other plugin set errorformat? Can you list the ones that do? (eg. grep -Rns 'set errorformat' ~/.vim* )

It doesn't look like the version of codesniffer or the error line at this point, but I will keep looking.

bpearson avatar Dec 15 '11 09:12 bpearson

Update: I have tried this plugin under Syntastic and Pathogen but I can still not replicate any problems.

bpearson avatar Feb 12 '12 08:02 bpearson

Closing since I cannot replicate this issue, I think it most likely caused by a conflicting plugin or an old version of PHPCS, but unsure how to fix if I cannot replicate. Feel free to lodge a new issue with replication steps if this is still a problem.

bpearson avatar Apr 17 '14 08:04 bpearson

Actually I can replicate (somewhat intermittently) this issue, but I can make it go away is by running PHPCS on the command line. No clue what the problem is, it appears to be something wrong with the command line but not sure.

bpearson avatar Jul 22 '14 01:07 bpearson