Skip to content

Commit

Permalink
Use modified LineLength check
Browse files Browse the repository at this point in the history
Ignore when main reason for too long line is long translatable message.
  • Loading branch information
nijel committed Apr 27, 2012
1 parent a7c63e6 commit fecb3c1
Showing 2 changed files with 14 additions and 5 deletions.
18 changes: 13 additions & 5 deletions PMAStandard/Sniffs/Files/LineLengthSniff.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Generic_Sniffs_Files_LineLengthSniff.
* PMAStandard_Sniffs_Files_LineLengthSniff.
*
* PHP version 5
*
@@ -14,7 +14,7 @@
*/

/**
* Generic_Sniffs_Files_LineLengthSniff.
* PMAStandard_Sniffs_Files_LineLengthSniff.
*
* Checks all lines in the file, and throws warnings if they are over 80
* characters in length and errors if they are over 100. Both these
@@ -29,15 +29,15 @@
* @version Release: 1.3.3
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
class Generic_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff
class PMAStandard_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff
{

/**
* The limit that the length of a line should not exceed.
*
* @var int
*/
public $lineLimit = 80;
public $lineLimit = 85;

/**
* The limit that the length of a line must not exceed.
@@ -46,7 +46,7 @@ class Generic_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff
*
* @var int
*/
public $absoluteLineLimit = 100;
public $absoluteLineLimit = 0;


/**
@@ -124,6 +124,14 @@ protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $
return;
}

if (preg_match('|__\("[^"]{40,999}"\)|', $lineContent) !== 0) {
return;
}

if (preg_match("|__\('[^']{40,999}'\)|", $lineContent) !== 0) {
return;
}

if (PHP_CODESNIFFER_ENCODING !== 'iso-8859-1') {
// Not using the detault encoding, so take a bit more care.
$lineLength = iconv_strlen($lineContent, PHP_CODESNIFFER_ENCODING);
1 change: 1 addition & 0 deletions PMAStandard/ruleset.xml
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
<exclude name="PEAR.Commenting.ClassComment" />
<exclude name="PEAR.Commenting.FunctionComment" />
<exclude name="PEAR.Commenting.InlineComment" />
<exclude name="Generic.Files.LineLength" />
</rule>
</ruleset>

0 comments on commit fecb3c1

Please sign in to comment.