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