TextRenderer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 19.35 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 6
loc 31
rs 10
c 0
b 0
f 0
ccs 15
cts 15
cp 1
wmc 3
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A renderReport() 6 20 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * This file is part of PHP Mess Detector.
4
 *
5
 * Copyright (c) Manuel Pichler <[email protected]>.
6
 * All rights reserved.
7
 *
8
 * Licensed under BSD License
9
 * For full copyright and license information, please see the LICENSE file.
10
 * Redistributions of files must retain the above copyright notice.
11
 *
12
 * @author Manuel Pichler <[email protected]>
13
 * @copyright Manuel Pichler. All rights reserved.
14
 * @license https://opensource.org/licenses/bsd-license.php BSD License
15
 * @link http://phpmd.org/
16
 */
17
18
namespace PHPMD\Renderer;
19
20
use PHPMD\AbstractRenderer;
21
use PHPMD\Report;
22
23
/**
24
 * This renderer output a textual log with all found violations and suspect
25
 * software artifacts.
26
 */
27
class TextRenderer extends AbstractRenderer
28
{
29
30
    /**
31
     * This method will be called when the engine has finished the source analysis
32
     * phase.
33
     *
34
     * @param \PHPMD\Report $report
35
     * @return void
36
     */
37 6
    public function renderReport(Report $report)
38
    {
39 6
        $writer = $this->getWriter();
40
41 6
        foreach ($report->getRuleViolations() as $violation) {
42 5
            $writer->write($violation->getFileName());
43 5
            $writer->write(':');
44 5
            $writer->write($violation->getBeginLine());
45 5
            $writer->write("\t");
46 5
            $writer->write($violation->getDescription());
47 5
            $writer->write(PHP_EOL);
48
        }
49
50 6 View Code Duplication
        foreach ($report->getErrors() as $error) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51 1
            $writer->write($error->getFile());
52 1
            $writer->write("\t-\t");
53 1
            $writer->write($error->getMessage());
54 1
            $writer->write(PHP_EOL);
55
        }
56 6
    }
57
}
58