JustBlackBird / gulp-phpcs

Gulp plugin for running PHP Code Sniffer
MIT License
47 stars 12 forks source link

File Reporter not Working when fail reporter triggers. #27

Closed di5abled closed 7 years ago

di5abled commented 7 years ago

It would be ideal when the code bellow writes the file with the errors and fail afterwards. This way you could open the file and check for your errors or give the file to another person etc.

At the moment the task fails but no errors are written to given path in the file reporter.

return gulp.src('**/*.php')
    .pipe(plugin.phpcs({...}))
    .pipe(plugin.phpcs.reporter('file', {path: '...'}))
    .pipe(plugin.phpcs.reporter('fail'));
JustBlackBird commented 7 years ago

Sorry, I cannot reproduce the problem. Here is my gulp file:

var gulp = require('gulp');
var phpcs = require('gulp-phpcs');

gulp.task('default', function () {
    return gulp.src(['src/**/*.php'])
        .pipe(phpcs({
            bin: 'vendor/bin/phpcs',
            standard: 'PSR2',
            warningSeverity: 0
        }))
        .pipe(phpcs.reporter('file', {path: './foo.log'}))
        .pipe(phpcs.reporter('fail'));
});

and it works fine.

Does file reporter work in your case without fail reporter after it?

di5abled commented 7 years ago

Hy,

yes, when I remove the fail reporter the file reporter works and writes the file. Can it be that the fail reporter fails on the first wrong file and stops the task?

I'm currently testing Gulp v4, maybe this could be a problem?

The error I get is:

Message:
    PHP Code Sniffer failed on /Users/.../Projects/.../....php
Details:
    domainEmitter: [object Object]
    domain: [object Object]
    domainThrown: false
JustBlackBird commented 7 years ago

Can it be that the fail reporter fails on the first wrong file and stops the task?

I think it could be the reason. Fail reporter (and all other reporters) works with files pipe so once the first "bad" file goes through the pipe, the fail reporter emits error to pipe. I think we could add an option to fail reporter to die after all files went through the pipe.

I'm currently testing Gulp v4, maybe this could be a problem?

As for Gulp v4 I did not test it yet, so I cannot say if the plugin works with it or not.

JustBlackBird commented 7 years ago

Fixed with #28

If it does not feel free to reopen the issue.