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

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

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 this to Backlog in Community Dashboard via automation Mar 25, 2019
@lenaorobei lenaorobei moved this from Backlog to Up for grabs in Community Dashboard Mar 25, 2019
@lenaorobei lenaorobei added the accepted New rule is accepted label Apr 18, 2019
@okorshenko okorshenko added this to Ready for Grooming in Backlog Jun 12, 2019
@lenaorobei lenaorobei moved this from Ready for Grooming to Ready for Development in Backlog Jun 12, 2019
@konarshankar07
Copy link
Contributor

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

@m2-community-project m2-community-project bot moved this from Ready for Development to Dev In Progress in Backlog Aug 10, 2019
@m2-community-project m2-community-project bot moved this from Dev In Progress to Pull Request In Progress in Backlog Aug 11, 2019
lenaorobei added a commit to konarshankar07/magento-coding-standard that referenced this issue Aug 16, 2019
@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Done in Backlog Aug 16, 2019
magento-devops-reposync-svc pushed a commit that referenced this issue Sep 28, 2021
…oding-standard-286

[Imported] Increased version to 11
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
Backlog
  
Done
Community Dashboard
  
Up for grabs
Development

Successfully merging a pull request may close this issue.

3 participants