Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
9 | class AdapterTest extends TestCase |
||
10 | { |
||
11 | public function Provider() |
||
30 | |||
31 | /** |
||
32 | * @dataProvider Provider |
||
33 | */ |
||
34 | public function testWrite($adapter) |
||
39 | |||
40 | /** |
||
41 | * @dataProvider Provider |
||
42 | * @expectedException \Freyo\Flysystem\QcloudCOSv3\Exceptions\RuntimeException |
||
43 | */ |
||
44 | View Code Duplication | public function testWriteStream($adapter) |
|
56 | |||
57 | /** |
||
58 | * @dataProvider Provider |
||
59 | */ |
||
60 | public function testUpdate($adapter) |
||
65 | |||
66 | /** |
||
67 | * @dataProvider Provider |
||
68 | * @expectedException \Freyo\Flysystem\QcloudCOSv3\Exceptions\RuntimeException |
||
69 | */ |
||
70 | View Code Duplication | public function testUpdateStream($adapter) |
|
82 | |||
83 | /** |
||
84 | * @dataProvider Provider |
||
85 | * @expectedException \Freyo\Flysystem\QcloudCOSv3\Exceptions\RuntimeException |
||
86 | */ |
||
87 | public function testRename($adapter) |
||
92 | |||
93 | /** |
||
94 | * @dataProvider Provider |
||
95 | */ |
||
96 | public function testCopy($adapter) |
||
101 | |||
102 | /** |
||
103 | * @dataProvider Provider |
||
104 | * @expectedException \Freyo\Flysystem\QcloudCOSv3\Exceptions\RuntimeException |
||
105 | */ |
||
106 | public function testDelete($adapter) |
||
111 | |||
112 | /** |
||
113 | * @dataProvider Provider |
||
114 | * @expectedException \Freyo\Flysystem\QcloudCOSv3\Exceptions\RuntimeException |
||
115 | */ |
||
116 | public function testCreateDir($adapter) |
||
121 | |||
122 | /** |
||
123 | * @dataProvider Provider |
||
124 | * @expectedException \Freyo\Flysystem\QcloudCOSv3\Exceptions\RuntimeException |
||
125 | */ |
||
126 | public function testDeleteDir($adapter) |
||
131 | |||
132 | /** |
||
133 | * @dataProvider Provider |
||
134 | * @expectedException \Freyo\Flysystem\QcloudCOSv3\Exceptions\RuntimeException |
||
135 | */ |
||
136 | public function testSetVisibility($adapter) |
||
140 | |||
141 | /** |
||
142 | * @dataProvider Provider |
||
143 | */ |
||
144 | public function testHas($adapter) |
||
149 | |||
150 | /** |
||
151 | * @dataProvider Provider |
||
152 | */ |
||
153 | public function testRead($adapter) |
||
157 | |||
158 | /** |
||
159 | * @dataProvider Provider |
||
160 | */ |
||
161 | public function testGetUrl($adapter, $config) |
||
168 | |||
169 | /** |
||
170 | * @dataProvider Provider |
||
171 | */ |
||
172 | public function testReadStream($adapter) |
||
179 | |||
180 | /** |
||
181 | * @dataProvider Provider |
||
182 | * @expectedException \Freyo\Flysystem\QcloudCOSv3\Exceptions\RuntimeException |
||
183 | */ |
||
184 | public function testListContents($adapter) |
||
188 | |||
189 | /** |
||
190 | * @dataProvider Provider |
||
191 | * @expectedException \Freyo\Flysystem\QcloudCOSv3\Exceptions\RuntimeException |
||
192 | */ |
||
193 | public function testGetMetadata($adapter) |
||
197 | |||
198 | /** |
||
199 | * @dataProvider Provider |
||
200 | * @expectedException \Freyo\Flysystem\QcloudCOSv3\Exceptions\RuntimeException |
||
201 | */ |
||
202 | public function testGetSize($adapter) |
||
206 | |||
207 | /** |
||
208 | * @dataProvider Provider |
||
209 | * @expectedException \Freyo\Flysystem\QcloudCOSv3\Exceptions\RuntimeException |
||
210 | */ |
||
211 | public function testGetMimetype($adapter) |
||
215 | |||
216 | /** |
||
217 | * @dataProvider Provider |
||
218 | * @expectedException \Freyo\Flysystem\QcloudCOSv3\Exceptions\RuntimeException |
||
219 | */ |
||
220 | public function testGetTimestamp($adapter) |
||
224 | |||
225 | /** |
||
226 | * @dataProvider Provider |
||
227 | * @expectedException \Freyo\Flysystem\QcloudCOSv3\Exceptions\RuntimeException |
||
228 | */ |
||
229 | public function testGetVisibility($adapter) |
||
233 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.