We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 8 |
Paths | 11 |
Total Lines | 53 |
Code Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 declare(strict_types=1); |
||
70 | function server_msg_318($fp, string $rdata): bool { |
||
71 | |||
72 | // :ice.coldfront.net 318 Caretaker MrSpock :End of /WHOIS list. |
||
73 | if (preg_match('/^:(.*) 318 ' . IRC_BOT_NICK . ' (.*) :End of \/WHOIS list\.\s/i', $rdata, $msg)) { |
||
74 | |||
75 | $server = $msg[1]; |
||
76 | $nick = $msg[2]; |
||
77 | |||
78 | echo_r('[SERVER_318] ' . $server . ' end of /WHOIS for ' . $nick); |
||
79 | |||
80 | $db = Database::getInstance(); |
||
81 | |||
82 | $dbResult = $db->read('SELECT * FROM irc_seen WHERE nick = ' . $db->escapeString($nick) . ' AND registered IS NULL'); |
||
83 | foreach ($dbResult->records() as $dbRecord) { |
||
84 | $seen_id = $dbRecord->getInt('seen_id'); |
||
85 | |||
86 | $db->write('UPDATE irc_seen SET ' . |
||
87 | 'registered = 0 ' . |
||
88 | 'WHERE seen_id = ' . $seen_id); |
||
89 | } |
||
90 | |||
91 | foreach (CallbackEvent::getAll() as $event) { |
||
92 | |||
93 | // is that a callback for our nick? |
||
94 | if ($event->type == 'MSG_318' && $event->nick == $nick) { |
||
95 | |||
96 | CallbackEvent::remove($event); |
||
97 | |||
98 | // so we should do a callback but need to check first if the guy has registered |
||
99 | $dbResult = $db->read('SELECT 1 FROM irc_seen WHERE nick = ' . $db->escapeString($nick) . ' AND registered = 1 AND channel = ' . $db->escapeString($event->channel)); |
||
100 | if ($dbResult->hasRecord()) { |
||
101 | //Forward to a NICKSERV INFO call. |
||
102 | fwrite($fp, 'NICKSERV INFO ' . $nick . EOL); |
||
103 | CallbackEvent::add(new CallbackEvent( |
||
104 | type: 'NICKSERV_INFO', |
||
105 | channel: $event->channel, |
||
106 | nick: $event->nick, |
||
107 | callback: $event->callback, |
||
108 | time: time(), |
||
109 | validate: $event->validate |
||
110 | )); |
||
111 | } elseif ($event->validate) { |
||
112 | fwrite($fp, 'PRIVMSG ' . $event->channel . ' :' . $nick . ', you are not using a registered nick. Please identify with NICKSERV and try the last command again.' . EOL); |
||
113 | } |
||
114 | |||
115 | } |
||
116 | |||
117 | } |
||
118 | |||
119 | return true; |
||
120 | } |
||
121 | |||
122 | return false; |
||
123 | } |
||
210 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.