XoopsModules25x/about

View on GitHub
class/Utility.php

Summary

Maintainability
A
1 hr
Test Coverage

getCss accesses the super-global variable $GLOBALS.
Open

    public static function getCss($style = 'default')
    {
        global $xoops;

        if (is_readable($xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . mb_strtolower($style) . '.css'))) {
Severity: Minor
Found in class/Utility.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

getTemplate accesses the super-global variable $GLOBALS.
Open

    public static function getTemplate($page = 'index', $style = null)
    {
        global $xoops;

        $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
Severity: Minor
Found in class/Utility.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

getTemplate accesses the super-global variable $GLOBALS.
Open

    public static function getTemplate($page = 'index', $style = null)
    {
        global $xoops;

        $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
Severity: Minor
Found in class/Utility.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

getCss accesses the super-global variable $GLOBALS.
Open

    public static function getCss($style = 'default')
    {
        global $xoops;

        if (is_readable($xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . mb_strtolower($style) . '.css'))) {
Severity: Minor
Found in class/Utility.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

getTemplate accesses the super-global variable $GLOBALS.
Open

    public static function getTemplate($page = 'index', $style = null)
    {
        global $xoops;

        $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
Severity: Minor
Found in class/Utility.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

getCss accesses the super-global variable $GLOBALS.
Open

    public static function getCss($style = 'default')
    {
        global $xoops;

        if (is_readable($xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . mb_strtolower($style) . '.css'))) {
Severity: Minor
Found in class/Utility.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

getTplPageList accesses the super-global variable $GLOBALS.
Open

    public static function &getTplPageList($page = '', $refresh = true)
    {
        $list = null;

        $cache_file = empty($page) ? 'template-list' : 'template-page';
Severity: Minor
Found in class/Utility.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

template_lookup accesses the super-global variable $GLOBALS.
Open

    public static function &template_lookup($index_by_page = false)
    {
        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';

        $files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
Severity: Minor
Found in class/Utility.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

template_lookup accesses the super-global variable $GLOBALS.
Open

    public static function &template_lookup($index_by_page = false)
    {
        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';

        $files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
Severity: Minor
Found in class/Utility.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

template_lookup accesses the super-global variable $GLOBALS.
Open

    public static function &template_lookup($index_by_page = false)
    {
        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';

        $files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
Severity: Minor
Found in class/Utility.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 template_lookup has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public static function &template_lookup($index_by_page = false)
    {
        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';

        $files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
Severity: Minor
Found in class/Utility.php - About 1 hr 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 getTplPageList has a boolean flag argument $refresh, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function &getTplPageList($page = '', $refresh = true)
Severity: Minor
Found in class/Utility.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 aboutmkdirs has a boolean flag argument $recursive, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function aboutmkdirs($dir, $mode = 0777, $recursive = true)
Severity: Minor
Found in class/Utility.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

Remove error control operator '@' on line 175.
Open

    public static function &getTplPageList($page = '', $refresh = true)
    {
        $list = null;

        $cache_file = empty($page) ? 'template-list' : 'template-page';
Severity: Minor
Found in class/Utility.php by phpmd

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

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

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

    public static function getTemplateList($page = 'index', $refresh = false)
Severity: Minor
Found in class/Utility.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 template_lookup has a boolean flag argument $index_by_page, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function &template_lookup($index_by_page = false)
Severity: Minor
Found in class/Utility.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 template_lookup uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $list[$matches[1]][$matches[3]] = $name;
                }
Severity: Minor
Found in class/Utility.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 '\XoopsLists' in method 'template_lookup'.
Open

        $files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
Severity: Minor
Found in class/Utility.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 using static access to class '\XoopsCache' in method 'getTplPageList'.
Open

        $list = \XoopsCache::read($key);
Severity: Minor
Found in class/Utility.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 using static access to class '\XoopsCache' in method 'template_lookup'.
Open

        \XoopsCache::write($key, $list);
Severity: Minor
Found in class/Utility.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 '$file'.
Open

        foreach ($files as $file => $name) {
Severity: Minor
Found in class/Utility.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 parameter $index_by_page is not named in camelCase.
Open

    public static function &template_lookup($index_by_page = false)
    {
        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';

        $files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
Severity: Minor
Found in class/Utility.php by phpmd

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 34 and the first side effect is on line 33.
Open

<?php
Severity: Minor
Found in class/Utility.php by phpcodesniffer

The closing brace for the class must go on the next line after the body
Open

}
Severity: Minor
Found in class/Utility.php by phpcodesniffer

Method name "Utility::template_lookup" is not in camel caps format
Open

    public static function &template_lookup($index_by_page = false)
Severity: Minor
Found in class/Utility.php by phpcodesniffer

Line exceeds 120 characters; contains 133 characters
Open

        if (is_readable($xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . mb_strtolower($style) . '.css'))) {
Severity: Minor
Found in class/Utility.php by phpcodesniffer

Line exceeds 120 characters; contains 121 characters
Open

        $files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
Severity: Minor
Found in class/Utility.php by phpcodesniffer

Line exceeds 120 characters; contains 131 characters
Open

            return $xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . mb_strtolower($style) . '.css', true);
Severity: Minor
Found in class/Utility.php by phpcodesniffer

Line exceeds 120 characters; contains 132 characters
Open

     * The hardcoded path is not desirable for theme switch, however, we have to keabout it before getting a good solution for cache
Severity: Minor
Found in class/Utility.php by phpcodesniffer

The variable $file_name is not named in camelCase.
Open

    public static function getTemplate($page = 'index', $style = null)
    {
        global $xoops;

        $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
Severity: Minor
Found in class/Utility.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 $template_dir is not named in camelCase.
Open

    public static function getTemplate($page = 'index', $style = null)
    {
        global $xoops;

        $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
Severity: Minor
Found in class/Utility.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 $file_name is not named in camelCase.
Open

    public static function getTemplate($page = 'index', $style = null)
    {
        global $xoops;

        $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
Severity: Minor
Found in class/Utility.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 $template_dir is not named in camelCase.
Open

    public static function getTemplate($page = 'index', $style = null)
    {
        global $xoops;

        $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
Severity: Minor
Found in class/Utility.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 $file_name is not named in camelCase.
Open

    public static function getTemplate($page = 'index', $style = null)
    {
        global $xoops;

        $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
Severity: Minor
Found in class/Utility.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 $template_dir is not named in camelCase.
Open

    public static function getTemplate($page = 'index', $style = null)
    {
        global $xoops;

        $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
Severity: Minor
Found in class/Utility.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 $xoops_module_header is not named in camelCase.
Open

    public static function getModuleHeader($style = 'default')
    {
        $xoops_module_header = '<link rel="stylesheet" type="text/css" href="' . self::getCss($style) . '">';

        return $xoops_module_header;
Severity: Minor
Found in class/Utility.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 $xoops_module_header is not named in camelCase.
Open

    public static function getModuleHeader($style = 'default')
    {
        $xoops_module_header = '<link rel="stylesheet" type="text/css" href="' . self::getCss($style) . '">';

        return $xoops_module_header;
Severity: Minor
Found in class/Utility.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 $file_name is not named in camelCase.
Open

    public static function getTemplate($page = 'index', $style = null)
    {
        global $xoops;

        $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
Severity: Minor
Found in class/Utility.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 $file_name is not named in camelCase.
Open

    public static function getTemplate($page = 'index', $style = null)
    {
        global $xoops;

        $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
Severity: Minor
Found in class/Utility.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 $file_name is not named in camelCase.
Open

    public static function getTemplate($page = 'index', $style = null)
    {
        global $xoops;

        $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/");
Severity: Minor
Found in class/Utility.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 $cache_file is not named in camelCase.
Open

    public static function &getTplPageList($page = '', $refresh = true)
    {
        $list = null;

        $cache_file = empty($page) ? 'template-list' : 'template-page';
Severity: Minor
Found in class/Utility.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 $cache_file is not named in camelCase.
Open

    public static function &template_lookup($index_by_page = false)
    {
        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';

        $files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
Severity: Minor
Found in class/Utility.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 $cache_file is not named in camelCase.
Open

    public static function &template_lookup($index_by_page = false)
    {
        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';

        $files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
Severity: Minor
Found in class/Utility.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 $cache_file is not named in camelCase.
Open

    public static function &getTplPageList($page = '', $refresh = true)
    {
        $list = null;

        $cache_file = empty($page) ? 'template-list' : 'template-page';
Severity: Minor
Found in class/Utility.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 $index_by_page is not named in camelCase.
Open

    public static function &template_lookup($index_by_page = false)
    {
        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';

        $files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
Severity: Minor
Found in class/Utility.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 $index_by_page is not named in camelCase.
Open

    public static function &template_lookup($index_by_page = false)
    {
        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';

        $files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
Severity: Minor
Found in class/Utility.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 method template_lookup is not named in camelCase.
Open

    public static function &template_lookup($index_by_page = false)
    {
        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';

        $files = \XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/');
Severity: Minor
Found in class/Utility.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