| Conditions | 1 |
| Paths | 1 |
| Total Lines | 207 |
| 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 // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
||
| 112 | public function provideExecute() { |
||
| 113 | return array( |
||
| 114 | 'Normal interactive use' => array( |
||
| 115 | array(), |
||
| 116 | array(), |
||
| 117 | array( '', 'patch', 'fixed', '', 'Testing.' ), |
||
| 118 | 0, |
||
| 119 | "Significance: patch\nType: fixed\n\nTesting.\n", |
||
| 120 | ), |
||
| 121 | 'Normal interactive use with comment' => array( |
||
| 122 | array(), |
||
| 123 | array(), |
||
| 124 | array( '', 'patch', 'fixed', 'This is a comment', 'Testing.' ), |
||
| 125 | 0, |
||
| 126 | "Significance: patch\nType: fixed\nComment: This is a comment\n\nTesting.\n", |
||
| 127 | ), |
||
| 128 | 'Normal interactive use with empty entry' => array( |
||
| 129 | array(), |
||
| 130 | array(), |
||
| 131 | array( '', 'patch', 'fixed', '', '' ), |
||
| 132 | 0, |
||
| 133 | "Significance: patch\nType: fixed\n\n\n", |
||
| 134 | ), |
||
| 135 | 'Interactive use with command line defaults' => array( |
||
| 136 | array( |
||
| 137 | '--significance' => 'patch', |
||
| 138 | '--type' => 'fixed', |
||
| 139 | '--entry' => 'Testing.', |
||
| 140 | ), |
||
| 141 | array(), |
||
| 142 | array( '', '', '', '', '' ), |
||
| 143 | 0, |
||
| 144 | "Significance: patch\nType: fixed\n\nTesting.\n", |
||
| 145 | ), |
||
| 146 | 'Interactive use that runs into some errors' => array( |
||
| 147 | array(), |
||
| 148 | array(), |
||
| 149 | array( |
||
| 150 | '<bad filename>', |
||
| 151 | 'bad:filename?', |
||
| 152 | 'bad/|\\filename', |
||
| 153 | '.bad-ilename', |
||
| 154 | '', |
||
| 155 | 'extreme', |
||
| 156 | 'minor', |
||
| 157 | 'improved', |
||
| 158 | 'fixed', |
||
| 159 | '', |
||
| 160 | '', |
||
| 161 | 'Testing.', |
||
| 162 | ), |
||
| 163 | 0, |
||
| 164 | "Significance: minor\nType: fixed\n\nTesting.\n", |
||
| 165 | array( |
||
| 166 | '/Filename may not contain angle brackets/', |
||
| 167 | '/Filename may not contain colons or question marks/', |
||
| 168 | '/Filename may not contain slashes, backslashes, or pipes/', |
||
| 169 | '/Filename may not begin with a dot/', |
||
| 170 | '/Value "extreme" is invalid/', |
||
| 171 | '/Value "improved" is invalid/', |
||
| 172 | '/An empty changelog entry is only allowed when the significance is "patch"/', |
||
| 173 | ), |
||
| 174 | ), |
||
| 175 | |||
| 176 | 'Normal non-interactive use' => array( |
||
| 177 | array( |
||
| 178 | '--significance' => 'patch', |
||
| 179 | '--type' => 'fixed', |
||
| 180 | '--entry' => 'Testing.', |
||
| 181 | ), |
||
| 182 | array( 'interactive' => false ), |
||
| 183 | array(), |
||
| 184 | 0, |
||
| 185 | "Significance: patch\nType: fixed\n\nTesting.\n", |
||
| 186 | ), |
||
| 187 | 'Normal non-interactive use with comment' => array( |
||
| 188 | array( |
||
| 189 | '--significance' => 'patch', |
||
| 190 | '--type' => 'fixed', |
||
| 191 | '--comment' => 'This is a comment', |
||
| 192 | '--entry' => 'Testing.', |
||
| 193 | ), |
||
| 194 | array( 'interactive' => false ), |
||
| 195 | array(), |
||
| 196 | 0, |
||
| 197 | "Significance: patch\nType: fixed\nComment: This is a comment\n\nTesting.\n", |
||
| 198 | ), |
||
| 199 | 'Normal non-interactive use with empty entry' => array( |
||
| 200 | array( |
||
| 201 | '--significance' => 'patch', |
||
| 202 | '--type' => 'fixed', |
||
| 203 | '--entry' => '', |
||
| 204 | ), |
||
| 205 | array( 'interactive' => false ), |
||
| 206 | array(), |
||
| 207 | 0, |
||
| 208 | "Significance: patch\nType: fixed\n\n\n", |
||
| 209 | ), |
||
| 210 | 'Non-interactive use with empty filename' => array( |
||
| 211 | array( |
||
| 212 | '--filename' => '', |
||
| 213 | '--significance' => 'patch', |
||
| 214 | '--type' => 'fixed', |
||
| 215 | '--entry' => '', |
||
| 216 | ), |
||
| 217 | array( 'interactive' => false ), |
||
| 218 | array(), |
||
| 219 | 1, |
||
| 220 | null, |
||
| 221 | array( '/Filename may not be empty/' ), |
||
| 222 | ), |
||
| 223 | 'Non-interactive use with dot filename' => array( |
||
| 224 | array( |
||
| 225 | '--filename' => '.bad', |
||
| 226 | '--significance' => 'patch', |
||
| 227 | '--type' => 'fixed', |
||
| 228 | '--entry' => '', |
||
| 229 | ), |
||
| 230 | array( 'interactive' => false ), |
||
| 231 | array(), |
||
| 232 | 1, |
||
| 233 | null, |
||
| 234 | array( '/Filename may not begin with a dot/' ), |
||
| 235 | ), |
||
| 236 | 'Non-interactive use with missing significance' => array( |
||
| 237 | array( |
||
| 238 | '--type' => 'fixed', |
||
| 239 | '--entry' => 'Testing.', |
||
| 240 | ), |
||
| 241 | array( 'interactive' => false ), |
||
| 242 | array(), |
||
| 243 | 1, |
||
| 244 | null, |
||
| 245 | array( |
||
| 246 | '/Significance must be specified in non-interactive mode/', |
||
| 247 | ), |
||
| 248 | ), |
||
| 249 | 'Non-interactive use with invalid significance' => array( |
||
| 250 | array( |
||
| 251 | '--significance' => 'bogus', |
||
| 252 | '--type' => 'fixed', |
||
| 253 | '--entry' => 'Testing.', |
||
| 254 | ), |
||
| 255 | array( 'interactive' => false ), |
||
| 256 | array(), |
||
| 257 | 1, |
||
| 258 | null, |
||
| 259 | array( |
||
| 260 | '/Significance value "bogus" is not valid/', |
||
| 261 | ), |
||
| 262 | ), |
||
| 263 | 'Non-interactive use with missing type' => array( |
||
| 264 | array( |
||
| 265 | '--significance' => 'patch', |
||
| 266 | '--entry' => 'Testing.', |
||
| 267 | ), |
||
| 268 | array( 'interactive' => false ), |
||
| 269 | array(), |
||
| 270 | 1, |
||
| 271 | null, |
||
| 272 | array( |
||
| 273 | '/Type must be specified in non-interactive mode/', |
||
| 274 | ), |
||
| 275 | ), |
||
| 276 | 'Non-interactive use with invalid type' => array( |
||
| 277 | array( |
||
| 278 | '--significance' => 'patch', |
||
| 279 | '--type' => 'bogus', |
||
| 280 | '--entry' => 'Testing.', |
||
| 281 | ), |
||
| 282 | array( 'interactive' => false ), |
||
| 283 | array(), |
||
| 284 | 1, |
||
| 285 | null, |
||
| 286 | array( |
||
| 287 | '/Type "bogus" is not valid/', |
||
| 288 | ), |
||
| 289 | ), |
||
| 290 | 'Non-interactive use with missing entry' => array( |
||
| 291 | array( |
||
| 292 | '--significance' => 'patch', |
||
| 293 | '--type' => 'fixed', |
||
| 294 | ), |
||
| 295 | array( 'interactive' => false ), |
||
| 296 | array(), |
||
| 297 | 1, |
||
| 298 | null, |
||
| 299 | array( |
||
| 300 | '/Entry must be specified in non-interactive mode/', |
||
| 301 | ), |
||
| 302 | ), |
||
| 303 | 'Non-interactive use with invalid entry' => array( |
||
| 304 | array( |
||
| 305 | '--significance' => 'minor', |
||
| 306 | '--type' => 'fixed', |
||
| 307 | '--entry' => '', |
||
| 308 | ), |
||
| 309 | array( 'interactive' => false ), |
||
| 310 | array(), |
||
| 311 | 1, |
||
| 312 | null, |
||
| 313 | array( |
||
| 314 | '/An empty changelog entry is only allowed when the significance is "patch"/', |
||
| 315 | ), |
||
| 316 | ), |
||
| 317 | ); |
||
| 318 | } |
||
| 319 | |||
| 321 |
This check looks for function calls that miss required arguments.