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