コード例 #1
0
ファイル: LongClass.php プロジェクト: n2bh/phpmd
 /**
  * This method checks the length of the given class node against a configured
  * threshold.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     $threshold = $this->getIntProperty('minimum');
     $ignoreWhitespace = $this->getBooleanProperty('ignore-whitespace');
     if ($ignoreWhitespace) {
         $loc = $node->getMetric('eloc');
     } else {
         $loc = $node->getMetric('loc');
     }
     if ($loc < $threshold) {
         return;
     }
     $this->addViolation($node, array($node->getName(), $loc, $threshold));
 }
コード例 #2
0
ファイル: ExcessivePublicCount.php プロジェクト: noelg/phpmd
 /**
  * This method checks the number of public fields and methods in the given
  * class and checks that value against a configured threshold.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     if ($node->getMetric('cis') < $this->getIntProperty('minimum')) {
         return;
     }
     $this->addViolation($node);
 }
コード例 #3
0
ファイル: NumberOfChildren.php プロジェクト: yusufchang/app
 /**
  * This method checks the number of classes derived from the given class
  * node.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     $nocc = $node->getMetric('nocc');
     if ($nocc >= $this->getIntProperty('minimum')) {
         $this->addViolation($node, array($node->getName(), $nocc));
     }
 }
コード例 #4
0
ファイル: TooManyFields.php プロジェクト: kingsj/core
 /**
  * This method checks the number of methods with in a given class and checks
  * this number against a configured threshold.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     if ($node->getMetric('vars') <= $this->getIntProperty('maxfields')) {
         return;
     }
     $this->addViolation($node);
 }
コード例 #5
0
 /**
  * This method should implement the violation analysis algorithm of concrete
  * rule implementations. All extending classes must implement this method.
  *
  * @param PHP_PMD_AbstractNode $node The current context for analysis.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     $cbo = $node->getMetric('cbo');
     if ($cbo >= ($threshold = $this->getIntProperty('minimum'))) {
         $this->addViolation($node, array($node->getName(), $cbo, $threshold));
     }
 }
コード例 #6
0
ファイル: LongClass.php プロジェクト: Tjorriemorrie/app
 /**
  * This method checks the length of the given class node against a configured
  * threshold.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     $loc = $node->getMetric('loc');
     if ($loc < $this->getIntProperty('minimum')) {
         return;
     }
     $this->addViolation($node, array($node->getName(), $loc));
 }
コード例 #7
0
ファイル: NpathComplexity.php プロジェクト: Tjorriemorrie/app
 /**
  * This method checks the acyclic complexity for the given node against a
  * configured threshold.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     $npath = $node->getMetric('npath');
     if ($npath < $this->getIntProperty('minimum')) {
         return;
     }
     $this->addViolation($node, array($node->getType(), $node->getName(), $npath));
 }
コード例 #8
0
 /**
  * This method checks the number of parents for the given class
  * node.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     $threshold = $this->getIntProperty('minimum');
     $dit = $node->getMetric('dit');
     if ($dit >= $threshold) {
         $this->addViolation($node, array($node->getType(), $node->getName(), $dit, $threshold));
     }
 }
コード例 #9
0
 /**
  * This method checks the cyclomatic complexity for the given node against
  * a configured threshold.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     $ccn = $node->getMetric('ccn2');
     if ($ccn < $this->getIntProperty('reportLevel')) {
         return;
     }
     $this->addViolation($node, array($node->getType(), $node->getName(), $ccn));
 }
コード例 #10
0
ファイル: WeightedMethodCount.php プロジェクト: kingsj/core
 /**
  * This method checks the weighted method count for the given class against
  * a configured threshold.
  *
  * @param PHP_PMD_AbstractNode $node The context class node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     $threshold = $this->getIntProperty('maximum');
     $actual = $node->getMetric('wmc');
     if ($actual >= $threshold) {
         $this->addViolation($node, array($node->getName(), $actual, $threshold));
     }
 }
コード例 #11
0
 /**
  * This method checks the number of public fields and methods in the given
  * class and checks that value against a configured threshold.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     $threshold = $this->getIntProperty('minimum');
     $cis = $node->getMetric('cis');
     if ($cis < $threshold) {
         return;
     }
     $this->addViolation($node, array($node->getType(), $node->getName(), $cis, $threshold));
 }
コード例 #12
0
 /**
  * This method checks the number of methods with in a given class and checks
  * this number against a configured threshold.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     $threshold = $this->getIntProperty('maxfields');
     $vars = $node->getMetric('vars');
     if ($vars <= $threshold) {
         return;
     }
     $this->addViolation($node, array($node->getType(), $node->getName(), $vars, $threshold));
 }
コード例 #13
0
ファイル: TooManyMethods.php プロジェクト: kingsj/core
 /**
  * This method checks the number of methods with in a given class and checks
  * this number against a configured threshold.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     if ($node->getMetric('nom') <= $this->getIntProperty('maxmethods')) {
         return;
     }
     if ($this->_countMethods($node) <= $this->getIntProperty('maxmethods')) {
         return;
     }
     $this->addViolation($node);
 }
コード例 #14
0
ファイル: LongMethod.php プロジェクト: kingsj/core
 /**
  * This method checks the lines of code length for the given function or
  * methode node against a configured threshold.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     $loc = $node->getMetric('loc');
     if ($loc < $this->getIntProperty('minimum')) {
         return;
     }
     $type = explode('_', get_class($node));
     $type = strtolower(array_pop($type));
     $this->addViolation($node, array($type, $node->getName(), $loc));
 }
コード例 #15
0
ファイル: TooManyMethods.php プロジェクト: zerkalica/phpmd
 /**
  * This method checks the number of methods with in a given class and checks
  * this number against a configured threshold.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     $threshold = $this->getIntProperty('maxmethods');
     if ($node->getMetric('nom') <= $threshold) {
         return;
     }
     $nom = $this->_countMethods($node);
     if ($nom <= $threshold) {
         return;
     }
     $this->addViolation($node, array($node->getType(), $node->getName(), $nom, $threshold));
 }
コード例 #16
0
 /**
  * This method checks the number of methods with in a given class and checks
  * this number against a configured threshold.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     try {
         $this->ignoreRegexp = $this->getStringProperty('ignorepattern');
     } catch (OutOfBoundsException $e) {
         $this->ignoreRegexp = self::DEFAULT_IGNORE_REGEXP;
     }
     $threshold = $this->getIntProperty('maxmethods');
     if ($node->getMetric('nom') <= $threshold) {
         return;
     }
     $nom = $this->countMethods($node);
     if ($nom <= $threshold) {
         return;
     }
     $this->addViolation($node, array($node->getType(), $node->getName(), $nom, $threshold));
 }