sovereignbot/citadel

View on GitHub

Showing 284 of 284 total issues

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";
                        }
Severity: Minor
Found in src/Plugins/onMessage/config.php by phpmd

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 unused local variables such as '$characterName'.
Open

            $characterName = json_decode($this->curl->get("https://evedata.xyz/api/character/shortinformation/{$characterID}/"))->characterName;
Severity: Minor
Found in src/Plugins/onMessage/auth.php by phpmd

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 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** You are trying to authenticate with an already used (or not existing) auth token..");
        }
Severity: Minor
Found in src/Plugins/onMessage/auth.php by phpmd

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 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;
Severity: Minor
Found in src/Plugins/onMessage/config.php by phpmd

Avoid unused parameters such as '$output'.
Open

    protected function execute(InputInterface $input, OutputInterface $output)
Severity: Minor
Found in src/Command/StartCommand.php by phpmd

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 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** corporationID is not valid";
                        }
Severity: Minor
Found in src/Plugins/onMessage/config.php by phpmd

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 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;
Severity: Minor
Found in src/Plugins/onMessage/coinflip.php by phpmd

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;
Severity: Minor
Found in src/Plugins/onTimer/memory.php by phpmd

The method execute() contains an exit expression.
Open

                die(1);
Severity: Minor
Found in src/Lib/Db.php by phpmd

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 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]);
Severity: Minor
Found in src/Plugins/onMessage/config.php by phpmd

The method execute() contains an exit expression.
Open

            die();
Severity: Minor
Found in src/Command/StartCommand.php by phpmd

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;
Severity: Minor
Found in src/Plugins/onMessage/tq.php by phpmd

The method run() has an NPath complexity of 4151808. The configured NPath complexity threshold is 200.
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..');
Severity: Minor
Found in src/Sovereign.php by phpmd

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() contains an exit expression.
Open

            die(1);
Severity: Minor
Found in src/Sovereign.php by phpmd

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 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]);
Severity: Minor
Found in src/Plugins/onMessage/char.php by phpmd

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 {
                    $solarSystemID = $this->db->queryField("SELECT solarSystemID FROM mapSolarSystems WHERE solarSystemName = :system", "solarSystemID", array(":system" => $system));
                    $data = new SimpleXMLElement($this->curl->get("https://api.eve-central.com/api/marketstat?usesystem={$solarSystemID}&typeid={$typeID}"));
                }
Severity: Minor
Found in src/Plugins/onMessage/pc.php by phpmd

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 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;
Severity: Minor
Found in src/Plugins/onMessage/time.php by phpmd

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..');
Severity: Minor
Found in src/Sovereign.php by phpmd

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";
                        }
Severity: Minor
Found in src/Plugins/onMessage/config.php by phpmd

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() 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";
Severity: Minor
Found in src/Plugins/onMessage/pc.php by phpmd

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

Severity
Category
Status
Source
Language