add copy-paste detection warnings generator script

This commit is contained in:
Ivan Smolin 2017-05-03 11:04:50 +03:00
parent d11082316a
commit c7c4fdc32f
1 changed files with 10 additions and 0 deletions

10
cpd_script.php Normal file
View File

@ -0,0 +1,10 @@
<?php
foreach (simplexml_load_file('cpd-output.xml')->duplication as $duplication) {
$files = $duplication->xpath('file');
foreach ($files as $file) {
echo $file['path'].':'.$file['line'].':1: warning: '.$duplication['lines'].' copy-pasted lines from: '
.implode(', ', array_map(function ($otherFile) { return $otherFile['path'].':'.$otherFile['line']; },
array_filter($files, function ($f) use (&$file) { return $f != $file; }))).PHP_EOL;
}
}
?>