XoopsModules25x/apcal

View on GitHub
blocks/apcal_map.php

Summary

Maintainability
A
2 hrs
Test Coverage

apcal_map_show accesses the super-global variable $GLOBALS.
Open

    function apcal_map_show($options)
    {
        global $xoopsConfig, $xoopsDB;

        $original_level = error_reporting(E_ALL ^ E_NOTICE);
Severity: Minor
Found in blocks/apcal_map.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

Method apcal_map_show has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function apcal_map_show($options)
    {
        global $xoopsConfig, $xoopsDB;

        $original_level = error_reporting(E_ALL ^ E_NOTICE);
Severity: Minor
Found in blocks/apcal_map.php - About 1 hr to fix

    Function apcal_map_show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php - About 45 mins 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

    Avoid using undefined variables such as '$skin_folder' which will lead to PHP notices.
    Open

            $cal->images_path = "$mod_path/assets/images/$skin_folder";
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$skin_folder' which will lead to PHP notices.
    Open

            $cal->images_url  = "$mod_url/assets/images/$skin_folder";
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Missing class import via use statement (line '47', column '20').
    Open

            $cal = new APCal_xoops('', $xoopsConfig['language'], true);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '69', column '24').
    Open

                $tpl = new XoopsTpl();
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Avoid assigning values to variables in if clauses and the like (line '62', column '24').
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

    Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

    Avoid using static access to class 'Xmf\Module\Helper' in method 'apcal_map_show'.
    Open

                $moduleHelper = Xmf\Module\Helper::getHelper('system');
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    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 apcal_map_show uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $moduleHelper = Xmf\Module\Helper::getHelper('system');
            }
    Severity: Minor
    Found in blocks/apcal_map.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 using static access to class 'Xmf\Module\Helper' in method 'apcal_map_show'.
    Open

            if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) {
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    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

    Avoid unused local variables such as '$xoopsDB'.
    Open

            global $xoopsConfig, $xoopsDB;
    Severity: Minor
    Found in blocks/apcal_map.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

    Avoid unused parameters such as '$options'.
    Open

        function apcal_map_edit($options)
    Severity: Minor
    Found in blocks/apcal_map.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 variable $mod_url is not named in camelCase.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $mod_path is not named in camelCase.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $mod_url is not named in camelCase.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $skin_folder is not named in camelCase.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $mod_path is not named in camelCase.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $mod_path is not named in camelCase.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $original_level is not named in camelCase.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $mod_path is not named in camelCase.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $skin_folder is not named in camelCase.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $mod_url is not named in camelCase.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $mod_url is not named in camelCase.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $original_level is not named in camelCase.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $mod_path is not named in camelCase.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $mod_path is not named in camelCase.
    Open

        function apcal_map_show($options)
        {
            global $xoopsConfig, $xoopsDB;
    
            $original_level = error_reporting(E_ALL ^ E_NOTICE);
    Severity: Minor
    Found in blocks/apcal_map.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status