Commit 7465766e authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Correction du compteur de lignes de code

parent eef7a24e
Loading
Loading
Loading
Loading
Loading
+64 −85
Original line number Diff line number Diff line
@@ -8,64 +8,64 @@
 * @var $viewFile   string
 */

$dir     = getcwd();
$ignored = [
    $dir . '/vendor',
    $dir . '/public/vendor',
    $dir . '/.idea',
    $dir . '/data',
    $dir . '/composer.lock',
    $dir . '/deploy.log',
];
$data = [];

$res          = parseCode($dir, $ignored);
$res['sql']   = parseFileSql($dir . '/data/bdd.sql');
$res['total'] = $res['lignes'] + $res['sql'];

echo '<h3>Nombre de lignes de codes et de fichiers dans ' . $container->get('config')['unicaen-app']['app_infos']['nom'] . ' :</h3>';
var_dump($res);
$dir = getcwd();
$name = $container->get('config')['unicaen-app']['app_infos']['nom'];
$data[$dir] = countLignes($dir, 'Application '.$name);

$unicaenLibs = scandir($dir.'/vendor/unicaen');
unset($unicaenLibs[0]);unset($unicaenLibs[1]); // pas de . et ..

$dir     = getcwd() . '/vendor/unicaen/app';
$ignored = [
    $dir . '/vendor',
    $dir . '/.idea',
    $dir . '/data',
    $dir . '/composer.lock',
    $dir . '/deploy.log',
];
$res     = parseCode($dir, $ignored);
foreach ($unicaenLibs as $lib) {
    $dir = getcwd().'/vendor/unicaen/'.$lib;
    $data[$dir] = countLignes($dir, 'unicaen/'.$lib);
}

echo '<h3>Nombre de lignes de codes et de fichiers dans UnicaenApp :</h3>';
var_dump($res);
?>
<table class="table table-bordered">
    <thead>
    <tr>
        <th>Nom</th>
        <th>Nombre de fichiers</th>
        <th>Nombre de lignes de code</th>
    </tr>
    </thead>
    <tbody>
    <?php foreach( $data as $d): ?>
    <tr>
        <td><?= $d['name'] ?></td>
        <td><?= $d['fichiers'] ?></td>
        <td><?= $d['lignes'] ?></td>
    </tr>
    <?php endforeach; ?>
    </tbody>
</table>
<?php


$dir     = getcwd() . '/vendor/unicaen/auth';
function countLignes(string $dir, string $name): array
{
    $ignored = [
        $dir . '/vendor',
        $dir . '/public/vendor',
        $dir . '/public/ace-builds-master', // pour Unicaen/import
        $dir . '/.idea',
    $dir . '/data',
        $dir . '/cache',
        $dir . '/log',
        $dir . '/.git',
        $dir . '/node_modules',
        $dir . '/package-lock.json',
        $dir . '/composer.lock',
        $dir . '/deploy.log',
        $dir . '/autoload_classmap.php',
    ];
$res     = parseCode($dir, $ignored);

echo '<h3>Nombre de lignes de codes et de fichiers dans UnicaenAuth :</h3>';
var_dump($res);


$dir     = getcwd() . '/vendor/unicaen/code';
$ignored = [
    $dir . '/vendor',
    $dir . '/.idea',
    $dir . '/data',
    $dir . '/composer.lock',
    $dir . '/deploy.log',
];
    $res = parseCode($dir, $ignored);

echo '<h3>Nombre de lignes de codes et de fichiers dans UnicaenCode :</h3>';
var_dump($res);
    $res['name'] = $name;
    return $res;
}


function parseCode($dir, $ignored = [])
@@ -77,18 +77,11 @@ function parseCode($dir, $ignored = [])
    $allowedExts = [
        'php', 'json', 'js', 'css', 'xml', 'phtml', 'dist', 'sql', 'yml', 'po', 'htaccess', 'txt', 'html',
    ];
    $excluded    = [
        '.',
        '..',
        'autoload_classmap.php',
        //        'Traits',
        //        'Interfaces',
    ];

    $i = scandir($dir);

    foreach ($i as $fd) {
        if (!in_array($fd, $excluded)) {
        if (!in_array($fd, ['.', '..'])) {
            $item = $dir . '/' . $fd;
            if (!in_array($item, $ignored)) {
                if (is_file($item)) {
@@ -121,17 +114,3 @@ function parseFileLines($filename)

    return $res;
}

function parseFileSql($filename)
{
    if (!file_exists($filename)) return 0;
    $res   = 0;
    $lines = file($filename);
    foreach ($lines as $line) {
        if ('' != trim($line) && 0 !== strpos($line, '--')) {
            $res++;
        } // on supprime les lignes vides ou les commentaires
    }

    return $res;
}
 No newline at end of file