Skip to content

Commit c287499

Browse files
authored
Merge pull request #50 from magento/36-LineLength-FixLimit
Move LineLength from ruleset to sniff (fixes #36)
2 parents 6f2428b + 9149ddd commit c287499

File tree

4 files changed

+58
-4
lines changed

4 files changed

+58
-4
lines changed

Magento/Sniffs/Files/LineLengthSniff.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ class LineLengthSniff extends FilesLineLengthSniff
1919
*/
2020
protected $previousLineContent = '';
2121

22+
/**
23+
* @inheritdoc
24+
*/
25+
public $lineLimit = 120;
26+
27+
/**
28+
* @inheritdoc
29+
*/
30+
public $absoluteLineLimit = 120;
31+
2232
/**
2333
* @inheritdoc
2434
*/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
// allowed
4+
$shortString = 'This is a short line';
5+
6+
// triggers an error
7+
$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.';
8+
9+
// allowed
10+
$longStringBrokenUp = 'This is a pretty long line. The code sniffer would report an error if this was written as a ' .
11+
'single line. You have to insert a line break to avoid this error.';
12+
13+
// allowed by Magento Standard (Generic ruleset would trigger warning / error)
14+
$test = '012344567890123445678901234456789012344567890123445678901234456789';
15+
$test1 = '01234456789012344567890123445678901234456789012344567890123445678901234456789';
16+
$test2 = '012344567890123445678901234456789012344567890123445678901234456789012344567890123445678901234456789';
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Tests\Files;
7+
8+
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
9+
10+
/**
11+
* Class LineLengthUnitTest
12+
*/
13+
class LineLengthUnitTest extends AbstractSniffUnitTest
14+
{
15+
/**
16+
* @inheritdoc
17+
*/
18+
public function getErrorList()
19+
{
20+
return [
21+
7 => 1
22+
];
23+
}
24+
25+
/**
26+
* @inheritdoc
27+
*/
28+
public function getWarningList()
29+
{
30+
return [];
31+
}
32+
}

Magento/ruleset.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@
118118
<type>warning</type>
119119
</rule>
120120
<rule ref="Magento.Files.LineLength">
121-
<properties>
122-
<property name="lineLimit" value="120"/>
123-
<property name="absoluteLineLimit" value="120"/>
124-
</properties>
125121
<severity>8</severity>
126122
<type>warning</type>
127123
</rule>

0 commit comments

Comments
 (0)