You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2008/06/06 16:56:03 UTC
svn commit: r663970 [19/25] - in /incubator/shindig/trunk/php: ./ test/
test/PHPUnit/ test/PHPUnit/Extensions/ test/PHPUnit/Extensions/Database/
test/PHPUnit/Extensions/Database/Constraint/
test/PHPUnit/Extensions/Database/DB/ test/PHPUnit/Extensions/D...
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/JSON.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/JSON.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/JSON.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/JSON.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,295 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: JSON.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.0.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+require_once '../PHPUnit/Util/Printer.php';
+require_once '../PHPUnit/Util/Test.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * A TestListener that generates JSON messages.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.0.0
+ */
+class PHPUnit_Util_Log_JSON extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener
+{
+ /**
+ * @var string
+ * @access protected
+ */
+ protected $currentTestSuiteName = '';
+
+ /**
+ * @var string
+ * @access protected
+ */
+ protected $currentTestName = '';
+
+ /**
+ * @var boolean
+ * @access private
+ */
+ protected $currentTestPass = TRUE;
+
+ /**
+ * An error occurred.
+ *
+ * @param PHPUnit_Framework_Test $test
+ * @param Exception $e
+ * @param float $time
+ * @access public
+ */
+ public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
+ {
+ $this->writeCase(
+ 'error',
+ $time,
+ PHPUnit_Util_Filter::getFilteredStacktrace(
+ $e,
+ TRUE,
+ FALSE
+ ),
+ $e->getMessage()
+ );
+
+ $this->currentTestPass = FALSE;
+ }
+
+ /**
+ * A failure occurred.
+ *
+ * @param PHPUnit_Framework_Test $test
+ * @param PHPUnit_Framework_AssertionFailedError $e
+ * @param float $time
+ * @access public
+ */
+ public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
+ {
+ $this->writeCase(
+ 'fail',
+ $time,
+ PHPUnit_Util_Filter::getFilteredStacktrace(
+ $e,
+ TRUE,
+ FALSE
+ ),
+ $e->getMessage()
+ );
+
+ $this->currentTestPass = FALSE;
+ }
+
+ /**
+ * Incomplete test.
+ *
+ * @param PHPUnit_Framework_Test $test
+ * @param Exception $e
+ * @param float $time
+ * @access public
+ */
+ public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
+ {
+ $this->writeCase('error', $time, array(), 'Incomplete Test');
+
+ $this->currentTestPass = FALSE;
+ }
+
+ /**
+ * Skipped test.
+ *
+ * @param PHPUnit_Framework_Test $test
+ * @param Exception $e
+ * @param float $time
+ * @access public
+ */
+ public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
+ {
+ $this->writeCase('error', $time, array(), 'Skipped Test');
+
+ $this->currentTestPass = FALSE;
+ }
+
+ /**
+ * A testsuite started.
+ *
+ * @param PHPUnit_Framework_TestSuite $suite
+ * @access public
+ */
+ public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
+ {
+ $this->currentTestSuiteName = $suite->getName();
+ $this->currentTestName = '';
+
+ $message = array(
+ 'event' => 'suiteStart',
+ 'suite' => $this->currentTestSuiteName,
+ 'tests' => count($suite)
+ );
+
+ $this->write($this->encode($message));
+ }
+
+ /**
+ * A testsuite ended.
+ *
+ * @param PHPUnit_Framework_TestSuite $suite
+ * @access public
+ */
+ public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
+ {
+ $this->currentTestSuiteName = '';
+ $this->currentTestName = '';
+ }
+
+ /**
+ * A test started.
+ *
+ * @param PHPUnit_Framework_Test $test
+ * @access public
+ */
+ public function startTest(PHPUnit_Framework_Test $test)
+ {
+ $this->currentTestName = PHPUnit_Util_Test::describe($test);
+ $this->currentTestPass = TRUE;
+ }
+
+ /**
+ * A test ended.
+ *
+ * @param PHPUnit_Framework_Test $test
+ * @param float $time
+ * @access public
+ */
+ public function endTest(PHPUnit_Framework_Test $test, $time)
+ {
+ if ($this->currentTestPass) {
+ $this->writeCase('pass', $time);
+ }
+ }
+
+ /**
+ * @param string $status
+ * @param float $time
+ * @param array $trace
+ * @param string $message
+ * @access protected
+ */
+ protected function writeCase($status, $time, array $trace = array(), $message = '')
+ {
+ $message = array(
+ 'event' => 'test',
+ 'suite' => $this->currentTestSuiteName,
+ 'test' => $this->currentTestName,
+ 'status' => $status,
+ 'time' => $time,
+ 'trace' => $trace,
+ 'message' => $message
+ );
+
+ $this->write($this->encode($message));
+ }
+
+ /**
+ * @param array $message
+ * @return string
+ * @access protected
+ */
+ protected function encode($message)
+ {
+ if (function_exists('json_encode')) {
+ return json_encode($message);
+ }
+
+ $first = TRUE;
+ $result = '';
+
+ if (is_scalar($message)) {
+ $message = array ($message);
+ }
+
+ foreach ($message as $key => $value) {
+ if (!$first) {
+ $result .= ',';
+ } else {
+ $first = FALSE;
+ }
+
+ $result .= sprintf('"%s":', $this->escape($key));
+
+ if (is_array($value) || is_object($value)) {
+ $result .= sprintf('%s', $this->encode($value));
+ } else {
+ $result .= sprintf('"%s"', $this->escape($value));
+ }
+ }
+
+ return '{' . $result . '}';
+ }
+
+ /**
+ * @param string $value
+ * @return string
+ * @access protected
+ */
+ protected function escape($value)
+ {
+ return str_replace(
+ array("\\", "\"", "/", "\b", "\f", "\n", "\r", "\t"),
+ array('\\\\', '\"', '\/', '\b', '\f', '\n', '\r', '\t'),
+ $value
+ );
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/Metrics.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/Metrics.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/Metrics.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/Metrics.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,184 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: Metrics.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Runner/Version.php';
+require_once '../PHPUnit/Util/Metrics/Project.php';
+require_once '../PHPUnit/Util/Class.php';
+require_once '../PHPUnit/Util/CodeCoverage.php';
+require_once '../PHPUnit/Util/Filter.php';
+require_once '../PHPUnit/Util/Printer.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Generates an XML logfile with software metrics information.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Util_Log_Metrics extends PHPUnit_Util_Printer
+{
+ /**
+ * @param PHPUnit_Framework_TestResult $result
+ * @access public
+ */
+ public function process(PHPUnit_Framework_TestResult $result)
+ {
+ $codeCoverage = $result->getCodeCoverageInformation();
+ $summary = PHPUnit_Util_CodeCoverage::getSummary($codeCoverage);
+ $files = array_keys($summary);
+ $projectMetrics = new PHPUnit_Util_Metrics_Project($files, $summary);
+
+ $document = new DOMDocument('1.0', 'UTF-8');
+ $document->formatOutput = TRUE;
+
+ $metrics = $document->createElement('metrics');
+ $metrics->setAttribute('files', count($projectMetrics->getFiles()));
+ $metrics->setAttribute('functions', count($projectMetrics->getFunctions()));
+ $metrics->setAttribute('cls', $projectMetrics->getCLS());
+ $metrics->setAttribute('clsa', $projectMetrics->getCLSa());
+ $metrics->setAttribute('clsc', $projectMetrics->getCLSc());
+ $metrics->setAttribute('roots', $projectMetrics->getRoots());
+ $metrics->setAttribute('leafs', $projectMetrics->getLeafs());
+ $metrics->setAttribute('interfs', $projectMetrics->getInterfs());
+ $metrics->setAttribute('maxdit', $projectMetrics->getMaxDit());
+
+ $document->appendChild($metrics);
+
+ foreach ($projectMetrics->getFiles() as $fileName => $fileMetrics) {
+ $xmlFile = $metrics->appendChild(
+ $document->createElement('file')
+ );
+
+ $xmlFile->setAttribute('name', $fileName);
+ $xmlFile->setAttribute('classes', count($fileMetrics->getClasses()));
+ $xmlFile->setAttribute('functions', count($fileMetrics->getFunctions()));
+ $xmlFile->setAttribute('loc', $fileMetrics->getLoc());
+ $xmlFile->setAttribute('cloc', $fileMetrics->getCloc());
+ $xmlFile->setAttribute('ncloc', $fileMetrics->getNcloc());
+ $xmlFile->setAttribute('locExecutable', $fileMetrics->getLocExecutable());
+ $xmlFile->setAttribute('locExecuted', $fileMetrics->getLocExecuted());
+ $xmlFile->setAttribute('coverage', sprintf('%F', $fileMetrics->getCoverage()));
+
+ foreach ($fileMetrics->getClasses() as $className => $classMetrics) {
+ if (!$classMetrics->getClass()->implementsInterface('PHPUnit_Framework_Test')) {
+ $xmlClass = $document->createElement('class');
+
+ $xmlClass->setAttribute('name', $classMetrics->getClass()->getName());
+ $xmlClass->setAttribute('loc', $classMetrics->getLoc());
+ $xmlClass->setAttribute('locExecutable', $classMetrics->getLocExecutable());
+ $xmlClass->setAttribute('locExecuted', $classMetrics->getLocExecuted());
+ $xmlClass->setAttribute('aif', sprintf('%F', $classMetrics->getAIF()));
+ $xmlClass->setAttribute('ahf', sprintf('%F', $classMetrics->getAHF()));
+ $xmlClass->setAttribute('ca', $classMetrics->getCa());
+ $xmlClass->setAttribute('ce', $classMetrics->getCe());
+ $xmlClass->setAttribute('csz', $classMetrics->getCSZ());
+ $xmlClass->setAttribute('cis', $classMetrics->getCIS());
+ $xmlClass->setAttribute('coverage', sprintf('%F', $classMetrics->getCoverage()));
+ $xmlClass->setAttribute('dit', $classMetrics->getDIT());
+ $xmlClass->setAttribute('i', sprintf('%F', $classMetrics->getI()));
+ $xmlClass->setAttribute('impl', $classMetrics->getIMPL());
+ $xmlClass->setAttribute('mif', sprintf('%F', $classMetrics->getMIF()));
+ $xmlClass->setAttribute('mhf', sprintf('%F', $classMetrics->getMHF()));
+ $xmlClass->setAttribute('noc', $classMetrics->getNOC());
+ $xmlClass->setAttribute('pf', sprintf('%F', $classMetrics->getPF()));
+ $xmlClass->setAttribute('vars', $classMetrics->getVARS());
+ $xmlClass->setAttribute('varsnp', $classMetrics->getVARSnp());
+ $xmlClass->setAttribute('varsi', $classMetrics->getVARSi());
+ $xmlClass->setAttribute('wmc', $classMetrics->getWMC());
+ $xmlClass->setAttribute('wmcnp', $classMetrics->getWMCnp());
+ $xmlClass->setAttribute('wmci', $classMetrics->getWMCi());
+
+ foreach ($classMetrics->getMethods() as $methodName => $methodMetrics) {
+ $xmlMethod = $xmlClass->appendChild(
+ $document->createElement('method')
+ );
+
+ $this->processFunctionOrMethod($methodMetrics, $xmlMethod);
+ }
+
+ $xmlFile->appendChild($xmlClass);
+ }
+ }
+
+ foreach ($fileMetrics->getFunctions() as $functionName => $functionMetrics) {
+ $xmlFunction = $xmlFile->appendChild(
+ $document->createElement('function')
+ );
+
+ $this->processFunctionOrMethod($functionMetrics, $xmlFunction);
+ }
+ }
+
+ $this->write($document->saveXML());
+ $this->flush();
+ }
+
+ /**
+ * @param PHPUnit_Util_Metrics_Function $metrics
+ * @param DOMElement $element
+ * @access protected
+ */
+ protected function processFunctionOrMethod($metrics, DOMElement $element)
+ {
+ $element->setAttribute('name', $metrics->getFunction()->getName());
+ $element->setAttribute('loc', $metrics->getLoc());
+ $element->setAttribute('locExecutable', $metrics->getLocExecutable());
+ $element->setAttribute('locExecuted', $metrics->getLocExecuted());
+ $element->setAttribute('coverage', sprintf('%F', $metrics->getCoverage()));
+ $element->setAttribute('ccn', $metrics->getCCN());
+ $element->setAttribute('crap', sprintf('%F', $metrics->getCrapIndex()));
+ $element->setAttribute('npath', $metrics->getNPath());
+ $element->setAttribute('parameters', $metrics->getParameters());
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PEAR.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PEAR.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PEAR.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PEAR.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,247 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: PEAR.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 2.3.0
+ */
+
+@include_once 'Log.php';
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * A TestListener that logs to a PEAR_Log sink.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 2.1.0
+ */
+class PHPUnit_Util_Log_PEAR implements PHPUnit_Framework_TestListener
+{
+ /**
+ * Log.
+ *
+ * @var Log
+ * @access protected
+ */
+ protected $log;
+
+ /**
+ * @param string $type The type of concrete Log subclass to use.
+ * Currently, valid values are 'console',
+ * 'syslog', 'sql', 'file', and 'mcal'.
+ * @param string $name The name of the actually log file, table, or
+ * other specific store to use. Defaults to an
+ * empty string, with which the subclass will
+ * attempt to do something intelligent.
+ * @param string $ident The identity reported to the log system.
+ * @param array $conf A hash containing any additional configuration
+ * information that a subclass might need.
+ * @param int $maxLevel Maximum priority level at which to log.
+ * @access public
+ */
+ public function __construct($type, $name = '', $ident = '', $conf = array(), $maxLevel = PEAR_LOG_DEBUG)
+ {
+ $this->log = Log::factory($type, $name, $ident, $conf, $maxLevel);
+ }
+
+ /**
+ * An error occurred.
+ *
+ * @param PHPUnit_Framework_Test $test
+ * @param Exception $e
+ * @param float $time
+ * @access public
+ */
+ public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
+ {
+ $this->log->crit(
+ sprintf(
+ 'Test "%s" failed: %s',
+
+ $test->getName(),
+ $e->getMessage()
+ )
+ );
+ }
+
+ /**
+ * A failure occurred.
+ *
+ * @param PHPUnit_Framework_Test $test
+ * @param PHPUnit_Framework_AssertionFailedError $e
+ * @param float $time
+ * @access public
+ */
+ public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
+ {
+ $this->log->err(
+ sprintf(
+ 'Test "%s" failed: %s',
+
+ $test->getName(),
+ $e->getMessage()
+ )
+ );
+ }
+
+ /**
+ * Incomplete test.
+ *
+ * @param PHPUnit_Framework_Test $test
+ * @param Exception $e
+ * @param float $time
+ * @access public
+ */
+ public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
+ {
+ $this->log->info(
+ sprintf(
+ 'Test "%s" incomplete: %s',
+
+ $test->getName(),
+ $e->getMessage()
+ )
+ );
+ }
+
+ /**
+ * Skipped test.
+ *
+ * @param PHPUnit_Framework_Test $test
+ * @param Exception $e
+ * @param float $time
+ * @access public
+ * @since Method available since Release 3.0.0
+ */
+ public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
+ {
+ $this->log->info(
+ sprintf(
+ 'Test "%s" skipped: %s',
+
+ $test->getName(),
+ $e->getMessage()
+ )
+ );
+ }
+
+ /**
+ * A test suite started.
+ *
+ * @param PHPUnit_Framework_TestSuite $suite
+ * @access public
+ * @since Method available since Release 2.2.0
+ */
+ public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
+ {
+ $this->log->info(
+ sprintf(
+ 'TestSuite "%s" started.',
+
+ $suite->getName()
+ )
+ );
+ }
+
+ /**
+ * A test suite ended.
+ *
+ * @param PHPUnit_Framework_TestSuite $suite
+ * @access public
+ * @since Method available since Release 2.2.0
+ */
+ public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
+ {
+ $this->log->info(
+ sprintf(
+ 'TestSuite "%s" ended.',
+
+ $suite->getName()
+ )
+ );
+ }
+
+ /**
+ * A test started.
+ *
+ * @param PHPUnit_Framework_Test $test
+ * @access public
+ */
+ public function startTest(PHPUnit_Framework_Test $test)
+ {
+ $this->log->info(
+ sprintf(
+ 'Test "%s" started.',
+
+ $test->getName()
+ )
+ );
+ }
+
+ /**
+ * A test ended.
+ *
+ * @param PHPUnit_Framework_Test $test
+ * @param float $time
+ * @access public
+ */
+ public function endTest(PHPUnit_Framework_Test $test, $time)
+ {
+ $this->log->info(
+ sprintf(
+ 'Test "%s" ended.',
+
+ $test->getName()
+ )
+ );
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,340 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: PMD.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Runner/Version.php';
+require_once '../PHPUnit/Util/Metrics/Project.php';
+require_once '../PHPUnit/Util/Log/PMD/Rule/Class.php';
+require_once '../PHPUnit/Util/Log/PMD/Rule/File.php';
+require_once '../PHPUnit/Util/Log/PMD/Rule/Function.php';
+require_once '../PHPUnit/Util/Log/PMD/Rule/Project.php';
+require_once '../PHPUnit/Util/Class.php';
+require_once '../PHPUnit/Util/CodeCoverage.php';
+require_once '../PHPUnit/Util/Filter.php';
+require_once '../PHPUnit/Util/FilterIterator.php';
+require_once '../PHPUnit/Util/Printer.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Generates an XML logfile with software metrics information using the
+ * PMD format "documented" at
+ * http://svn.atlassian.com/fisheye/browse/~raw,r=7084/public/contrib/bamboo/bamboo-pmd-plugin/trunk/src/test/resources/test-pmd-report.xml
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Util_Log_PMD extends PHPUnit_Util_Printer
+{
+ protected $added;
+
+ protected $rules = array(
+ 'project' => array(),
+ 'file' => array(),
+ 'class' => array(),
+ 'function' => array()
+ );
+
+ /**
+ * Constructor.
+ *
+ * @param mixed $out
+ * @param array $configuration
+ * @throws InvalidArgumentException
+ * @access public
+ */
+ public function __construct($out = NULL, array $configuration = array())
+ {
+ parent::__construct($out);
+ $this->loadClasses($configuration);
+ }
+
+ /**
+ * @param PHPUnit_Framework_TestResult $result
+ * @access public
+ */
+ public function process(PHPUnit_Framework_TestResult $result)
+ {
+ $codeCoverage = $result->getCodeCoverageInformation();
+ $summary = PHPUnit_Util_CodeCoverage::getSummary($codeCoverage);
+ $files = array_keys($summary);
+ $metrics = new PHPUnit_Util_Metrics_Project($files, $summary);
+
+ $document = new DOMDocument('1.0', 'UTF-8');
+ $document->formatOutput = TRUE;
+
+ $pmd = $document->createElement('pmd');
+ $pmd->setAttribute('version', 'PHPUnit ' . PHPUnit_Runner_Version::id());
+ $document->appendChild($pmd);
+
+ foreach ($this->rules['project'] as $ruleName => $rule) {
+ $result = $rule->apply($metrics);
+
+ if ($result !== NULL) {
+ $this->addViolation(
+ $result,
+ $pmd,
+ $rule
+ );
+ }
+ }
+
+ foreach ($metrics->getFiles() as $fileName => $fileMetrics) {
+ $xmlFile = $document->createElement('file');
+ $xmlFile->setAttribute('name', $fileName);
+
+ $this->added = FALSE;
+
+ foreach ($this->rules['file'] as $ruleName => $rule) {
+ $result = $rule->apply($fileMetrics);
+
+ if ($result !== NULL) {
+ $this->addViolation(
+ $result,
+ $xmlFile,
+ $rule
+ );
+
+ $this->added = TRUE;
+ }
+ }
+
+ foreach ($fileMetrics->getClasses() as $className => $classMetrics) {
+ if (!$classMetrics->getClass()->isInterface()) {
+ $classStartLine = $classMetrics->getClass()->getStartLine();
+ $classEndLine = $classMetrics->getClass()->getEndLine();
+ $classPackage = $classMetrics->getPackage();
+
+ foreach ($this->rules['class'] as $ruleName => $rule) {
+ $result = $rule->apply($classMetrics);
+
+ if ($result !== NULL) {
+ $this->addViolation(
+ $result,
+ $xmlFile,
+ $rule,
+ $classStartLine,
+ $classEndLine,
+ $classPackage,
+ $className
+ );
+
+ $this->added = TRUE;
+ }
+ }
+
+ foreach ($classMetrics->getMethods() as $methodName => $methodMetrics) {
+ if (!$methodMetrics->getMethod()->isAbstract()) {
+ $this->processFunctionOrMethod($xmlFile, $methodMetrics, $classPackage);
+ }
+ }
+ }
+ }
+
+ foreach ($fileMetrics->getFunctions() as $functionName => $functionMetrics) {
+ $this->processFunctionOrMethod($xmlFile, $functionMetrics);
+ }
+
+ if ($this->added) {
+ $pmd->appendChild($xmlFile);
+ }
+ }
+
+ $this->write($document->saveXML());
+ $this->flush();
+ }
+
+ /**
+ * @param string $violation
+ * @param DOMElement $element
+ * @param PHPUnit_Util_Log_PMD_Rule $rule
+ * @param integer $line
+ * @param integer $toLine
+ * @param string $package
+ * @param string $class
+ * @param string $method
+ * @access public
+ */
+ protected function addViolation($violation, DOMElement $element, PHPUnit_Util_Log_PMD_Rule $rule, $line = '', $toLine = '', $package = '', $class = '', $method = '', $function = '')
+ {
+ $violationXml = $element->appendChild(
+ $element->ownerDocument->createElement('violation', $violation)
+ );
+
+ $violationXml->setAttribute('rule', $rule->getName());
+ $violationXml->setAttribute('priority', $rule->getPriority());
+
+ if (!empty($line)) {
+ $violationXml->setAttribute('line', $line);
+ }
+
+ if (!empty($toLine)) {
+ $violationXml->setAttribute('to-line', $toLine);
+ }
+
+ if (empty($package)) {
+ $package = 'global';
+ }
+
+ if (!empty($package)) {
+ $violationXml->setAttribute('package', $package);
+ }
+
+ if (!empty($class)) {
+ $violationXml->setAttribute('class', $class);
+ }
+
+ if (!empty($method)) {
+ $violationXml->setAttribute('method', $method);
+ }
+
+ if (!empty($function)) {
+ $violationXml->setAttribute('function', $function);
+ }
+ }
+
+ protected function processFunctionOrMethod(DOMElement $element, $metrics, $package = '')
+ {
+ $scope = '';
+
+ if ($metrics->getFunction() instanceof ReflectionMethod) {
+ $scope = $metrics->getFunction()->getDeclaringClass()->getName();
+ }
+
+ $startLine = $metrics->getFunction()->getStartLine();
+ $endLine = $metrics->getFunction()->getEndLine();
+ $name = $metrics->getFunction()->getName();
+
+ foreach ($this->rules['function'] as $ruleName => $rule) {
+ $result = $rule->apply($metrics);
+
+ if ($result !== NULL) {
+ $this->addViolation(
+ $result,
+ $element,
+ $rule,
+ $startLine,
+ $endLine,
+ $package,
+ $scope,
+ $name
+ );
+
+ $this->added = TRUE;
+ }
+ }
+ }
+
+ protected function loadClasses(array $configuration)
+ {
+ $basedir = dirname(__FILE__) . DIRECTORY_SEPARATOR .
+ 'PMD' . DIRECTORY_SEPARATOR . 'Rule';
+
+ $dirs = array(
+ $basedir . DIRECTORY_SEPARATOR . 'Class',
+ $basedir . DIRECTORY_SEPARATOR . 'File',
+ $basedir . DIRECTORY_SEPARATOR . 'Function',
+ $basedir . DIRECTORY_SEPARATOR . 'Project'
+ );
+
+ foreach ($dirs as $dir) {
+ if (file_exists($dir)) {
+ $iterator = new PHPUnit_Util_FilterIterator(
+ new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator($dir)
+ ),
+ '.php'
+ );
+
+ foreach ($iterator as $file) {
+ include_once $file->getPathname();
+ }
+ }
+ }
+
+ $classes = get_declared_classes();
+
+ foreach ($classes as $className) {
+ $class = new ReflectionClass($className);
+
+ if (!$class->isAbstract() && $class->isSubclassOf('PHPUnit_Util_Log_PMD_Rule')) {
+ $rule = explode('_', $className);
+ $rule = $rule[count($rule)-1];
+
+ if (isset($configuration[$className])) {
+ $object = new $className(
+ $configuration[$className]['threshold'],
+ $configuration[$className]['priority']
+ );
+ } else {
+ $object = new $className;
+ }
+
+ if ($class->isSubclassOf('PHPUnit_Util_Log_PMD_Rule_Project')) {
+ $this->rules['project'][$rule] = $object;
+ }
+
+ if ($class->isSubclassOf('PHPUnit_Util_Log_PMD_Rule_File')) {
+ $this->rules['file'][$rule] = $object;
+ }
+
+ else if ($class->isSubclassOf('PHPUnit_Util_Log_PMD_Rule_Class')) {
+ $this->rules['class'][$rule] = $object;
+ }
+
+ else if ($class->isSubclassOf('PHPUnit_Util_Log_PMD_Rule_Function')) {
+ $this->rules['function'][$rule] = $object;
+ }
+ }
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,89 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: Rule.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Util/Metrics.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Abstract base class for PMD rule classes.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+abstract class PHPUnit_Util_Log_PMD_Rule
+{
+ protected $threshold;
+ protected $priority;
+
+ public function __construct($threshold, $priority = 1)
+ {
+ $this->threshold = $threshold;
+ $this->priority = $priority;
+ }
+
+ public function getName()
+ {
+ $name = explode('_', get_class($this));
+
+ return array_pop($name);
+ }
+
+ public function getPriority()
+ {
+ return $this->priority;
+ }
+
+ abstract public function apply(PHPUnit_Util_Metrics $metrics);
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,67 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: Class.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Util/Log/PMD/Rule.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Abstract base class for PMD rule classes that operate on the class-level.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+abstract class PHPUnit_Util_Log_PMD_Rule_Class extends PHPUnit_Util_Log_PMD_Rule
+{
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/DepthOfInheritanceTree.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/DepthOfInheritanceTree.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/DepthOfInheritanceTree.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/DepthOfInheritanceTree.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,83 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: DepthOfInheritanceTree.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Util/Log/PMD/Rule/Class.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ *
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Util_Log_PMD_Rule_Class_DepthOfInheritanceTree extends PHPUnit_Util_Log_PMD_Rule_Class
+{
+ public function __construct($threshold = 6, $priority = 1)
+ {
+ parent::__construct($threshold);
+ }
+
+ public function apply(PHPUnit_Util_Metrics $metrics)
+ {
+ $dit = $metrics->getDIT();
+
+ if ($dit > $this->threshold) {
+ return sprintf(
+ 'Depth of Inheritance Tree (DIT) is %d.',
+ $dit
+ );
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/EfferentCoupling.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/EfferentCoupling.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/EfferentCoupling.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/EfferentCoupling.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,86 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: EfferentCoupling.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Util/Log/PMD/Rule/Class.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ *
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Util_Log_PMD_Rule_Class_EfferentCoupling extends PHPUnit_Util_Log_PMD_Rule_Class
+{
+ public function __construct($threshold = 20, $priority = 1)
+ {
+ parent::__construct($threshold);
+ }
+
+ public function apply(PHPUnit_Util_Metrics $metrics)
+ {
+ $ce = $metrics->getCe();
+
+ if ($ce > $this->threshold) {
+ return sprintf(
+ "Class depends on %d other classes.\n" .
+ 'The number of other classes that the class ' .
+ 'depends upon is an indicator of the class\' ' .
+ 'independence.',
+ $ce
+ );
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/ExcessiveClassLength.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/ExcessiveClassLength.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/ExcessiveClassLength.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/ExcessiveClassLength.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,86 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: ExcessiveClassLength.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Util/Log/PMD/Rule/Class.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ *
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Util_Log_PMD_Rule_Class_ExcessiveClassLength extends PHPUnit_Util_Log_PMD_Rule_Class
+{
+ public function __construct($threshold = 1000, $priority = 1)
+ {
+ parent::__construct($threshold);
+ }
+
+ public function apply(PHPUnit_Util_Metrics $metrics)
+ {
+ $locExecutable = $metrics->getLocExecutable();
+
+ if ($locExecutable > $this->threshold) {
+ return sprintf(
+ "Class has %d lines of executable code.\n" .
+ 'This is an indication that the class may be ' .
+ 'trying to do too much. Try to break it down, ' .
+ 'and reduce the size to something manageable.',
+ $locExecutable
+ );
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/ExcessivePublicCount.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/ExcessivePublicCount.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/ExcessivePublicCount.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/ExcessivePublicCount.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,87 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: ExcessivePublicCount.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Util/Log/PMD/Rule/Class.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ *
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Util_Log_PMD_Rule_Class_ExcessivePublicCount extends PHPUnit_Util_Log_PMD_Rule_Class
+{
+ public function __construct($threshold = 45, $priority = 1)
+ {
+ parent::__construct($threshold);
+ }
+
+ public function apply(PHPUnit_Util_Metrics $metrics)
+ {
+ $publicMethods = $metrics->getPublicMethods();
+
+ if ($publicMethods > $this->threshold) {
+ return sprintf(
+ "Class has %d public methods.\n" .
+ 'A large number of public methods and attributes ' .
+ 'declared in a class can indicate the class may need ' .
+ 'to be broken up as increased effort will be required ' .
+ 'to thoroughly test it.',
+ $publicMethods
+ );
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/TooManyFields.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/TooManyFields.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/TooManyFields.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Class/TooManyFields.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,88 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: TooManyFields.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Util/Log/PMD/Rule/Class.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ *
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Util_Log_PMD_Rule_Class_TooManyFields extends PHPUnit_Util_Log_PMD_Rule_Class
+{
+ public function __construct($threshold = 15, $priority = 1)
+ {
+ parent::__construct($threshold);
+ }
+
+ public function apply(PHPUnit_Util_Metrics $metrics)
+ {
+ $varsNp = $metrics->getVARSnp();
+
+ if ($varsNp > $this->threshold) {
+ return sprintf(
+ "Class has %d public fields.\n" .
+ 'Classes that have too many fields could be redesigned ' .
+ 'to have fewer fields, possibly through some nested ' .
+ 'object grouping of some of the information. For ' .
+ 'example, a class with city/state/zip fields could ' .
+ 'instead have one Address field.',
+ $varsNp
+ );
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/File.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/File.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/File.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/File.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,67 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: File.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Util/Log/PMD/Rule.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Abstract base class for PMD rule classes that operate on the file-level.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+abstract class PHPUnit_Util_Log_PMD_Rule_File extends PHPUnit_Util_Log_PMD_Rule
+{
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,68 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: Function.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Util/Log/PMD/Rule.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Abstract base class for PMD rule classes that operate on the function- or
+ * method-level.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+abstract class PHPUnit_Util_Log_PMD_Rule_Function extends PHPUnit_Util_Log_PMD_Rule
+{
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/CRAP.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/CRAP.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/CRAP.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/CRAP.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,88 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: CRAP.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Util/Log/PMD/Rule/Function.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ *
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Util_Log_PMD_Rule_Function_CRAP extends PHPUnit_Util_Log_PMD_Rule_Function
+{
+ public function __construct($threshold = 30, $priority = 1)
+ {
+ parent::__construct($threshold);
+ }
+
+ public function apply(PHPUnit_Util_Metrics $metrics)
+ {
+ $crap = $metrics->getCrapIndex();
+
+ if ($crap >= $this->threshold) {
+ return sprintf(
+ "The CRAP index is %d.\n" .
+ 'The Change Risk Analysis and Predictions (CRAP) index of a ' .
+ 'function or method uses cyclomatic complexity and code coverage ' .
+ 'from automated tests to help estimate the effort and risk ' .
+ 'associated with maintaining legacy code. A CRAP index over 30 ' .
+ 'is a good indicator of crappy code.',
+ $crap
+ );
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/CodeCoverage.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/CodeCoverage.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/CodeCoverage.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/CodeCoverage.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,91 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: CodeCoverage.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Util/Log/PMD/Rule/Function.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ *
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Util_Log_PMD_Rule_Function_CodeCoverage extends PHPUnit_Util_Log_PMD_Rule_Function
+{
+ public function __construct($threshold = array(35, 70), $priority = 1)
+ {
+ parent::__construct($threshold);
+ }
+
+ public function apply(PHPUnit_Util_Metrics $metrics)
+ {
+ $coverage = $metrics->getCoverage();
+
+ if ($coverage <= $this->threshold[0]) {
+ $violation = 'The code coverage is %01.2F which is considered low.';
+ }
+
+ else if ($coverage > $this->threshold[0] && $coverage < $this->threshold[1]) {
+ $violation = 'The code coverage is %01.2F which is considered medium.';
+ }
+
+ if (isset($violation)) {
+ return sprintf(
+ $violation,
+ $coverage
+ );
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/CyclomaticComplexity.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/CyclomaticComplexity.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/CyclomaticComplexity.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/CyclomaticComplexity.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,89 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: CyclomaticComplexity.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Util/Log/PMD/Rule/Function.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ *
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Util_Log_PMD_Rule_Function_CyclomaticComplexity extends PHPUnit_Util_Log_PMD_Rule_Function
+{
+ public function __construct($threshold = 20, $priority = 1)
+ {
+ parent::__construct($threshold);
+ }
+
+ public function apply(PHPUnit_Util_Metrics $metrics)
+ {
+ $ccn = $metrics->getCCN();
+
+ if ($ccn >= $this->threshold) {
+ return sprintf(
+ "The cyclomatic complexity is %d.\n" .
+ 'Complexity is determined by the number of decision points in a ' .
+ 'function or method plus one for the function or method entry. ' .
+ 'The decision points are "if", "for", "foreach", "while", "case", ' .
+ '"catch", "&&", "||", and "?:". Generally, 1-4 is low ' .
+ 'complexity, 5-7 indicates moderate complexity, 8-10 is high ' .
+ 'complexity, and 11+ is very high complexity.',
+ $ccn
+ );
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/ExcessiveMethodLength.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/ExcessiveMethodLength.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/ExcessiveMethodLength.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Util/Log/PMD/Rule/Function/ExcessiveMethodLength.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,86 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: ExcessiveMethodLength.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Util/Log/PMD/Rule/Function.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ *
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Util_Log_PMD_Rule_Function_ExcessiveMethodLength extends PHPUnit_Util_Log_PMD_Rule_Function
+{
+ public function __construct($threshold = 100, $priority = 1)
+ {
+ parent::__construct($threshold);
+ }
+
+ public function apply(PHPUnit_Util_Metrics $metrics)
+ {
+ $locExecutable = $metrics->getLocExecutable();
+
+ if ($locExecutable >= $this->threshold) {
+ return sprintf(
+ "Function or method has %d lines of executable code.\n" .
+ 'Violations of this rule usually indicate that the method is ' .
+ 'doing too much. Try to reduce the method size by creating ' .
+ 'helper methods and removing any copy/pasted code.',
+ $locExecutable
+ );
+ }
+ }
+}
+?>