| Conditions | 14 |
| Paths | 92 |
| Total Lines | 65 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 49 | public function doRun(InputInterface $input, OutputInterface $output) |
||
| 50 | { |
||
| 51 | $output->writeln(sprintf('<fg=white;options=bold;bg=red>%s</fg=white;options=bold;bg=red>', $this->name)); |
||
| 52 | $output->writeln('<info>Fetching files...</info>'); |
||
| 53 | $files = Git::committedFiles(); |
||
| 54 | |||
| 55 | $output->writeln('<info>Check composer</info>'); |
||
| 56 | Composer::check($files); |
||
| 57 | |||
| 58 | if (in_array('phpcsfixer', $this->parameters['enabled'], true)) { |
||
| 59 | $output->writeln('<info>Fixing PHP code style with PHP-CS-Fixer</info>'); |
||
| 60 | PhpCsFixer::check($files, $this->parameters); |
||
| 61 | } |
||
| 62 | |||
| 63 | if (in_array('twigcs', $this->parameters['enabled'], true)) { |
||
| 64 | $output->writeln('<info>Linting the Twig files with TwigCS</info>'); |
||
| 65 | $twigCsResult = TwigCs::check($files, $this->parameters); |
||
| 66 | if (count($twigCsResult) > 0) { |
||
| 67 | foreach ($twigCsResult as $error) { |
||
| 68 | $output->writeln($error->output()); |
||
| 69 | } |
||
| 70 | throw new CheckFailException('TwigCS'); |
||
| 71 | } |
||
| 72 | } |
||
| 73 | |||
| 74 | if (in_array('phpmd', $this->parameters['enabled'], true)) { |
||
| 75 | $output->writeln('<info>Checking code mess with PHPMD</info>'); |
||
| 76 | $phpmdResult = Phpmd::check($files, $this->parameters); |
||
| 77 | if (count($phpmdResult) > 0) { |
||
| 78 | foreach ($phpmdResult as $error) { |
||
| 79 | $output->writeln($error->output()); |
||
| 80 | } |
||
| 81 | throw new CheckFailException('PHPMD'); |
||
| 82 | } |
||
| 83 | } |
||
| 84 | |||
| 85 | if (in_array('stylelint', $this->parameters['enabled'], true)) { |
||
| 86 | $output->writeln('<info>Checking scss files with Stylelint</info>'); |
||
| 87 | $stylelintResult = Stylelint::check($files, $this->parameters); |
||
| 88 | if (count($stylelintResult) > 0) { |
||
| 89 | foreach ($stylelintResult as $error) { |
||
| 90 | $output->writeln($error->output()); |
||
| 91 | } |
||
| 92 | throw new CheckFailException('Stylelint', 'Please, execute "npm update -g stylelint'); |
||
| 93 | } |
||
| 94 | } |
||
| 95 | |||
| 96 | if (in_array('eslint', $this->parameters['enabled'], true)) { |
||
| 97 | $output->writeln('<info>Checking js files with ESLint</info>'); |
||
| 98 | $esLintResult = EsLint::check($files, $this->parameters); |
||
| 99 | if (count($esLintResult) > 0) { |
||
| 100 | foreach ($esLintResult as $error) { |
||
| 101 | $output->writeln($error->output()); |
||
| 102 | } |
||
| 103 | throw new CheckFailException( |
||
| 104 | 'ESLint', |
||
| 105 | 'Please, execute "npm update -g eslint eslint-plugin-class-property ' . |
||
| 106 | 'eslint-plugin-react eslint-plugin-babel babel-eslint"' |
||
| 107 | ); |
||
| 108 | } |
||
| 109 | } |
||
| 110 | |||
| 111 | Git::addFiles($files, $this->parameters['root_directory']); |
||
| 112 | $output->writeln('<info>Nice commit man!</info>'); |
||
| 113 | } |
||
| 114 | |||
| 120 |