Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task PHPMDTask and PhpCodeSnifferTask enables writing of last-modifie…
…d times to cachefile, to speed up processing of files that rarely change.
- Loading branch information
Showing
7 changed files
with
430 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
classes/phing/tasks/ext/phpcs/Reports_PhingRemoveFromCache.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
/** | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* This software consists of voluntary contributions made by many individuals | ||
* and is licensed under the LGPL. For more information please see | ||
* <http://phing.info>. | ||
*/ | ||
|
||
/** | ||
* Remove from cache files where contains errors | ||
* | ||
* @category PHP | ||
* @package PHP_CodeSniffer | ||
* @author Rui Filipe Da Cunha Alves <ruifil@ruifil.com> | ||
*/ | ||
class PHP_CodeSniffer_Reports_PhingRemoveFromCache implements PHP_CodeSniffer_Report | ||
{ | ||
/** | ||
* Cache data storage | ||
* @var DataStore | ||
*/ | ||
protected static $cache; | ||
|
||
/** | ||
* Set cache object | ||
* | ||
* @param DataStore $cache | ||
*/ | ||
public static function setCache($cache) | ||
{ | ||
self::$cache = $cache; | ||
} | ||
|
||
/** | ||
* Remove file from cache if contains errors | ||
* | ||
* @param array $report Prepared report data. | ||
* @param PHP_CodeSniffer_File $phpcsFile The file being reported on. | ||
* @param boolean $showSources Show sources? | ||
* @param int $width Maximum allowed line width. | ||
* | ||
* @return boolean | ||
*/ | ||
public function generateFileReport( | ||
$report, | ||
PHP_CodeSniffer_File $phpcsFile, | ||
$showSources = false, | ||
$width = 80 | ||
) { | ||
if (!self::$cache || ($report['errors'] === 0 && $report['warnings'] === 0)) { | ||
// Nothing to do | ||
return false; | ||
} | ||
|
||
self::$cache->remove($report['filename']); | ||
return false; | ||
} | ||
|
||
|
||
/** | ||
* Do nothing | ||
* | ||
* @param string $cachedData Any partial report data that was returned from | ||
* generateFileReport during the run. | ||
* @param int $totalFiles Total number of files processed during the run. | ||
* @param int $totalErrors Total number of errors found during the run. | ||
* @param int $totalWarnings Total number of warnings found during the run. | ||
* @param int $totalFixable Total number of problems that can be fixed. | ||
* @param boolean $showSources Show sources? | ||
* @param int $width Maximum allowed line width. | ||
* @param boolean $toScreen Is the report being printed to screen? | ||
* | ||
* @return void | ||
*/ | ||
public function generate( | ||
$cachedData, | ||
$totalFiles, | ||
$totalErrors, | ||
$totalWarnings, | ||
$totalFixable, | ||
$showSources = false, | ||
$width = 80, | ||
$toScreen = true | ||
) { | ||
// Do nothing | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
classes/phing/tasks/ext/phpmd/PHPMDRendererRemoveFromCache.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
/** | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* This software consists of voluntary contributions made by many individuals | ||
* and is licensed under the LGPL. For more information please see | ||
* <http://phing.info>. | ||
*/ | ||
|
||
require_once 'phing/util/DataStore.php'; | ||
|
||
use PHPMD\AbstractRenderer; | ||
use PHPMD\Report; | ||
|
||
/** | ||
* This class will remove files with violations from cache | ||
* | ||
* @category PHP | ||
* @package PHPMD | ||
* @author Rui Filipe Da Cunha Alves <ruifil@ruifil.com> | ||
*/ | ||
class PHPMDRendererRemoveFromCache extends AbstractRenderer | ||
{ | ||
/** | ||
* Cache data storage | ||
* @var DataStore | ||
*/ | ||
protected $cache; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param DataStore $cache | ||
*/ | ||
public function __construct($cache) | ||
{ | ||
$this->cache = $cache; | ||
} | ||
|
||
/** | ||
* This method will be called when the engine has finished the source | ||
* analysis phase. To remove file with violations from cache. | ||
* | ||
* @param Report $report | ||
* @return void | ||
*/ | ||
public function renderReport(Report $report) | ||
{ | ||
foreach ($report->getRuleViolations() as $violation) { | ||
$fileName = $violation->getFileName(); | ||
$this->cache->remove($fileName, null); | ||
} | ||
} | ||
} |
Oops, something went wrong.