|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
14
|
|
|
* |
|
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
16
|
|
|
* and is licensed under the LGPL. For more information please see |
|
17
|
|
|
* <http://phing.info>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
use SebastianBergmann\PHPCPD\CodeCloneMap; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Prints plain text output of phpcpd run |
|
24
|
|
|
* |
|
25
|
|
|
* @package phing.tasks.ext.phpcpd.formatter |
|
26
|
|
|
* @author Benjamin Schultz <[email protected]> |
|
27
|
|
|
*/ |
|
28
|
|
|
class DefaultPHPCPDResultFormatter extends PHPCPDResultFormatter |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* Processes a list of clones. |
|
32
|
|
|
* |
|
33
|
|
|
* @param CodeCloneMap $clones |
|
34
|
|
|
* @param Project $project |
|
35
|
|
|
* @param boolean $useFile |
|
36
|
|
|
* @param PhingFile|null $outFile |
|
37
|
|
|
*/ |
|
38
|
2 |
|
public function processClones($clones, Project $project, $useFile = false, $outFile = null) |
|
39
|
|
|
{ |
|
40
|
2 |
|
if (get_class($clones) == 'SebastianBergmann\PHPCPD\CodeCloneMap') { |
|
41
|
2 |
|
if (class_exists('SebastianBergmann\PHPCPD\Log\Text')) { |
|
42
|
2 |
|
$this->processClonesNew($clones, $useFile, $outFile); |
|
43
|
|
|
|
|
44
|
2 |
|
return; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
$logger = new \SebastianBergmann\PHPCPD\TextUI\ResultPrinter(); |
|
|
|
|
|
|
48
|
|
|
} else { |
|
49
|
|
|
$logger = new PHPCPD_TextUI_ResultPrinter(); |
|
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
// default format goes to logs, no buffering |
|
53
|
|
|
ob_start(); |
|
54
|
|
|
$logger->printResult($clones, $project->getBaseDir(), true); |
|
55
|
|
|
$output = ob_get_contents(); |
|
56
|
|
|
ob_end_clean(); |
|
57
|
|
|
|
|
58
|
|
|
if (!$useFile || empty($outFile)) { |
|
59
|
|
|
echo $output; |
|
60
|
|
|
} else { |
|
61
|
|
|
file_put_contents($outFile->getPath(), $output); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Wrapper for PHPCPD 2.0 |
|
67
|
|
|
* |
|
68
|
|
|
* @param CodeCloneMap $clones |
|
69
|
|
|
* @param boolean $useFile |
|
70
|
|
|
* @param PhingFile|null $outFile |
|
71
|
|
|
*/ |
|
72
|
2 |
|
private function processClonesNew($clones, $useFile = false, $outFile = null) |
|
73
|
|
|
{ |
|
74
|
2 |
|
if ($useFile) { |
|
75
|
1 |
|
ob_start(); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
2 |
|
$logger = new \SebastianBergmann\PHPCPD\Log\Text(); |
|
79
|
2 |
|
$logger->printResult($clones, true); |
|
80
|
|
|
|
|
81
|
2 |
|
if ($useFile) { |
|
82
|
1 |
|
file_put_contents($outFile->getPath(), ob_get_clean()); |
|
|
|
|
|
|
83
|
|
|
} |
|
84
|
2 |
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths