Showing 284 of 284 total issues
The method query() contains an exit expression. Open
die(1);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
The method __construct has 12 parameters. Consider reducing the number of parameters to less than 10. Open
public function __construct($message, $discord, $channelConfig, $log, $config, $db, $curl, $settings, $permissions, $serverConfig, $users, $extras)
{
$this->message = $message;
$this->discord = $discord;
$this->channelConfig = $channelConfig;
- Create a ticketCreate a ticket
- Exclude checks
Avoid unused parameters such as '$log'. Open
public function run(Message $message, Discord $discord, WebSocket $webSocket, Logger $log, &$audioStreams, Channel $channel, cURL $curl)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
The method connect() contains an exit expression. Open
die();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
Avoid unused local variables such as '$characterName'. Open
$characterName = json_decode($this->curl->get("https://evedata.xyz/api/character/shortinformation/{$characterID}/"))->characterName;
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
The method run() has an NPath complexity of 448. The configured NPath complexity threshold is 200. Open
public function run()
{
// Most EVE players on Discord use their ingame name, so lets support @highlights
$explode = explode(" ", $this->message->content);
unset($explode[0]);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method __construct has 12 parameters. Consider reducing the number of parameters to less than 10. Open
public function __construct($message, $discord, $channelConfig, $log, $config, $db, $curl, $settings, $permissions, $serverConfig, $users, $extras)
{
$this->message = $message;
$this->discord = $discord;
$this->channelConfig = $channelConfig;
- Create a ticketCreate a ticket
- Exclude checks
The method __construct has 12 parameters. Consider reducing the number of parameters to less than 10. Open
public function __construct($message, $discord, $channelConfig, $log, $config, $db, $curl, $settings, $permissions, $serverConfig, $users, $extras)
{
$this->message = $message;
$this->discord = $discord;
$this->channelConfig = $channelConfig;
- Create a ticketCreate a ticket
- Exclude checks
The method run() has an NPath complexity of 328. The configured NPath complexity threshold is 200. Open
public function run()
{
$explode = explode(" ", $this->message->content);
$prefix = $this->channelConfig->prefix;
$system = isset($explode[0]) ? $explode[0] == "{$prefix}pc" ? "global" : str_replace($prefix, "", $explode[0]) : "global";
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$msg = "**Error** characterID is not valid";
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->message->reply("Error, no such user has been seen..");
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\Discord\Cache\Cache' in method '__construct'. Open
Cache::setCache(new ArrayCacheDriver());
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method run() has 258 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function run()
{
// Reap the threads!
$this->websocket->loop->addPeriodicTimer(600, function () {
$this->log->addInfo('Restarting the threading pool, to clear out old threads..');
- Create a ticketCreate a ticket
- Exclude checks
The method run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$msg = "No endpoint selected. Currently available are: " . implode(", ", $categoryNames);
$this->message->reply($msg);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method __construct has 10 parameters. Consider reducing the number of parameters to less than 10. Open
public function __construct($discord, $log, $config, $db, $curl, $settings, $permissions, $serverConfig, $users, $extras)
{
$this->discord = $discord;
$this->log = $log;
$this->config = $config;
- Create a ticketCreate a ticket
- Exclude checks
The method __construct has 12 parameters. Consider reducing the number of parameters to less than 10. Open
public function __construct($message, $discord, $channelConfig, $log, $config, $db, $curl, $settings, $permissions, $serverConfig, $users, $extras)
{
$this->message = $message;
$this->discord = $discord;
$this->channelConfig = $channelConfig;
- Create a ticketCreate a ticket
- Exclude checks
The method __construct has 12 parameters. Consider reducing the number of parameters to less than 10. Open
public function __construct($message, $discord, $channelConfig, $log, $config, $db, $curl, $settings, $permissions, $serverConfig, $users, $extras)
{
$this->message = $message;
$this->discord = $discord;
$this->channelConfig = $channelConfig;
- Create a ticketCreate a ticket
- Exclude checks
The method run() has 126 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function run()
{
$guildID = $this->message->full_channel->guild->id;
$input = explode(" ", $this->message->content);
unset($input[0]);
- Create a ticketCreate a ticket
- Exclude checks
The method run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$msg = "**Error** allianceID is not valid";
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method run uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->message->reply("**Error:** ***{$item}*** not found");
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}