| Conditions | 17 |
| Paths | 260 |
| Total Lines | 58 |
| Code Lines | 36 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 121 | function __construct( $argv ) { |
||
| 122 | array_shift( $argv ); |
||
| 123 | $options = array(); |
||
| 124 | while ( list( $i, $arg ) = each( $argv ) ) { |
||
| 125 | try { |
||
| 126 | if ( strlen( $arg ) > 1 && $arg[0] === '-' && $arg[1] === '-' ) { |
||
| 127 | PHPUnit_Util_Getopt::parseLongOption( substr( $arg, 2 ), $this->longOptions, $options, $argv ); |
||
| 128 | } |
||
| 129 | } |
||
| 130 | catch ( PHPUnit_Framework_Exception $e ) { |
||
| 131 | // Enforcing recognized arguments or correctly formed arguments is |
||
| 132 | // not really the concern here. |
||
| 133 | continue; |
||
| 134 | } |
||
| 135 | } |
||
| 136 | |||
| 137 | $skipped_groups = array( |
||
| 138 | 'ajax' => true, |
||
| 139 | 'ms-files' => true, |
||
| 140 | 'external-http' => true, |
||
| 141 | ); |
||
| 142 | |||
| 143 | foreach ( $options as $option ) { |
||
| 144 | switch ( $option[0] ) { |
||
| 145 | case '--exclude-group' : |
||
| 146 | foreach ( $skipped_groups as $group_name => $skipped ) { |
||
| 147 | $skipped_groups[ $group_name ] = false; |
||
| 148 | } |
||
| 149 | continue 2; |
||
| 150 | case '--group' : |
||
| 151 | $groups = explode( ',', $option[1] ); |
||
| 152 | foreach ( $groups as $group ) { |
||
| 153 | if ( is_numeric( $group ) || preg_match( '/^(UT|Plugin)\d+$/', $group ) ) { |
||
| 154 | WP_UnitTestCase::forceTicket( $group ); |
||
| 155 | } |
||
| 156 | } |
||
| 157 | |||
| 158 | foreach ( $skipped_groups as $group_name => $skipped ) { |
||
| 159 | if ( in_array( $group_name, $groups ) ) { |
||
| 160 | $skipped_groups[ $group_name ] = false; |
||
| 161 | } |
||
| 162 | } |
||
| 163 | continue 2; |
||
| 164 | } |
||
| 165 | } |
||
| 166 | |||
| 167 | $skipped_groups = array_filter( $skipped_groups ); |
||
| 168 | foreach ( $skipped_groups as $group_name => $skipped ) { |
||
| 169 | echo sprintf( 'Not running %1$s tests. To execute these, use --group %1$s.', $group_name ) . PHP_EOL; |
||
| 170 | } |
||
| 171 | |||
| 172 | if ( ! isset( $skipped_groups['external-http'] ) ) { |
||
| 173 | echo PHP_EOL; |
||
| 174 | echo 'External HTTP skipped tests can be caused by timeouts.' . PHP_EOL; |
||
| 175 | echo 'If this changeset includes changes to HTTP, make sure there are no timeouts.' . PHP_EOL; |
||
| 176 | echo PHP_EOL; |
||
| 177 | } |
||
| 178 | } |
||
| 179 | } |
||
| 181 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.