Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@
$standards_faults = 0;
$path = $argv[1];

// Lines of code.
$finder = Finder::create();
$finder->files()->in($path)->filter(static function (SplFileInfo $file) {
return $file->isDir() || \preg_match('/\.(php|module|install|inc|js|scss)$/', $file->getPathname());
});
$files = [];
foreach ($finder as $file) {
$files[] = $file->getRealPath();
}
$count = (new Analyser)->countFiles($files, TRUE);
$total_lines = $count['ncloc'];

if ($total_lines === 0) {
print "There is no code to analyse.\n";
exit;
}

/**
* Mess Detector function.
*/
Expand Down Expand Up @@ -81,18 +98,6 @@ function php_md($path, $type) {
print "phpcs DrupalPractice: " . $faults . "\n";
$standards_faults += $faults;

// Lines of code.
$finder = Finder::create();
$finder->files()->in($path)->filter(static function (SplFileInfo $file) {
return $file->isDir() || \preg_match('/\.(php|module|install|inc|js|scss)$/', $file->getPathname());
});
$files = [];
foreach ($finder as $file) {
$files[] = $file->getRealPath();
}
$count = (new Analyser)->countFiles($files, TRUE);
$total_lines = $count['ncloc'];

$faults = $code_faults + $standards_faults;
$percent = ($faults / $total_lines) * 100;

Expand Down