Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slevomat/coding-standard dependency should be at least 7.1.0 (instead of 7.0.19) #4

Open
aadmathijssen opened this issue Nov 23, 2023 · 0 comments

Comments

@aadmathijssen
Copy link
Collaborator

Currently the slevomat/coding-standard package dependency allows installation of versions 7.0.19 or higher.

However, as of version 7.1.0 the default behavior of the SlevomatCodingStandard.Functions.FunctionLength sniff has changed such that comments and whitespace are not counted as part of the function length.

From the Slevomat Coding Standard release notes of version 7.1.0:

SlevomatCodingStandard.Functions.FunctionLength: New options includeComments and includeWhitespace

See for example the following code:

<?php

function notTooLong(): void
{
    echo '1';
    echo '2';
    echo '3';
    echo '4';
    echo '5';
    echo '6';
    echo '7';
    echo '8';
    echo '9';
    echo '10';
    //comment
    echo '11';
    echo '12';
    echo '13';
    echo '14';
    echo '15';
    echo '16';
    echo '17';
    echo '18';
    echo '19';
    echo '20';

    echo '21';
    echo '22';
    echo '23';
    echo '24';
    echo '25';
}

This reports a violation of the SlevomatCodingStandard.Functions.FunctionLength for versions of the slevomat/coding-standard package prior to 7.1.0:

$ composer require --dev slevomat/coding-standard:7.0.19
$ vendor/bin/phpcs --sniffs=SlevomatCodingStandard.Functions.FunctionLength file.php

FILE: /path/to/file.php
----------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------------------------
 3 | ERROR | Your function is too long. Currently using 27 lines. Can be up to 25 lines.
   |       | (SlevomatCodingStandard.Functions.FunctionLength.FunctionLength)
----------------------------------------------------------------------------------------------------------------------------------------------------------

To resolve this, the minimum version of the slevomat/coding-standard package should be increased to at least 7.1.0.

@aadmathijssen aadmathijssen changed the title slevomat/coding-standard dependency should be at least 7.1.0 (instead of 7.0.19) slevomat/coding-standard dependency should be at least 7.1.0 (instead of 7.0.19) Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant