Skip to content

Move LineLength from ruleset to sniff (fixes #36) #50

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

Merged
merged 2 commits into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Magento/Sniffs/Files/LineLengthSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ class LineLengthSniff extends FilesLineLengthSniff
*/
protected $previousLineContent = '';

/**
* @inheritdoc
*/
public $lineLimit = 120;

/**
* @inheritdoc
*/
public $absoluteLineLimit = 120;

/**
* @inheritdoc
*/
Expand Down
16 changes: 16 additions & 0 deletions Magento/Tests/Files/LineLengthUnitTest.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

// allowed
$shortString = 'This is a short line';

// triggers an error
$tooLongString = 'This is a pretty long line. The code sniffer will report an error if a single line exceeds the maximum character count. You have need to insert a line break to avoid this error.';

// allowed
$longStringBrokenUp = 'This is a pretty long line. The code sniffer would report an error if this was written as a ' .
'single line. You have to insert a line break to avoid this error.';

// allowed by Magento Standard (Generic ruleset would trigger warning / error)
$test = '012344567890123445678901234456789012344567890123445678901234456789';
$test1 = '01234456789012344567890123445678901234456789012344567890123445678901234456789';
$test2 = '012344567890123445678901234456789012344567890123445678901234456789012344567890123445678901234456789';
32 changes: 32 additions & 0 deletions Magento/Tests/Files/LineLengthUnitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Copyright © Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Tests\Files;

use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;

/**
* Class LineLengthUnitTest
*/
class LineLengthUnitTest extends AbstractSniffUnitTest
{
/**
* @inheritdoc
*/
public function getErrorList()
{
return [
7 => 1
];
}

/**
* @inheritdoc
*/
public function getWarningList()
{
return [];
}
}
4 changes: 0 additions & 4 deletions Magento/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@
<type>warning</type>
</rule>
<rule ref="Magento.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
<property name="absoluteLineLimit" value="120"/>
</properties>
<severity>8</severity>
<type>warning</type>
</rule>
Expand Down