| Conditions | 5 |
| Paths | 27 |
| Total Lines | 63 |
| Code Lines | 41 |
| 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 |
||
| 100 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
| 101 | { |
||
| 102 | try { |
||
| 103 | $projectRoot = ProjectRootHelper::getProjectRoot($input); |
||
| 104 | $outputFormatter = $this->getOutputFormatter($input); |
||
| 105 | $baseLineFileName = BaseLineFileHelper::getBaselineFile($input); |
||
| 106 | $inputAnalysisResultsAsString = CliConfigReader::getStdin($input); |
||
| 107 | $showRandomIssues = CliConfigReader::getBooleanOption($input, self::SHOW_RANDOM_ERRORS); |
||
| 108 | |||
| 109 | $prunedResults = $this->resultsPruner->getPrunedResults( |
||
| 110 | $baseLineFileName, |
||
| 111 | $inputAnalysisResultsAsString, |
||
| 112 | $projectRoot |
||
| 113 | ); |
||
| 114 | |||
| 115 | $outputAnalysisResults = $prunedResults->getPrunedResults(); |
||
| 116 | |||
| 117 | OutputWriter::writeToStdError( |
||
| 118 | $output, |
||
| 119 | "Latest analysis issue count: {$prunedResults->getInputAnalysisResults()->getCount()}", |
||
| 120 | false |
||
| 121 | ); |
||
| 122 | |||
| 123 | OutputWriter::writeToStdError( |
||
| 124 | $output, |
||
| 125 | "Baseline issue count: {$prunedResults->getBaseLine()->getAnalysisResults()->getCount()}", |
||
| 126 | false |
||
| 127 | ); |
||
| 128 | |||
| 129 | OutputWriter::writeToStdError( |
||
| 130 | $output, |
||
| 131 | "Issue count with baseline removed: {$outputAnalysisResults->getCount()}", |
||
| 132 | !$outputAnalysisResults->hasNoIssues() |
||
| 133 | ); |
||
| 134 | |||
| 135 | $outputAsString = $outputFormatter->outputResults($outputAnalysisResults); |
||
| 136 | $output->writeln($outputAsString); |
||
| 137 | |||
| 138 | $returnCode = $outputAnalysisResults->hasNoIssues() ? 0 : 1; |
||
| 139 | |||
| 140 | if ($showRandomIssues && !$prunedResults->getInputAnalysisResults()->hasNoIssues()) { |
||
| 141 | $randomIssues = $this->randomResultsPicker->getRandomResultsToFix($prunedResults->getInputAnalysisResults()); |
||
| 142 | |||
| 143 | OutputWriter::writeToStdError( |
||
| 144 | $output, |
||
| 145 | "\n\nRandom {$randomIssues->getCount()} issues in the baseline to fix...", |
||
| 146 | false |
||
| 147 | ); |
||
| 148 | |||
| 149 | $outputAsString = $this->tableOutputFormatter->outputResults($randomIssues); |
||
| 150 | |||
| 151 | OutputWriter::writeToStdError( |
||
| 152 | $output, |
||
| 153 | $outputAsString, |
||
| 154 | false |
||
| 155 | ); |
||
| 156 | } |
||
| 157 | |||
| 158 | return $returnCode; |
||
| 159 | } catch (Throwable $throwable) { |
||
| 160 | $returnCode = ErrorReporter::reportError($output, $throwable); |
||
| 161 | |||
| 162 | return $returnCode; |
||
| 163 | } |
||
| 180 |