XoopsModules25x/userlog

View on GitHub
class/plugin/plugin.php

Summary

Maintainability
A
2 hrs
Test Coverage

getPlugins accesses the super-global variable $GLOBALS.
Open

    public static function getPlugins($pluginName = 'system', $inactiveModules = false)
    {
        static $plugins = [];
        if (!isset($plugins[$pluginName])) {
            $plugins[$pluginName] = [];
Severity: Minor
Found in class/plugin/plugin.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

getPlugins accesses the super-global variable $GLOBALS.
Open

    public static function getPlugins($pluginName = 'system', $inactiveModules = false)
    {
        static $plugins = [];
        if (!isset($plugins[$pluginName])) {
            $plugins[$pluginName] = [];
Severity: Minor
Found in class/plugin/plugin.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

getPlugins accesses the super-global variable $GLOBALS.
Open

    public static function getPlugins($pluginName = 'system', $inactiveModules = false)
    {
        static $plugins = [];
        if (!isset($plugins[$pluginName])) {
            $plugins[$pluginName] = [];
Severity: Minor
Found in class/plugin/plugin.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Function getPlugins has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getPlugins($pluginName = 'system', $inactiveModules = false)
    {
        static $plugins = [];
        if (!isset($plugins[$pluginName])) {
            $plugins[$pluginName] = [];
Severity: Minor
Found in class/plugin/plugin.php - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

The method getPlugin has a boolean flag argument $force, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function getPlugin($dirname, $pluginName = 'system', $force = false)
Severity: Minor
Found in class/plugin/plugin.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method getPlugins has a boolean flag argument $inactiveModules, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function getPlugins($pluginName = 'system', $inactiveModules = false)
Severity: Minor
Found in class/plugin/plugin.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method loadFile has a boolean flag argument $once, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function loadFile($file, $once = true)
Severity: Minor
Found in class/plugin/plugin.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method loadFile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                include $file;
            }
Severity: Minor
Found in class/plugin/plugin.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 _securityCheck() contains an exit expression.
Open

            exit('Security check: Illegal character in filename');
Severity: Minor
Found in class/plugin/plugin.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

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Userlog_Module_Plugin
Severity: Minor
Found in class/plugin/plugin.php by phpcodesniffer

The class Userlog_Module_Plugin is not named in CamelCase.
Open

class Userlog_Module_Plugin
{
    /**
     * @param string $dirname
     * @param string $pluginName
Severity: Minor
Found in class/plugin/plugin.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Method name "_securityCheck" should not be prefixed with an underscore to indicate visibility
Open

    protected static function _securityCheck($filename)
Severity: Minor
Found in class/plugin/plugin.php by phpcodesniffer

Class name "Userlog_Module_Plugin" is not in camel caps format
Open

class Userlog_Module_Plugin
Severity: Minor
Found in class/plugin/plugin.php by phpcodesniffer

The method _securityCheck is not named in camelCase.
Open

    protected static function _securityCheck($filename)
    {
        /**
         * Security check
         */
Severity: Minor
Found in class/plugin/plugin.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status