| Conditions | 37 | 
| Paths | > 20000 | 
| Total Lines | 157 | 
| Code Lines | 103 | 
| Lines | 0 | 
| Ratio | 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  | 
            ||
| 108 | function check(){ | 
            ||
| 109 | global $conf;  | 
            ||
| 110 | global $INFO;  | 
            ||
| 111 | /* @var Input $INPUT */  | 
            ||
| 112 | global $INPUT;  | 
            ||
| 113 | |||
| 114 |     if ($INFO['isadmin'] || $INFO['ismanager']){ | 
            ||
| 115 |         msg('DokuWiki version: '.getVersion(),1); | 
            ||
| 116 | |||
| 117 |         if(version_compare(phpversion(),'5.3.3','<')){ | 
            ||
| 118 |             msg('Your PHP version is too old ('.phpversion().' vs. 5.3.3+ needed)',-1); | 
            ||
| 119 |         }else{ | 
            ||
| 120 |             msg('PHP version '.phpversion(),1); | 
            ||
| 121 | }  | 
            ||
| 122 |     } else { | 
            ||
| 123 |         if(version_compare(phpversion(),'5.3.3','<')){ | 
            ||
| 124 |             msg('Your PHP version is too old',-1); | 
            ||
| 125 | }  | 
            ||
| 126 | }  | 
            ||
| 127 | |||
| 128 |     $mem = (int) php_to_byte(ini_get('memory_limit')); | 
            ||
| 129 |     if($mem){ | 
            ||
| 130 |         if($mem < 16777216){ | 
            ||
| 131 |             msg('PHP is limited to less than 16MB RAM ('.$mem.' bytes). Increase memory_limit in php.ini',-1); | 
            ||
| 132 |         }elseif($mem < 20971520){ | 
            ||
| 133 |             msg('PHP is limited to less than 20MB RAM ('.$mem.' bytes), you might encounter problems with bigger pages. Increase memory_limit in php.ini',-1); | 
            ||
| 134 |         }elseif($mem < 33554432){ | 
            ||
| 135 |             msg('PHP is limited to less than 32MB RAM ('.$mem.' bytes), but that should be enough in most cases. If not, increase memory_limit in php.ini',0); | 
            ||
| 136 |         }else{ | 
            ||
| 137 |             msg('More than 32MB RAM ('.$mem.' bytes) available.',1); | 
            ||
| 138 | }  | 
            ||
| 139 | }  | 
            ||
| 140 | |||
| 141 |     if(is_writable($conf['changelog'])){ | 
            ||
| 142 |         msg('Changelog is writable',1); | 
            ||
| 143 |     }else{ | 
            ||
| 144 |         if (file_exists($conf['changelog'])) { | 
            ||
| 145 |             msg('Changelog is not writable',-1); | 
            ||
| 146 | }  | 
            ||
| 147 | }  | 
            ||
| 148 | |||
| 149 |     if (isset($conf['changelog_old']) && file_exists($conf['changelog_old'])) { | 
            ||
| 150 |         msg('Old changelog exists', 0); | 
            ||
| 151 | }  | 
            ||
| 152 | |||
| 153 |     if (file_exists($conf['changelog'].'_failed')) { | 
            ||
| 154 |         msg('Importing old changelog failed', -1); | 
            ||
| 155 |     } else if (file_exists($conf['changelog'].'_importing')) { | 
            ||
| 156 |         msg('Importing old changelog now.', 0); | 
            ||
| 157 |     } else if (file_exists($conf['changelog'].'_import_ok')) { | 
            ||
| 158 |         msg('Old changelog imported', 1); | 
            ||
| 159 |         if (!plugin_isdisabled('importoldchangelog')) { | 
            ||
| 160 |             msg('Importoldchangelog plugin not disabled after import', -1); | 
            ||
| 161 | }  | 
            ||
| 162 | }  | 
            ||
| 163 | |||
| 164 |     if(is_writable(DOKU_CONF)){ | 
            ||
| 165 |         msg('conf directory is writable',1); | 
            ||
| 166 |     }else{ | 
            ||
| 167 |         msg('conf directory is not writable',-1); | 
            ||
| 168 | }  | 
            ||
| 169 | |||
| 170 |     if($conf['authtype'] == 'plain'){ | 
            ||
| 171 | global $config_cascade;  | 
            ||
| 172 |         if(is_writable($config_cascade['plainauth.users']['default'])){ | 
            ||
| 173 |             msg('conf/users.auth.php is writable',1); | 
            ||
| 174 |         }else{ | 
            ||
| 175 |             msg('conf/users.auth.php is not writable',0); | 
            ||
| 176 | }  | 
            ||
| 177 | }  | 
            ||
| 178 | |||
| 179 |     if(function_exists('mb_strpos')){ | 
            ||
| 180 |         if(defined('UTF8_NOMBSTRING')){ | 
            ||
| 181 |             msg('mb_string extension is available but will not be used',0); | 
            ||
| 182 |         }else{ | 
            ||
| 183 |             msg('mb_string extension is available and will be used',1); | 
            ||
| 184 |             if(ini_get('mbstring.func_overload') != 0){ | 
            ||
| 185 |                 msg('mb_string function overloading is enabled, this will cause problems and should be disabled',-1); | 
            ||
| 186 | }  | 
            ||
| 187 | }  | 
            ||
| 188 |     }else{ | 
            ||
| 189 |         msg('mb_string extension not available - PHP only replacements will be used',0); | 
            ||
| 190 | }  | 
            ||
| 191 | |||
| 192 |     if (!UTF8_PREGSUPPORT) { | 
            ||
| 193 |         msg('PHP is missing UTF-8 support in Perl-Compatible Regular Expressions (PCRE)', -1); | 
            ||
| 194 | }  | 
            ||
| 195 |     if (!UTF8_PROPERTYSUPPORT) { | 
            ||
| 196 |         msg('PHP is missing Unicode properties support in Perl-Compatible Regular Expressions (PCRE)', -1); | 
            ||
| 197 | }  | 
            ||
| 198 | |||
| 199 | $loc = setlocale(LC_ALL, 0);  | 
            ||
| 200 |     if(!$loc){ | 
            ||
| 201 |         msg('No valid locale is set for your PHP setup. You should fix this',-1); | 
            ||
| 202 |     }elseif(stripos($loc,'utf') === false){ | 
            ||
| 203 |         msg('Your locale <code>'.hsc($loc).'</code> seems not to be a UTF-8 locale, you should fix this if you encounter problems.',0); | 
            ||
| 204 |     }else{ | 
            ||
| 205 |         msg('Valid locale '.hsc($loc).' found.', 1); | 
            ||
| 206 | }  | 
            ||
| 207 | |||
| 208 |     if($conf['allowdebug']){ | 
            ||
| 209 |         msg('Debugging support is enabled. If you don\'t need it you should set $conf[\'allowdebug\'] = 0',-1); | 
            ||
| 210 |     }else{ | 
            ||
| 211 |         msg('Debugging support is disabled',1); | 
            ||
| 212 | }  | 
            ||
| 213 | |||
| 214 |     if($INFO['userinfo']['name']){ | 
            ||
| 215 |         msg('You are currently logged in as '.$INPUT->server->str('REMOTE_USER').' ('.$INFO['userinfo']['name'].')',0); | 
            ||
| 216 |         msg('You are part of the groups '.join($INFO['userinfo']['grps'],', '),0); | 
            ||
| 217 |     }else{ | 
            ||
| 218 |         msg('You are currently not logged in',0); | 
            ||
| 219 | }  | 
            ||
| 220 | |||
| 221 |     msg('Your current permission for this page is '.$INFO['perm'],0); | 
            ||
| 222 | |||
| 223 |     if(is_writable($INFO['filepath'])){ | 
            ||
| 224 |         msg('The current page is writable by the webserver',0); | 
            ||
| 225 |     }else{ | 
            ||
| 226 |         msg('The current page is not writable by the webserver',0); | 
            ||
| 227 | }  | 
            ||
| 228 | |||
| 229 |     if($INFO['writable']){ | 
            ||
| 230 |         msg('The current page is writable by you',0); | 
            ||
| 231 |     }else{ | 
            ||
| 232 |         msg('The current page is not writable by you',0); | 
            ||
| 233 | }  | 
            ||
| 234 | |||
| 235 | // Check for corrupted search index  | 
            ||
| 236 | $lengths = idx_listIndexLengths();  | 
            ||
| 237 | $index_corrupted = false;  | 
            ||
| 238 |     foreach ($lengths as $length) { | 
            ||
| 239 |         if (count(idx_getIndex('w', $length)) != count(idx_getIndex('i', $length))) { | 
            ||
| 240 | $index_corrupted = true;  | 
            ||
| 241 | break;  | 
            ||
| 242 | }  | 
            ||
| 243 | }  | 
            ||
| 244 | |||
| 245 |     foreach (idx_getIndex('metadata', '') as $index) { | 
            ||
| 246 |         if (count(idx_getIndex($index.'_w', '')) != count(idx_getIndex($index.'_i', ''))) { | 
            ||
| 247 | $index_corrupted = true;  | 
            ||
| 248 | break;  | 
            ||
| 249 | }  | 
            ||
| 250 | }  | 
            ||
| 251 | |||
| 252 | if ($index_corrupted)  | 
            ||
| 253 |         msg('The search index is corrupted. It might produce wrong results and most | 
            ||
| 254 | probably needs to be rebuilt. See  | 
            ||
| 255 | <a href="http://www.dokuwiki.org/faq:searchindex">faq:searchindex</a>  | 
            ||
| 256 | for ways to rebuild the search index.', -1);  | 
            ||
| 257 | elseif (!empty($lengths))  | 
            ||
| 258 |         msg('The search index seems to be working', 1); | 
            ||
| 259 | else  | 
            ||
| 260 |         msg('The search index is empty. See | 
            ||
| 261 | <a href="http://www.dokuwiki.org/faq:searchindex">faq:searchindex</a>  | 
            ||
| 262 | for help on how to fix the search index. If the default indexer  | 
            ||
| 263 | isn\'t used or the wiki is actually empty this is normal.');  | 
            ||
| 264 | }  | 
            ||
| 265 | |||
| 492 | 
If you suppress an error, we recommend checking for the error condition explicitly: