Exemplo n.º 1
0
 /**
  * Calculates the crap index for the given callable.
  *
  * @param  \PDepend\Source\AST\AbstractASTCallable $callable
  * @return float
  */
 private function calculateCrapIndex(AbstractASTCallable $callable)
 {
     $report = $this->createOrReturnCoverageReport();
     $complexity = $this->ccnAnalyzer->getCcn2($callable);
     $coverage = $report->getCoverage($callable);
     if ($coverage == 0) {
         return pow($complexity, 2) + $complexity;
     } elseif ($coverage > 99.5) {
         return $complexity;
     }
     return pow($complexity, 2) * pow(1 - $coverage / 100, 3) + $complexity;
 }
Exemplo n.º 2
0
 /**
  * Calculates the Weight Method Per Class metric.
  *
  * @param  \PDepend\Source\AST\AbstractASTType $type
  * @return integer[]
  * @since  1.0.6
  */
 private function calculateWmci(AbstractASTType $type)
 {
     $ccn = array();
     foreach ($type->getMethods() as $method) {
         $ccn[$method->getName()] = $this->cyclomaticAnalyzer->getCcn2($method);
     }
     return $ccn;
 }