|
1
|
|
|
<?php |
|
2
|
|
|
/****************************************************************************** |
|
3
|
|
|
* An implementation of dicto (scg.unibe.ch/dicto) in and for PHP. |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright (c) 2016, 2015 Richard Klees <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* This software is licensed under The MIT License. You should have received |
|
8
|
|
|
* a copy of the license along with the code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Lechimp\Dicto\App; |
|
12
|
|
|
|
|
13
|
|
|
use Lechimp\Dicto\Analysis\ReportGenerator; |
|
14
|
|
|
use Lechimp\Dicto\Analysis\Violation; |
|
15
|
|
|
use Lechimp\Dicto\Rules\Ruleset; |
|
16
|
|
|
use Lechimp\Dicto\Rules\Rule; |
|
17
|
|
|
|
|
18
|
|
|
class CLIReportGenerator implements ReportGenerator { |
|
19
|
|
|
protected $lines = array(); |
|
20
|
|
|
|
|
21
|
|
|
protected function line($content = "") { |
|
22
|
|
|
$this->lines[] = $content; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @inheritdoc |
|
27
|
|
|
*/ |
|
28
|
|
|
public function begin_run($commit_hash) { |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @inheritdoc |
|
33
|
|
|
*/ |
|
34
|
|
|
public function end_run() { |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @inheritdoc |
|
39
|
|
|
*/ |
|
40
|
|
|
public function begin_ruleset(Ruleset $rule) { |
|
41
|
|
|
$this->line("Result of analysis:"); |
|
42
|
|
|
$this->line(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function end_ruleset() { |
|
46
|
|
|
echo implode("\n", $this->lines); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @inheritdoc |
|
51
|
|
|
*/ |
|
52
|
|
|
public function begin_rule(Rule $rule) { |
|
53
|
|
|
$this->line("------------------------------------------------------------------------------"); |
|
54
|
|
|
$this->line($rule->pprint()); |
|
55
|
|
|
$this->line("------------------------------------------------------------------------------"); |
|
56
|
|
|
$this->line(); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function end_rule() { |
|
60
|
|
|
$this->line(); |
|
61
|
|
|
$this->line(); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @inheritdoc |
|
66
|
|
|
*/ |
|
67
|
|
|
public function report_violation(Violation $violation) { |
|
68
|
|
|
$this->line($violation->filename()." (".$violation->line_no().")"); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|