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

fail reporter fails on Warnings

Open tdmalone opened this issue 6 years ago • 1 comments

I'm running the log reporter followed by the fail reporter, and unexpectedly, the fail reporter is failing on warnings:

[10:08:03] PHP Code Sniffer found a problem in C:\Users\Tim\Dropbox\Chromatix\htdocs\base\theme-portal\inc\portal-setup.php

    FILE: ...\Dropbox\Chromatix\htdocs\base\theme-portal\inc\portal-setup.php
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------
      10 | WARNING | Inline comments must start with a capital letter
         |         | (Squiz.Commenting.InlineComment.NotCapital)
    ----------------------------------------------------------------------

    Time: 817ms; Memory: 10Mb

C:\Users\Tim\Dropbox\Chromatix\htdocs\base\gulp-tasks\node_modules\longjohn\dist\longjohn.js:192
        throw e;
        ^
Error: PHP Code Sniffer failed on
    C:\Users\Tim\Dropbox\Chromatix\htdocs\base\theme-portal\inc\portal-setup.php

I'm not sure if this is intended behaviour or not. I'm assuming it's not - but if it is, would it be possible to have an optional flag to only fail on errors?

tdmalone avatar Nov 22 '17 23:11 tdmalone

Sorry, in digging into this further I've realised it's not an issue with gulp-phpcs - at least not directly anyway. phpcs itself exits with 1 by default on warnings.

There's a command line flag to change that, if possible it would be fantastic if gulp-phpcs could provide a mechanism to pass that through? Ideally we could manually pass through any args not specifically passed in this function.

(Note that the warning-severity option determines whether to display warnings or not, but doesn't allow warnings to still be displayed while ignoring the exit code).

Meantime I might also enquire of phpcs whether it's possible to set this option in the phpcs.xml.

EDIT: This can sort of be worked around by running vendor/bin/phpcs --config-set ignore_warnings_on_exit 1 in composer's post-install-cmd (ideally though it'd be great to be able to pass arbitrary command line options through to phpcs so we can configure this in the gulpfile) - BUT, this will also cause the gulp-phpcs log reporter to not report the warnings visibly at all.

EDIT 2: I imagine this check in gulp-phpcs is the cause of a non-error warning not being output.

tdmalone avatar Nov 23 '17 00:11 tdmalone