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

str_repeat() on Reports/Source.php:201

Open GaryJones opened this issue 9 years ago • 0 comments

When running a source report, as part of grunt phpcs, I'm getting the report generated at https://gist.github.com/GaryJones/156f24e88c71ab453937

Warning: str_repeat(): Second argument has to be greater than or equal to 0 in .../phpcs/CodeSniffer/Reports/Source.php on line 201

This appears to happen with multiple (but not all) sniffs from WordPress, Squiz and Generic standards, all in use by the WordPress standard.

It only happens with Source reports. Full, Summary and Info reports are all fine. If I run phpcs directly, not with grunt, then the errors do not appear.

phpcs: 2.3.4 grunt-phpcs: 0.4.0 grunt: 0.4.5

Here's my phpcs.xml:

<?xml version="1.0"?>
<ruleset name="Gary Jones">
    <description>The code standard for Gamajo theme.</description>
    <file>theme/.</file>
    <arg name="extensions" value="php"/>
    <arg name="report-full" value="logs/phpcs-full.log"/>
    <arg name="report-summary" value="logs/phpcs-summary.log"/>
    <arg name="report-source" value="logs/phpcs-source.log"/>
    <arg name="report-info" value="logs/phpcs-info.log"/>
    <arg value="sp"/>
    <exclude-pattern>vendor/.</exclude-pattern>
    <rule ref="WordPress.XSS.EscapeOutput">
        <properties>
            <property type="array" name="customAutoEscapedFunctions" value="genesis_attr"/>
        </properties>
    </rule>
    <rule ref="WordPress">
        <exclude name="WordPress.VIP"/>
        <!--<exclude name="WordPress.Files.FileName.UnderscoresNotAllowed"/>-->
    </rule>
</ruleset>

Using load-grunt-config, my phpcs.js is:

module.exports = {
    options: {
        // Assumes 'phpcs' is accessible in the global system.
        // If not, set 'bin: /path/to/bin/phpcs'
        // ignoreExitCode: true,
        standard: 'phpcs.xml'
    },
    src: [
        '<%= paths.theme %>**/*.php'
        ]
    }
};

It also happened with:

module.exports = {
    options: {
        // Assumes 'phpcs' is accessible in the global system.
        // If not, set 'bin: /path/to/bin/phpcs'
        // ignoreExitCode: true,
        standard: 'phpcs.xml'
    },
    full: {
        options: {
            reportFile: '<%= paths.logs %>phpcs-full.log'
        },
        src: [
            '<%= paths.theme %>**/*.php'
        ]
    }
};

(The reason for the shorter phpcs.js is so that it triggers the call to phpcs, but uses phpcs.xml for the configuration. This may warrant a new ticket for this functionality.)

GaryJones avatar Sep 07 '15 08:09 GaryJones