Skip to content

[BUG] LineLengthSniff RegEx misses long lines with Phrase/__ keyword in string #75

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

Closed
mzeis opened this issue Mar 24, 2019 · 1 comment · Fixed by #127
Closed

[BUG] LineLengthSniff RegEx misses long lines with Phrase/__ keyword in string #75

mzeis opened this issue Mar 24, 2019 · 1 comment · Fixed by #127
Assignees
Labels
accepted New rule is accepted bug Something isn't working

Comments

@mzeis
Copy link
Contributor

mzeis commented Mar 24, 2019

Preconditions

  1. Use fix from #6: Fix line length sniff when using translations #74 (original implementation of the sniff is broken)

Steps to reproduce

  1. in Magento2/Tests/Files/LineLengthUnitTest.inc, add this line:

    $test = "If a string exceeds 120 characters and a part of the string is Phrase('xy'), this would not be caught by the regular expression because it matches any line containing Phrase('xy') or __('xy').";
    
  2. Run vendor/bin/phpunit

Expected result

  1. An error as the line contains no translation but only the keywords "Phrase" and "__" inside a string, e.g.

    PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
    
    ..........F....................                                   31 / 31 (100%)
    
    Time: 441 ms, Memory: 14.00MB
    
    There was 1 failure:
    
    1) Magento2\Tests\Files\LineLengthUnitTest::testSniff
    [LINE 32] Expected 0 error(s) in LineLengthUnitTest.inc but found 1 error(s). The error(s) found were:
     -> Line exceeds maximum limit of 120 characters; contains 202 characters (Magento2.Files.LineLength.MaxExceeded)
    
    /home/matthias/PhpstormProjects/magento-coding-standard/vendor/squizlabs/php_codesniffer/tests/Standards/AbstractSniffUnitTest.php:205
    
    FAILURES!
    Tests: 31, Assertions: 0, Failures: 1.
    

Actual result

  1. The long string is missed:

    PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
    
    ...............................                                   31 / 31 (100%)
    
    Time: 519 ms, Memory: 14.00MB
    
    OK (31 tests, 0 assertions)
    
@mzeis mzeis added the bug Something isn't working label Mar 24, 2019
@lenaorobei lenaorobei added the accepted New rule is accepted label Apr 18, 2019
@konarshankar07
Copy link
Contributor

Hello @lenaorobei
Can I have this assigned to me please?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted New rule is accepted bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants