| Conditions | 14 |
| Paths | 864 |
| Total Lines | 91 |
| Code Lines | 57 |
| 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 |
||
| 41 | function getQueryInfo() { |
||
| 42 | $conds = []; |
||
| 43 | $conds['rc_new'] = 1; |
||
| 44 | |||
| 45 | $namespace = $this->opts->getValue( 'namespace' ); |
||
| 46 | $namespace = ( $namespace === 'all' ) ? false : intval( $namespace ); |
||
| 47 | |||
| 48 | $username = $this->opts->getValue( 'username' ); |
||
| 49 | $user = Title::makeTitleSafe( NS_USER, $username ); |
||
| 50 | |||
| 51 | $size = abs( intval( $this->opts->getValue( 'size' ) ) ); |
||
| 52 | if ( $size > 0 ) { |
||
| 53 | if ( $this->opts->getValue( 'size-mode' ) === 'max' ) { |
||
| 54 | $conds[] = 'page_len <= ' . $size; |
||
| 55 | } else { |
||
| 56 | $conds[] = 'page_len >= ' . $size; |
||
| 57 | } |
||
| 58 | } |
||
| 59 | |||
| 60 | $rcIndexes = []; |
||
| 61 | |||
| 62 | if ( $namespace !== false ) { |
||
| 63 | if ( $this->opts->getValue( 'invert' ) ) { |
||
| 64 | $conds[] = 'rc_namespace != ' . $this->mDb->addQuotes( $namespace ); |
||
| 65 | } else { |
||
| 66 | $conds['rc_namespace'] = $namespace; |
||
| 67 | } |
||
| 68 | } |
||
| 69 | |||
| 70 | if ( $user ) { |
||
| 71 | $conds['rc_user_text'] = $user->getText(); |
||
| 72 | $rcIndexes = 'rc_user_text'; |
||
| 73 | } elseif ( User::groupHasPermission( '*', 'createpage' ) && |
||
| 74 | $this->opts->getValue( 'hideliu' ) |
||
| 75 | ) { |
||
| 76 | # If anons cannot make new pages, don't "exclude logged in users"! |
||
| 77 | $conds['rc_user'] = 0; |
||
| 78 | } |
||
| 79 | |||
| 80 | # If this user cannot see patrolled edits or they are off, don't do dumb queries! |
||
| 81 | if ( $this->opts->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) { |
||
| 82 | $conds['rc_patrolled'] = 0; |
||
| 83 | } |
||
| 84 | |||
| 85 | if ( $this->opts->getValue( 'hidebots' ) ) { |
||
| 86 | $conds['rc_bot'] = 0; |
||
| 87 | } |
||
| 88 | |||
| 89 | if ( $this->opts->getValue( 'hideredirs' ) ) { |
||
| 90 | $conds['page_is_redirect'] = 0; |
||
| 91 | } |
||
| 92 | |||
| 93 | // Allow changes to the New Pages query |
||
| 94 | $tables = [ 'recentchanges', 'page' ]; |
||
| 95 | $fields = [ |
||
| 96 | 'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user', 'rc_user_text', |
||
| 97 | 'rc_comment', 'rc_timestamp', 'rc_patrolled', 'rc_id', 'rc_deleted', |
||
| 98 | 'length' => 'page_len', 'rev_id' => 'page_latest', 'rc_this_oldid', |
||
| 99 | 'page_namespace', 'page_title' |
||
| 100 | ]; |
||
| 101 | $join_conds = [ 'page' => [ 'INNER JOIN', 'page_id=rc_cur_id' ] ]; |
||
| 102 | |||
| 103 | Hooks::run( 'SpecialNewpagesConditions', |
||
| 104 | [ &$this, $this->opts, &$conds, &$tables, &$fields, &$join_conds ] ); |
||
| 105 | |||
| 106 | $options = []; |
||
| 107 | |||
| 108 | if ( $rcIndexes ) { |
||
| 109 | $options = [ 'USE INDEX' => [ 'recentchanges' => $rcIndexes ] ]; |
||
| 110 | } |
||
| 111 | |||
| 112 | $info = [ |
||
| 113 | 'tables' => $tables, |
||
| 114 | 'fields' => $fields, |
||
| 115 | 'conds' => $conds, |
||
| 116 | 'options' => $options, |
||
| 117 | 'join_conds' => $join_conds |
||
| 118 | ]; |
||
| 119 | |||
| 120 | // Modify query for tags |
||
| 121 | ChangeTags::modifyDisplayQuery( |
||
| 122 | $info['tables'], |
||
| 123 | $info['fields'], |
||
| 124 | $info['conds'], |
||
| 125 | $info['join_conds'], |
||
| 126 | $info['options'], |
||
| 127 | $this->opts['tagfilter'] |
||
| 128 | ); |
||
| 129 | |||
| 130 | return $info; |
||
| 131 | } |
||
| 132 | |||
| 158 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.