phpro / grumphp

A PHP code-quality tool
MIT License
4.15k stars 431 forks source link

Is it planning to realize feature to check lines witch was changed only? #361

Closed benbor closed 7 years ago

benbor commented 7 years ago
Q A
New feature? yes
Question? yes

Is it planning to realize feature to check lines witch was changed only? For all external tasks?

veewee commented 7 years ago

Hello @benbor,

Sadly, I do not understand your question. Can you try to rephrase your question? Thanks!

jyggen commented 7 years ago

As far as I understand he wants GrumPHP to fail only if it's due to one of the changed lines, so just because the file you edit have some CodeSniffer errors you'll still be able to commit your unrelated, CodeSniffer-approved change in that file.

Personally I think it's near impossible to do something like that, especially for all external tasks. Some tools do report the failing line, so it could be possible to filter on that, but I can imagine the line number not always being exact for multi-line definitions, function calls, arrays etc.

veewee commented 7 years ago

Indeed, that is not possible: Since we are using external CLI tools, it mostly is only possible to run on file base. For some tasks this is possible, but they are already implemented this way.

benbor commented 7 years ago

@jyggen Yes, i meant it. And yes, you're right again, the line number not always being exact for multi-line definitions. But for some projects (very awful legacy projects) with huge files it will be silver bullet.

@veewee From my point of view, we can do it.
If external CLI tool return line numbers of fails ( for example CodeSniffer) we can parse output and after that found intersections. Of course it's will work for external CLI only which return needed data.

veewee commented 7 years ago

@benbor, It is possible to write your own formatter for almost every task. This way you can fetch the process result message and do whatever you want with it. It isn't documented at the moment, but there are some examples available: https://github.com/phpro/grumphp/tree/master/src/Formatter