Conditions | 17 |
Paths | > 20000 |
Total Lines | 246 |
Code Lines | 184 |
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 |
||
51 | final public function testEmptyElementIfIsReference() |
||
52 | { |
||
53 | /** @var FileSet $f */ |
||
54 | $f = $this->getInstance(); |
||
55 | $f->setIncludes("**/*.php"); |
||
56 | try { |
||
57 | $f->setRefid(new Reference($this->getProject(), "dummyref")); |
||
58 | $this->fail( |
||
59 | "Can add reference to " |
||
60 | . $f |
||
61 | . " with elements from setIncludes" |
||
62 | ); |
||
63 | } catch (BuildException $be) { |
||
64 | $this->assertEquals( |
||
65 | "You must not specify more than one attribute " |
||
66 | . "when using refid", |
||
67 | $be->getMessage() |
||
68 | ); |
||
69 | } |
||
70 | |||
71 | $f = $this->getInstance(); |
||
72 | $f->createPatternSet(); |
||
73 | try { |
||
74 | $f->setRefid(new Reference($this->getProject(), "dummyref")); |
||
75 | $this->fail( |
||
76 | "Can add reference to " |
||
77 | . $f |
||
78 | . " with nested patternset element." |
||
79 | ); |
||
80 | } catch (BuildException $be) { |
||
81 | $this->assertEquals( |
||
82 | "You must not specify nested elements when " |
||
83 | . "using refid", |
||
84 | $be->getMessage() |
||
85 | ); |
||
86 | } |
||
87 | |||
88 | $f = $this->getInstance(); |
||
89 | $f->createInclude(); |
||
90 | try { |
||
91 | $f->setRefid(new Reference($this->getProject(), "dummyref")); |
||
92 | $this->fail( |
||
93 | "Can add reference to " |
||
94 | . $f |
||
95 | . " with nested include element." |
||
96 | ); |
||
97 | } catch (BuildException $be) { |
||
98 | $this->assertEquals( |
||
99 | "You must not specify more than one attribute " |
||
100 | . "when using refid", |
||
101 | $be->getMessage() |
||
102 | ); |
||
103 | } |
||
104 | |||
105 | $f = $this->getInstance(); |
||
106 | $f->setRefid(new Reference($this->getProject(), "dummyref")); |
||
107 | try { |
||
108 | $f->setIncludes("**/*.java"); |
||
109 | $this->fail( |
||
110 | "Can set includes in " |
||
111 | . $f |
||
112 | . " that is a reference." |
||
113 | ); |
||
114 | } catch (BuildException $be) { |
||
115 | $this->assertEquals( |
||
116 | "You must not specify more than one attribute " |
||
117 | . "when using refid", |
||
118 | $be->getMessage() |
||
119 | ); |
||
120 | } |
||
121 | |||
122 | try { |
||
123 | $f->setIncludesfile(new File("/a")); |
||
124 | $this->fail( |
||
125 | "Can set includesfile in " |
||
126 | . $f |
||
127 | . " that is a reference." |
||
128 | ); |
||
129 | } catch (BuildException $be) { |
||
130 | $this->assertEquals( |
||
131 | "You must not specify more than one attribute " |
||
132 | . "when using refid", |
||
133 | $be->getMessage() |
||
134 | ); |
||
135 | } |
||
136 | |||
137 | try { |
||
138 | $f->setExcludes("**/*.java"); |
||
139 | $this->fail( |
||
140 | "Can set excludes in " |
||
141 | . $f |
||
142 | . " that is a reference." |
||
143 | ); |
||
144 | } catch (BuildException $be) { |
||
145 | $this->assertEquals( |
||
146 | "You must not specify more than one attribute " |
||
147 | . "when using refid", |
||
148 | $be->getMessage() |
||
149 | ); |
||
150 | } |
||
151 | |||
152 | try { |
||
153 | $f->setExcludesfile(new File("/a")); |
||
154 | $this->fail( |
||
155 | "Can set excludesfile in " |
||
156 | . $f |
||
157 | . " that is a reference." |
||
158 | ); |
||
159 | } catch (BuildException $be) { |
||
160 | $this->assertEquals( |
||
161 | "You must not specify more than one attribute " |
||
162 | . "when using refid", |
||
163 | $be->getMessage() |
||
164 | ); |
||
165 | } |
||
166 | |||
167 | try { |
||
168 | $f->setDir($this->project->resolveFile(".")); |
||
169 | $this->fail( |
||
170 | "Can set dir in " |
||
171 | . $f |
||
172 | . " that is a reference." |
||
173 | ); |
||
174 | } catch (BuildException $be) { |
||
175 | $this->assertEquals( |
||
176 | "You must not specify more than one attribute " |
||
177 | . "when using refid", |
||
178 | $be->getMessage() |
||
179 | ); |
||
180 | } |
||
181 | |||
182 | try { |
||
183 | $f->setExpandSymbolicLinks(true); |
||
184 | $this->fail( |
||
185 | "Can expand symbolic links in " |
||
186 | . $f |
||
187 | . " that is a reference." |
||
188 | ); |
||
189 | } catch (BuildException $be) { |
||
190 | $this->assertEquals( |
||
191 | "You must not specify more than one attribute " |
||
192 | . "when using refid", |
||
193 | $be->getMessage() |
||
194 | ); |
||
195 | } |
||
196 | |||
197 | try { |
||
198 | $f->setFile($this->project->resolveFile(__FILE__)); |
||
199 | $this->fail( |
||
200 | "Can set file in " |
||
201 | . $f |
||
202 | . " that is a reference." |
||
203 | ); |
||
204 | } catch (BuildException $be) { |
||
205 | $this->assertEquals( |
||
206 | "You must not specify more than one attribute " |
||
207 | . "when using refid", |
||
208 | $be->getMessage() |
||
209 | ); |
||
210 | } |
||
211 | |||
212 | try { |
||
213 | $f->setCaseSensitive(true); |
||
214 | $this->fail( |
||
215 | "Can set case sensitive in " |
||
216 | . $f |
||
217 | . " that is a reference." |
||
218 | ); |
||
219 | } catch (BuildException $be) { |
||
220 | $this->assertEquals( |
||
221 | "You must not specify more than one attribute " |
||
222 | . "when using refid", |
||
223 | $be->getMessage() |
||
224 | ); |
||
225 | } |
||
226 | |||
227 | try { |
||
228 | $f->createInclude(); |
||
229 | $this->fail( |
||
230 | "Can add nested include in " |
||
231 | . $f |
||
232 | . " that is a reference." |
||
233 | ); |
||
234 | } catch (BuildException $be) { |
||
235 | $this->assertEquals( |
||
236 | "You must not specify nested elements when using " |
||
237 | . "refid", |
||
238 | $be->getMessage() |
||
239 | ); |
||
240 | } |
||
241 | |||
242 | try { |
||
243 | $f->createExclude(); |
||
244 | $this->fail( |
||
245 | "Can add nested exclude in " |
||
246 | . $f |
||
247 | . " that is a reference." |
||
248 | ); |
||
249 | } catch (BuildException $be) { |
||
250 | $this->assertEquals( |
||
251 | "You must not specify nested elements when using " |
||
252 | . "refid", |
||
253 | $be->getMessage() |
||
254 | ); |
||
255 | } |
||
256 | |||
257 | try { |
||
258 | $f->createIncludesFile(); |
||
259 | $this->fail( |
||
260 | "Can add nested includesfile in " |
||
261 | . $f |
||
262 | . " that is a reference." |
||
263 | ); |
||
264 | } catch (BuildException $be) { |
||
265 | $this->assertEquals( |
||
266 | "You must not specify nested elements when using " |
||
267 | . "refid", |
||
268 | $be->getMessage() |
||
269 | ); |
||
270 | } |
||
271 | try { |
||
272 | $f->createExcludesFile(); |
||
273 | $this->fail( |
||
274 | "Can add nested excludesfile in " |
||
275 | . $f |
||
276 | . " that is a reference." |
||
277 | ); |
||
278 | } catch (BuildException $be) { |
||
279 | $this->assertEquals( |
||
280 | "You must not specify nested elements when using " |
||
281 | . "refid", |
||
282 | $be->getMessage() |
||
283 | ); |
||
284 | } |
||
285 | try { |
||
286 | $f->createPatternSet(); |
||
287 | $this->fail( |
||
288 | "Can add nested patternset in " |
||
289 | . $f |
||
290 | . " that is a reference." |
||
291 | ); |
||
292 | } catch (BuildException $be) { |
||
293 | $this->assertEquals( |
||
294 | "You must not specify nested elements when using " |
||
295 | . "refid", |
||
296 | $be->getMessage() |
||
297 | ); |
||
301 |