| Conditions | 1 |
| Paths | 1 |
| Total Lines | 58 |
| Code Lines | 38 |
| 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 |
||
| 45 | public function testConversionFromString(): void |
||
| 46 | { |
||
| 47 | $analysisResults = $this->phpCodeSnifferJsonResultsParser->convertFromString($this->fileContents, |
||
| 48 | $this->projectRoot); |
||
| 49 | |||
| 50 | $this->assertCount(6, $analysisResults->getAnalysisResults()); |
||
| 51 | |||
| 52 | $result1 = $analysisResults->getAnalysisResults()[0]; |
||
| 53 | $result2 = $analysisResults->getAnalysisResults()[1]; |
||
| 54 | $result3 = $analysisResults->getAnalysisResults()[2]; |
||
| 55 | $result4 = $analysisResults->getAnalysisResults()[3]; |
||
| 56 | $result5 = $analysisResults->getAnalysisResults()[4]; |
||
| 57 | $result6 = $analysisResults->getAnalysisResults()[5]; |
||
| 58 | |||
| 59 | $this->assertMatch($result1, |
||
| 60 | 'src/Domain/BaseLiner/BaseLineImporter.php', |
||
| 61 | 8, |
||
| 62 | 'Generic.Files.LineLength.TooLong', |
||
| 63 | Severity::warning(), |
||
| 64 | ); |
||
| 65 | |||
| 66 | $this->assertMatch($result2, |
||
| 67 | 'src/Domain/BaseLiner/BaseLineImporter.php', |
||
| 68 | 52, |
||
| 69 | 'Squiz.WhiteSpace.FunctionSpacing.Before', |
||
| 70 | Severity::error(), |
||
| 71 | ); |
||
| 72 | |||
| 73 | $this->assertMatch($result3, |
||
| 74 | 'src/Domain/Common/InvalidPathException.php', |
||
| 75 | 2, |
||
| 76 | 'Squiz.Commenting.FileComment.Missing', |
||
| 77 | Severity::error(), |
||
| 78 | ); |
||
| 79 | $this->assertSame( |
||
| 80 | 'Missing file doc comment', |
||
| 81 | $result3->getMessage(), |
||
| 82 | ); |
||
| 83 | |||
| 84 | $this->assertMatch($result4, |
||
| 85 | 'src/Domain/Common/InvalidPathException.php', |
||
| 86 | 7, |
||
| 87 | 'Squiz.Commenting.ClassComment.Missing', |
||
| 88 | Severity::error(), |
||
| 89 | ); |
||
| 90 | |||
| 91 | $this->assertMatch($result5, |
||
| 92 | 'src/Domain/Common/InvalidPathException.php', |
||
| 93 | 9, |
||
| 94 | 'Squiz.Commenting.FunctionComment.Missing', |
||
| 95 | Severity::error(), |
||
| 96 | ); |
||
| 97 | |||
| 98 | $this->assertMatch($result6, |
||
| 99 | 'src/Domain/Common/InvalidPathException.php', |
||
| 100 | 11, |
||
| 101 | 'Generic.Files.LineLength.TooLong', |
||
| 102 | Severity::warning(), |
||
| 103 | ); |
||
| 144 |