minimalize modification

This commit is contained in:
Pélisset Vincent 2017-12-14 12:43:28 +01:00 committed by Dmitry Khomutov
parent e8d043fdfd
commit 8bfdea3073
No known key found for this signature in database
GPG key ID: EC19426474B37AAC

View file

@ -40,9 +40,24 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
*/
protected $searches;
/**
* @var array - lines of . and X to visualize errors
*/
protected $errorPerFile = [];
/**
* @var int
*/
protected $currentLineSize = 0;
/**
* @var int
*/
protected $lineNumber = 0;
/**
* @var int
*/
protected $numberOfAnalysedFile = 0;
/**
@ -53,7 +68,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
return 'technical_debt';
}
/**
* Store the statu of the file :
* Store the status of the file :
* . : checked no errors
* X : checked with one or more errr
*
@ -217,12 +232,14 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
if (!$ignored) {
$handle = fopen($filePath, "r");
$lineNumber = 1;
$found=false;
$errorInFile=false;
while (false === feof($handle)) {
$line = fgets($handle);
foreach ($this->searches as $search) {
if ($technicalDeptLine = trim(strstr($line, $search))) {
$fileName = str_replace($this->directory, '', $filePath);
$this->build->reportError(
$this->builder,
'technical_debt',
@ -231,14 +248,16 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
$fileName,
$lineNumber
);
$found=true;
$errorInFile=true;
$errorCount++;
}
}
$lineNumber++;
}
fclose ($handle);
if ($found === true) {
if ($errorInFile === true) {
$this->buildLogString('X');
} else {
$this->buildLogString('.');