public function analyse() { $analyser = new PHPLOCAnalyser(); $finder = new FinderFacade([$this->findSourceRoot()]); $files = $finder->findFiles(); return $analyser->countFiles($files, true); }
/** * Run the task. * * @param array &$options Additional options. * * @return integer Number of errors. */ public function run(&$options) { $finder = new FinderFacade(array(realpath($this->_config->getPath()))); $files = $finder->findFiles(); $analyser = new PHPLOC\Analyser(); $count = $analyser->countFiles($files, true); $this->_printResult($count); }
/** * Processes a directory * * @param array $arguments * @param $excludes * @param $names * @param $namesExclude * @param $countTests * @return array|bool */ private function count(array $arguments, $excludes, $names, $namesExclude, $countTests) { try { $finder = new FinderFacade($arguments, $excludes, $names, $namesExclude); $files = $finder->findFiles(); } catch (\InvalidArgumentException $ex) { return false; } if (empty($files)) { return false; } $analyser = new Analyser(); return $analyser->countFiles($files, $countTests); }
/** * @return array */ public function getCodeMetrics() { $analyzer = new Analyser(); return $analyzer->countFiles(array($this->getRelativePath()), null); }
private function count(array $arguments, $excludes, $names, $namesExclude, $countTests) { $finder = new FinderFacade($arguments, $excludes, $names, $namesExclude); $files = $finder->findFiles(); if (empty($files)) { return FALSE; } $analyser = new Analyser(); return $analyser->countFiles($files, $countTests); }
/** * @return array */ public function getCodeMetrics() { $analyzer = new Analyser(); $finder = new Finder(); $finder->name('*.php')->in($this->getRealPath()); return $analyzer->countFiles(iterator_to_array($finder), null); }
/** * Count source lines of code and comments * * @return array */ public function countSloc() { $filelistPath = $this->_outputPath . 'filelist'; $this->_qis->log("Counting lines of codes in paths '" . implode(',', $this->_paths) . "'"); $sloc = 0; $comments = 1; $this->_clearFileList(); foreach ($this->_paths as $path) { $files = $this->_createFileList($path); } $analyser = new Analyser(); $results = $analyser->countFiles($files, false); if (isset($results['loc'])) { // Lines of Code $sloc = $results['loc']; } if (isset($results['cloc'])) { // Lines of Code $comments = $results['cloc']; } $this->_updateSloc($sloc); $this->_updateCommentLines($comments); return array($sloc, $comments); }
/** * @ticket 139 */ public function testIssue139IsFixed() { error_reporting(E_ALL); $result = $this->analyser->countFiles([__DIR__ . '/_files/issue_139.php'], false); $this->assertEquals(1, $result['anonymousFunctions']); }
/** * Get sloc (source lines of code for a file) * * @param string $file Path to file * @return int */ protected function _getSloc($file) { $analyser = new Analyser(); $results = $analyser->countFiles(array($file), false); // lloc = Logical Lines of Code return $results['lloc']; }
/** * Runs PHP LinesOfCode analysis. * * Https://github.com/sebastianbergmann/phploc. * * @param \DrupalCodeMetrics\Module $module * @param $extensions * @return array|null */ function getLocAnalysis(Module $module, $extensions) { // Run phploc analyser directly as PHP. $analyser = new Analyser(); // It's my job to set the parameters right, and take care to only give it // PHP files (it borks on binaries, understandably). $tree = $module->getCodeFiles($extensions); $analysis = NULL; try { $analysis = $analyser->countFiles($tree, TRUE); } catch (Exception $e) { $message = "When processing " . $module->getLocation() . " " . $e->getMessage(); error_log($message); } return $analysis; }