SublimeLinter / SublimeLinter-php

SublimeLinter 3 plugin for PHP, using php -l.
MIT License
209 stars 29 forks source link

Process PHP with 100% CPU usage #12

Closed kokokurak closed 8 years ago

kokokurak commented 9 years ago

I'm on OS X Yosemite. From time to time, for me like about every hour, SublimeLinter-php is starting PHP task with 100% CPU usage. It never stops, unless I stop the task manually. I didn't know what starts that task, but found out that the issue is gone when I disable SublimeLinter-php.

sormy commented 9 years ago

The problem is actually in phpcs. If we will implement workaround on the level of linter to prevent running phpcs when phpcs -l returns errors, then it will completely resolve this and any future releated issues. phpcs hangs but php -l is not and we could use that for workaround.

kokokurak commented 9 years ago

@sormy You are right. When I disable SublimeLinter-phpcs, the problem with foreach doesn't occur.

sormy commented 9 years ago

Actually, I posted this bug on phpcs and they already fixed that, but I think they have more bugs like that =) Actually I found two in a couple days =) I don't know what will be more efficient - to report each bug into phpcs or just implement workaround to prevent phpcs to run on files with bad syntax.

akrabat commented 9 years ago

Personally, I would rather not see phpcs errors in Sublime Text while the code is invalid.

sormy commented 9 years ago

Personally, I'm too.

groteworld commented 9 years ago

@sormy Great work bringing this to a replicable state

the best fix for SublimeLinter-php is to do not try to lint via phpcs/phpmd or something else if file is not valid based on php -l result

I don't think the "fix" is in SL-php but in SL-phpcs instead.

I would rather not see phpcs errors in Sublime Text while the code is invalid.

We'd want to at least show that phpcs is not running because of errors. An error placed on the first character of the file with text stating so.

akrabat commented 9 years ago

We'd want to at least show that phpcs is not running because of errors. An error placed on the first character of the file with text stating so

That would be nice.

sormy commented 9 years ago

So actually, last question is: "Will somebody find a time to make phpcs linter be used only if php linter was succeeded?" =)

ghost commented 9 years ago

Or: "Will PHP-CodeSniffer be fixed so that it doesn't hang and roast one's CPU when passed invalid code?"

sormy commented 9 years ago

Aedx in that case we need all to monitor when phpcs will hang, make dumps and send them to phpcs developers. I think they have a lot of bugs like this because they are primarily focused on linting of valid php code.

ghost commented 9 years ago

@sormy Alternatively, we could just edit phpcs' tokeniser slightly, so that it would return an error if incorrect syntax is found. What I think may be happening, is that the tokeniser is checking through, finds the start of a token, but cannot find the end of the token by the end of the input stream. As is such, phpcs simply hangs, as the tokeniser does not have any defined behaviour when the end of a stream is reached before the end of a token is reached.

sormy commented 9 years ago

yes, may be "convert all warnings and notices into exceptions" on phpcs level will help

kokokurak commented 9 years ago

Any progress on this issue?

sormy commented 9 years ago

kokokurak, try last phpcs

sormy commented 9 years ago

last phpcs 3.0 still hangs

kokokurak commented 9 years ago

Any updates?

ghost commented 9 years ago

@kokokurak Are you sure this only occurs with SL-php as opposed to SL-phpcs? If it is actually SL-phpcs, it would probably be wise to post an issue to that project, referencing this issue.

sormy commented 9 years ago

From my side it's only phpcs problem and I'm not sure that they will be able to fix it. phpcs is very unstable for wrong php syntax.

ajmichels commented 8 years ago

This isn't actually a bug with this linter package. I am going to create a new issue in the SublimeLinter/SublimeLinter-phpcs repo for introducing some sort of catch for the known issue within the phpcs linter itself. The real solution it seems is for the phpcs project to resolve this issue.