<commit_before>#!/usr/bin/php
<?php

require 'vendor/autoload.php';

$file = 'clover.xml';

$collector = new CloverXmlMetricCollector($file, 'phpunit.coverage.');
var_dump($collector->collect());
#$nodes = $node->childNodes;







exit;

$projectName = 'portal';
#$projectName = 'core';
$project = new Project($projectName);

foreach (array('checkstyle', 'pmd', 'dry') as $metricType) {
    $data = json_decode(file_get_contents('http://ci.lafourchette.lan:8080/view/B2C/job/lafourchette-' . $projectName . '-master-nightly/lastBuild/' . $metricType . 'Result/api/json'), true);
    $project->addMetric(new Metric($metricType . ' / numberOfHighPriorityWarnings', $data['numberOfHighPriorityWarnings']));
    $project->addMetric(new Metric($metricType . ' / numberOfNormalPriorityWarnings', $data['numberOfNormalPriorityWarnings']));
    $project->addMetric(new Metric($metricType . ' / numberOfLowPriorityWarnings', $data['numberOfLowPriorityWarnings']));
}
$data = json_decode(file_get_contents('http://ci.lafourchette.lan:8080/view/B2C/job/lafourchette-' . $projectName . '-master-nightly/lastBuild/testReport/api/json'), true);
$project->addMetric(new Metric('phpunit / pass', $data['passCount']));
$project->addMetric(new Metric('phpunit / fail', $data['failCount']));
$data = file_get_contents('http://ci.lafourchette.lan:8080/view/B2C/job/lafourchette-' . $projectName . '-master-nightly/lastBuild/cloverphp-report/');
//$x('//table[@class="coverage"]/tbody/tr/td[@class="data"]')
$document = new DOMDocument();
$document->loadHTML($data);
$xpath = new DOMXpath($document);
$nodes = $xpath->query('//table[@class="coverage"]');
$node = $nodes->item(0)->childNodes->item(1);
$nodes = $node->childNodes;
$project->addMetric(new Metric('coverage / method', strtr($nodes->item(4)->textContent, array(PHP_EOL => '', '                ' => ' '))));
$project->addMetric(new Metric('coverage / statement', strtr($nodes->item(5)->textContent, array(PHP_EOL => '', '                ' => ' '))));
echo $project;
<commit_msg>Pushing in statsd<commit_after>#!/usr/bin/php
<?php

require 'vendor/autoload.php';


use Liuggio\StatsdClient\StatsdClient,
    Liuggio\StatsdClient\Factory\StatsdDataFactory,
    Liuggio\StatsdClient\Sender\SocketSender,
    Liuggio\StatsdClient\Service\StatsdService;
            // use Liuggio\StatsdClient\Sender\SysLogSender;

$sender = new SocketSender('localhost', 8125, 'udp');
            // $sender = new SysLogSender(); // enabling this, the packet will not send over the socket

$client  = new StatsdClient($sender);
$factory = new StatsdDataFactory('\Liuggio\StatsdClient\Entity\StatsdData');
$service = new StatsdService($client, $factory);

$file = 'clover.xml';

$prefix = 'lafourchette.ci.b2c.core.';

$metrics = array();
$collector = new CloverXmlMetricCollector('clover.xml', $prefix . 'coverage.');
$metrics = array_merge($collector->collect(), $metrics);

$collector = new JunitXmlMetricCollector('junit.xml', $prefix . 'phpunit.');
$metrics = array_merge($metrics, $collector->collect());

$collector = new CheckstyleXmlMetricCollector('checkstyle.xml', $prefix . 'checkstyle.');
$metrics = array_merge($metrics, $collector->collect());

$collector = new PhplocXmlMetricCollector('phploc.xml', $prefix . 'phploc.');
$metrics = array_merge($metrics, $collector->collect());

//var_dump($metrics);
foreach ($metrics as $metric => $value) {
    $service->gauge($metric, $value);
}

$service->flush();

{'fraction_non_alphanumeric': 0.19098837209302325, 'fraction_numerical': 0.0069767441860465115, 'mean_word_length': 5.617307692307692, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3905434', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1148, 'n_words': 177}