| Conditions | 13 |
| Paths | 3 |
| Total Lines | 90 |
| Code Lines | 62 |
| 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 |
||
| 61 | function left(){ |
||
| 62 | global $user, $no_web_account_creation, $project_id; |
||
| 63 | panel( |
||
| 64 | $user?tra("Welcome, %1", $user->name):tra("What is %1?", PROJECT), |
||
| 65 | function() use($user) { |
||
| 66 | global $no_web_account_creation, $project_id; |
||
| 67 | if ($user) { |
||
| 68 | $dt = time() - $user->create_time; |
||
| 69 | if ($dt < 86400) { |
||
| 70 | echo tra("Thanks for joining %1", PROJECT); |
||
| 71 | } else if ($user->total_credit == 0) { |
||
| 72 | echo tra("Your computer hasn't completed any tasks yet. If you need help, %1go here%2.", |
||
| 73 | "<a href=https://boinc.berkeley.edu/help.php>", |
||
| 74 | "</a>" |
||
| 75 | ); |
||
| 76 | } else { |
||
| 77 | $x = format_credit($user->expavg_credit); |
||
| 78 | echo tra("You've contributed about %1 credits per day to %2 recently.", $x, PROJECT); |
||
| 79 | if ($user->expavg_credit > 1) { |
||
| 80 | echo " "; |
||
| 81 | echo tra("Thanks!"); |
||
| 82 | } else { |
||
| 83 | echo "<p><p>"; |
||
| 84 | echo tra("Please make sure BOINC is installed and enabled on your computer."); |
||
| 85 | } |
||
| 86 | } |
||
| 87 | echo "<p><p>"; |
||
| 88 | echo sprintf('<center>%s</center>', |
||
| 89 | button_text('home.php', |
||
| 90 | tra('Continue to your home page'), |
||
| 91 | '', |
||
| 92 | '', |
||
| 93 | button_style('green', 16) |
||
| 94 | ) |
||
| 95 | ); |
||
| 96 | echo "<p><p>"; |
||
| 97 | echo sprintf('%s |
||
| 98 | <ul> |
||
| 99 | <li> %s |
||
| 100 | <li> %s |
||
| 101 | <li> %s |
||
| 102 | ', |
||
| 103 | tra("Want to help more?"), |
||
| 104 | tra("If BOINC is not installed on this computer, %1download it%2.", |
||
| 105 | "<a href=download_software.php>", "</a>" |
||
| 106 | ), |
||
| 107 | tra("Install BOINC on your other computers, tablets, and phones."), |
||
| 108 | tra("Tell your friends about BOINC, and show them how to join %1.", PROJECT) |
||
| 109 | ); |
||
| 110 | if (function_exists('project_help_more')) { |
||
| 111 | project_help_more(); |
||
| 112 | } |
||
| 113 | echo "</ul>\n"; |
||
| 114 | } else { |
||
| 115 | echo "<p>"; |
||
| 116 | $pd = "../project/project_description.php"; |
||
| 117 | if (file_exists($pd)) { |
||
| 118 | include($pd); |
||
| 119 | } else { |
||
| 120 | echo "No project description yet. Create a file html/project/project_description.php |
||
| 121 | that prints a short description of your project. |
||
| 122 | "; |
||
| 123 | } |
||
| 124 | echo "</p>\n"; |
||
| 125 | if (NO_COMPUTING) { |
||
| 126 | if (!$no_web_account_creation) { |
||
| 127 | echo " |
||
| 128 | <a href=\"create_account_form.php\">Create an account</a> |
||
| 129 | "; |
||
| 130 | } |
||
| 131 | } else { |
||
| 132 | // use auto-attach if possible |
||
| 133 | // |
||
| 134 | if (!$no_web_account_creation) { |
||
| 135 | echo '<center><a href="signup.php" class="btn btn-success"><font size=+2>'.tra('Join %1', PROJECT).'</font></a></center>'; |
||
| 136 | } |
||
| 137 | echo "<p><p>".tra("Already joined? %1Log in%2.", |
||
| 138 | "<a href=login_form.php>", "</a>" |
||
| 139 | ); |
||
| 140 | } |
||
| 141 | } |
||
| 142 | } |
||
| 143 | ); |
||
| 144 | global $stopped; |
||
| 145 | if (!$stopped) { |
||
| 146 | $profile = get_current_uotd(); |
||
| 147 | if ($profile) { |
||
| 148 | panel(tra('User of the Day'), |
||
| 149 | function() use ($profile) { |
||
| 150 | show_uotd($profile); |
||
| 151 | } |
||
| 175 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.