1 | <?php declare(strict_types=1); |
||
23 | class RoboFile extends \Robo\Tasks { |
||
24 | |||
25 | /** |
||
26 | * Directories used by analysis tools |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $taskDirs = [ |
||
31 | 'build/logs', |
||
32 | 'build/pdepend', |
||
33 | 'build/phpdox', |
||
34 | ]; |
||
35 | |||
36 | /** |
||
37 | * Directories to remove with the clean task |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $cleanDirs = [ |
||
42 | 'coverage', |
||
43 | 'apiDocumentation', |
||
44 | 'phpdoc', |
||
45 | 'build/logs', |
||
46 | 'build/phpdox', |
||
47 | 'build/pdepend' |
||
48 | ]; |
||
49 | |||
50 | |||
51 | /** |
||
52 | * Do static analysis tasks |
||
53 | */ |
||
54 | public function analyze() |
||
63 | |||
64 | /** |
||
65 | * Run all tests, generate coverage, generate docs, generate code statistics |
||
66 | */ |
||
67 | public function build() |
||
73 | |||
74 | /** |
||
75 | * Cleanup temporary files |
||
76 | */ |
||
77 | public function clean() |
||
91 | |||
92 | /** |
||
93 | * Run unit tests and generate coverage reports |
||
94 | */ |
||
95 | public function coverage() |
||
99 | |||
100 | /** |
||
101 | * Generate documentation with phpdox |
||
102 | */ |
||
103 | public function docs() |
||
104 | { |
||
105 | $this->_run(['vendor/bin/phpdox']); |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * Verify that source files are valid |
||
110 | */ |
||
111 | public function lint() |
||
122 | |||
123 | /** |
||
124 | * Run the phpcs tool |
||
125 | * |
||
126 | * @param bool $report - if true, generates reports instead of direct output |
||
127 | */ |
||
128 | public function phpcs($report = FALSE) |
||
147 | |||
148 | /** |
||
149 | * Run the phploc tool |
||
150 | * |
||
151 | * @param bool $report - if true, generates reports instead of direct output |
||
152 | */ |
||
153 | public function phploc($report = FALSE) |
||
177 | |||
178 | /** |
||
179 | * Create temporary directories |
||
180 | */ |
||
181 | public function prepare() |
||
185 | |||
186 | /** |
||
187 | * Lint php files and run unit tests |
||
188 | */ |
||
189 | public function test() |
||
197 | |||
198 | /** |
||
199 | * Watches for file updates, and automatically runs appropriate actions |
||
200 | */ |
||
201 | public function watch() |
||
215 | |||
216 | /** |
||
217 | * Create pdepend reports |
||
218 | */ |
||
219 | protected function dependencyReport() |
||
230 | |||
231 | /** |
||
232 | * Get the total list of source files, including tests |
||
233 | * |
||
234 | * @return array |
||
235 | */ |
||
236 | protected function getAllSourceFiles() |
||
249 | |||
250 | /** |
||
251 | * Run php's linter in one parallel task for the passed chunk |
||
252 | * |
||
253 | * @param array $chunk |
||
254 | */ |
||
255 | protected function parallelLint(array $chunk) |
||
268 | |||
269 | /** |
||
270 | * Generate copy paste detector report |
||
271 | */ |
||
272 | protected function phpcpdReport() |
||
281 | |||
282 | /** |
||
283 | * Shortcut for joining an array of command arguments |
||
284 | * and then running it |
||
285 | * |
||
286 | * @param array $cmd_parts - command arguments |
||
287 | * @param string $join_on - what to join the command arguments with |
||
288 | */ |
||
289 | protected function _run(array $cmd_parts, $join_on = ' ') |
||
293 | } |
||
294 |
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.