| Conditions | 6 |
| Paths | 8 |
| Total Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | public function run(): int |
||
| 11 | { |
||
| 12 | $options = $this->options(); |
||
| 13 | |||
| 14 | $repository = new Repository($options['root'] . ''); |
||
| 15 | $head = $repository->getHead(); |
||
| 16 | if ($head === null) { |
||
| 17 | echo "TodoReminder cannot determine HEAD of repository"; |
||
| 18 | return 1; |
||
| 19 | } |
||
| 20 | $files = $head->getCommit()->getDiff()->getFiles(); |
||
| 21 | if (empty($files)) { |
||
| 22 | echo "TodoReminder found no files to check"; |
||
| 23 | return 0; |
||
| 24 | } |
||
| 25 | $fileInspector = new FileInspector( |
||
| 26 | $repository, |
||
| 27 | (new ParserFactory())->create(ParserFactory::ONLY_PHP7) |
||
| 28 | ); |
||
| 29 | $comments = new TodoComments(); |
||
| 30 | foreach ($files as $file) { |
||
| 31 | /** @var \Gitonomy\Git\Diff\File $file */ |
||
| 32 | $fullPath = $repository->getWorkingDir() . '/' . $file->getName(); |
||
| 33 | if (file_exists($fullPath)) { |
||
| 34 | $comments->add($fileInspector->findTodoComments($file->getName())); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | if ($comments->notEmpty()) { |
||
| 38 | echo $comments->formatText(), "\n"; |
||
| 39 | return 0; |
||
| 40 | } |
||
| 41 | |||
| 42 | echo "TodoReminder has nothing to say.\n"; |
||
| 43 | return 0; |
||
| 44 | } |
||
| 45 | |||
| 55 |