Conditions | 1 |
Paths | 1 |
Total Lines | 132 |
Code Lines | 55 |
Lines | 132 |
Ratio | 100 % |
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 |
||
33 | View Code Duplication | public function commitDataProvider() : array |
|
34 | { |
||
35 | $packageName = uniqid('packageName', true); |
||
36 | $package = $this->createMock(PackageInterface::class); |
||
37 | |||
38 | $package->expects(self::any())->method('getName')->willReturn($packageName); |
||
39 | |||
40 | return [ |
||
41 | 'empty' => [ |
||
42 | $package, |
||
43 | '', |
||
44 | 0, |
||
45 | '', |
||
46 | false, |
||
47 | <<<'READABLE' |
||
48 | [NOT SIGNED] [NOT VERIFIED] |
||
49 | Command: |
||
50 | Exit code: 0 |
||
51 | Output: |
||
52 | READABLE |
||
53 | ], |
||
54 | 'not signed' => [ |
||
55 | $package, |
||
56 | 'git verify-commit --verbose HEAD', |
||
57 | 1, |
||
58 | '', |
||
59 | false, |
||
60 | <<<'READABLE' |
||
61 | [NOT SIGNED] [NOT VERIFIED] |
||
62 | Command: git verify-commit --verbose HEAD |
||
63 | Exit code: 1 |
||
64 | Output: |
||
65 | READABLE |
||
66 | ], |
||
67 | 'signed, no key' => [ |
||
68 | $package, |
||
69 | 'git verify-commit --verbose HEAD', |
||
70 | 1, |
||
71 | <<<'OUTPUT' |
||
72 | tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 |
||
73 | author Mr. Magoo <[email protected]> 1495040303 +0200 |
||
74 | committer Mr. Magoo <[email protected]> 1495040303 +0200 |
||
75 | |||
76 | signed commit |
||
77 | gpg: Signature made Mi 17 Mai 2017 18:58:23 CEST |
||
78 | gpg: using RSA key ECFE352F73409A6E |
||
79 | gpg: Can't check signature: No public key |
||
80 | OUTPUT |
||
81 | , |
||
82 | false, |
||
83 | <<<'READABLE' |
||
84 | [SIGNED] [NOT VERIFIED] Commit #4b825dc642cb6eb9a060e54bf8d69288fbee4904 (Key ECFE352F73409A6E) |
||
85 | Command: git verify-commit --verbose HEAD |
||
86 | Exit code: 1 |
||
87 | Output: tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 |
||
88 | author Mr. Magoo <[email protected]> 1495040303 +0200 |
||
89 | committer Mr. Magoo <[email protected]> 1495040303 +0200 |
||
90 | |||
91 | signed commit |
||
92 | gpg: Signature made Mi 17 Mai 2017 18:58:23 CEST |
||
93 | gpg: using RSA key ECFE352F73409A6E |
||
94 | gpg: Can't check signature: No public key |
||
95 | READABLE |
||
96 | ], |
||
97 | 'signed, key not trusted' => [ |
||
98 | $package, |
||
99 | 'git verify-commit --verbose HEAD', |
||
100 | 0, |
||
101 | <<<'OUTPUT' |
||
102 | tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 |
||
103 | author Mr. Magoo <[email protected]> 1495041438 +0200 |
||
104 | committer Mr. Magoo <[email protected]> 1495041438 +0200 |
||
105 | |||
106 | signed commit |
||
107 | gpg: Signature made Mi 17 Mai 2017 19:17:18 CEST |
||
108 | gpg: using RSA key 3CD2E574BC4207C7 |
||
109 | gpg: Good signature from "Mr. Magoo <[email protected]>" [unknown] |
||
110 | gpg: WARNING: This key is not certified with a trusted signature! |
||
111 | gpg: There is no indication that the signature belongs to the owner. |
||
112 | Primary key fingerprint: AA0E 63DC BC06 F864 F53E F630 3CD2 E574 BC42 07C7 |
||
113 | OUTPUT |
||
114 | , |
||
115 | false, |
||
116 | <<<'READABLE' |
||
117 | [SIGNED] [NOT VERIFIED] Commit #4b825dc642cb6eb9a060e54bf8d69288fbee4904 By "Mr. Magoo <[email protected]>" (Key 3CD2E574BC4207C7) |
||
118 | Command: git verify-commit --verbose HEAD |
||
119 | Exit code: 0 |
||
120 | Output: tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 |
||
121 | author Mr. Magoo <[email protected]> 1495041438 +0200 |
||
122 | committer Mr. Magoo <[email protected]> 1495041438 +0200 |
||
123 | |||
124 | signed commit |
||
125 | gpg: Signature made Mi 17 Mai 2017 19:17:18 CEST |
||
126 | gpg: using RSA key 3CD2E574BC4207C7 |
||
127 | gpg: Good signature from "Mr. Magoo <[email protected]>" [unknown] |
||
128 | gpg: WARNING: This key is not certified with a trusted signature! |
||
129 | gpg: There is no indication that the signature belongs to the owner. |
||
130 | Primary key fingerprint: AA0E 63DC BC06 F864 F53E F630 3CD2 E574 BC42 07C7 |
||
131 | READABLE |
||
132 | ], |
||
133 | [ |
||
134 | $package, |
||
135 | 'git verify-commit --verbose HEAD', |
||
136 | 0, |
||
137 | <<<'OUTPUT' |
||
138 | tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 |
||
139 | author Mr. Magoo <[email protected]> 1495041602 +0200 |
||
140 | committer Mr. Magoo <[email protected]> 1495041602 +0200 |
||
141 | |||
142 | signed commit |
||
143 | gpg: Signature made Mi 17 Mai 2017 19:20:02 CEST |
||
144 | gpg: using RSA key 4889C20D148231DC |
||
145 | gpg: Good signature from "Mr. Magoo <[email protected]>" [full] |
||
146 | OUTPUT |
||
147 | , |
||
148 | true, |
||
149 | <<<'READABLE' |
||
150 | [SIGNED] [VERIFIED] Commit #4b825dc642cb6eb9a060e54bf8d69288fbee4904 By "Mr. Magoo <[email protected]>" (Key 4889C20D148231DC) |
||
151 | Command: git verify-commit --verbose HEAD |
||
152 | Exit code: 0 |
||
153 | Output: tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 |
||
154 | author Mr. Magoo <[email protected]> 1495041602 +0200 |
||
155 | committer Mr. Magoo <[email protected]> 1495041602 +0200 |
||
156 | |||
157 | signed commit |
||
158 | gpg: Signature made Mi 17 Mai 2017 19:20:02 CEST |
||
159 | gpg: using RSA key 4889C20D148231DC |
||
160 | gpg: Good signature from "Mr. Magoo <[email protected]>" [full] |
||
161 | READABLE |
||
162 | ], |
||
163 | ]; |
||
164 | } |
||
165 | |||
330 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.