joonty / vim-phpqa

PHP QA tools for Vim
http://www.joncairns.com
MIT License
290 stars 32 forks source link

Commands on demand not working #15

Closed tarciozemel closed 9 years ago

tarciozemel commented 10 years ago

Hi! This is a great plugin, thank you for share!

I'm testing somethings with vim-phpqa and, so far, almost everything is OK, except commands on demand aren't working.

So, if I have a syntax/phpcs problem, the Errors window appears and show me things when a save the file. However, when I try to run :Php or :Phpcs, nothing happens!

I'm using Ubuntu 13.04 with Vim 7.4 building from source.

joonty commented 10 years ago

Sounds odd. When you run :Php or :Phpcs, are you sure that the current buffer has php syntax errors or codesniffer errors accordingly? I thought this wasn't working for me, until I realised that the errors I was looking at were actually mess detector errors (marked with a M> sign), which are created by running :Phpmd.

Thanks!

tarciozemel commented 10 years ago

I'm sure! I purposely delete a bracket to test. When I try :Php, nothing happens; when I save, the Errors window appears...

joonty commented 10 years ago

Ah ok.

Has the buffer been saved when you run :Php? It takes the file, not the current buffer contents, which could be misleading really.

Thanks

tarciozemel commented 10 years ago

No, the buffer isn't saved when I run it. Sadly, when I say "nothing happens", nothing happens at all! The cursor simply returns to the line I was before I start to typing :...

tarciozemel commented 10 years ago

I just figured out: I can run :Phpcs!

At least for me, this is getting more awkward, since all php, phpcs and phpmd commands are already in my $PATH, as stated in PHPQA instructions... I've even tried to add let g:phpqa_php_cmd = '/usr/bin/php' for tests, but neither worked.

But this behaviour may be a clue to help me with this problem. :-)

joonty commented 10 years ago

Hi @tarciozemel,

:Phpcs, :Php and :Phpmd will not work as expected if run on an unsaved buffer. They run on the file, not on the buffer contents. You would need to save the file first before running :Php or any of the other commands.

I hope that makes sense.

Thanks

tarciozemel commented 10 years ago

Hi, again, @joonty!

I just tried to run :Phpcs in a unsaved buffer and it normally runs (I didn't specifid any namespace in the test file and the Errors windows spot me that).

Also I already tried to run :Phpmd in a saved buffer and nothing happens. Besides, if :Php it's suposed to execute only in saved buffers and PHPQA run it automaticaly when a buffer is saved, the command would be useless...

Anyways, I think the fact I can run :Phpcs it's not a clue at all... =/

joonty commented 10 years ago

@tarciozemel you can turn off the automatic running of the tools, so the extra commands were a way of giving the user the option to run it manually.

The commands will run, but they would use the file as it was at the last save.

When you say that nothing happened with :Phpmd, were there definitely mess detector errors in the file?

tarciozemel commented 10 years ago

Yeah, I have a function with 6 parameters in the file and the Code Size Rules ruleset it's supposed to pointing this kind of thing.

In my .vimrc I have: let g:phpqa_messdetector_ruleset = "cleancode,codesize,design,unusedcode". Maybe this is not the right way to specify what rulesets I want to use (but even so, this don't explain why :Php also it's not working).

joonty commented 9 years ago

My bad on this: it's been so long that I think this issue is probably redundant, due to the number of changes. Hopefully the latest version won't have this problem.