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