Ejemplo n.º 1
0
 /**
  * @param string $path
  * @param array $options
  * @param AbstractLogger $logger
  * @return Result
  */
 public function run($path, array $options, AbstractLogger $logger)
 {
     $processBuilder = new ProcessBuilder([$this->bin, 'security:check', '--format=json', $options['directory']]);
     $processBuilder->setWorkingDirectory($path);
     $output = $processBuilder->run($logger);
     $data = json_decode($output, true);
     $result = new Result();
     if (count($data) == 0) {
         return $result;
     }
     foreach ($data as $lib => $info) {
         $result->merge($this->createIssues(trim(rtrim($options['directory'], '/') . '/composer.json', './'), $lib, $info, $options['level']));
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * @param string $path
  * @param array $options
  * @param AbstractLogger $logger
  * @return Result
  */
 public function run($path, array $options, AbstractLogger $logger)
 {
     $processBuilder = new ProcessBuilder([$this->bin, '--report=csv']);
     foreach ($options['standards'] as $standard) {
         $processBuilder->add('--standard=' . $standard);
     }
     $processBuilder->add('--extensions=' . implode(',', $options['extensions']));
     foreach ($options['files'] as $file) {
         $processBuilder->add($file);
     }
     $processBuilder->setWorkingDirectory($path);
     $output = $processBuilder->run($logger);
     $rawIssues = $this->convertFromCsvToArray($output);
     $result = new Result();
     foreach ($rawIssues as $info) {
         $result->addIssue($this->createIssue($info));
     }
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * @param string $path
  * @param array $options
  * @param AbstractLogger $logger
  * @return Result
  */
 public function run($path, array $options, AbstractLogger $logger)
 {
     $processBuilder = new ProcessBuilder([$this->bin]);
     $processBuilder->add(implode(',', $options['files']));
     $processBuilder->add('xml');
     $processBuilder->add(implode(',', $options['rulesets']));
     $processBuilder->setWorkingDirectory($path);
     $output = $processBuilder->run($logger);
     $data = $this->convertFromXmlToArray($output);
     $result = new Result();
     if (!isset($data['file']) || !is_array($data['file'])) {
         return $result;
     }
     $files = isset($data['file'][0]) ? $data['file'] : [$data['file']];
     foreach ($files as $file) {
         $violations = isset($file['violation'][0]) ? $file['violation'] : [$file['violation']];
         foreach ($violations as $violation) {
             $result->addIssue($this->createIssue($file['@name'], $violation));
         }
     }
     return $result;
 }
Ejemplo n.º 4
0
 /**
  * @param string $path
  * @param array $options
  * @param AbstractLogger $logger
  * @return Result
  */
 public function run($path, array $options, AbstractLogger $logger)
 {
     $file = tempnam('/tmp', 'pdepend_');
     $processBuilder = new ProcessBuilder([$this->bin]);
     $processBuilder->add('--summary-xml=' . $file);
     $processBuilder->add(implode(',', $options['files']));
     $processBuilder->setWorkingDirectory($path);
     $processBuilder->run($logger);
     $data = $this->convertFromXmlToArray(file_get_contents($file));
     (new Filesystem())->remove($file);
     $result = new Result();
     $add = function ($code, $title, $description = null) use($result, $data) {
         $metric = new Metric($title, strtolower('pdepend.' . $code), $data['@' . $code]);
         $metric->setDescription($description);
         $result->addMetric($metric);
     };
     $add('ahh', 'Average Hierarchy Height', 'The average of the maximum lenght from a root class to ist deepest subclass subclass');
     $add('andc', 'Average Number of Derived Classes', 'The average of direct subclasses of a class');
     $add('calls', 'Number of Method or Function Calls');
     $add('ccn', 'Cyclomatic Complexity Number');
     $add('ccn2', 'Extended Cyclomatic Complexity Number');
     $add('cloc', 'Comment Lines fo Code');
     $add('clsa', 'Number of Abstract Classes');
     $add('clsc', 'Number of Concrete Classes');
     $add('fanout', 'Number of Fanouts', 'Referenced Classes');
     $add('leafs', 'Number of Leaf Classes', '(final) classes');
     $add('lloc', 'Logical Lines Of Code');
     $add('loc', 'Lines Of Code');
     $add('maxDIT', 'Max Depth of Inheritance Tree', 'Maximum depth of inheritance');
     $add('ncloc', 'Non Comment Lines Of Code');
     $add('noc', 'Number Of Classes');
     $add('nof', 'Number Of Functions');
     $add('noi', 'Number Of Interfaces');
     $add('nom', 'Number Of Methods');
     $add('nop', 'Number of Packages');
     $add('roots', 'Number of Root Classes');
     return $result;
 }