mambax7/adslight

View on GitHub
blocks/ads.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method adslight_show has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function adslight_show($options)
{
    if (!class_exists(Helper::class)) {
        return [];
    }
Severity: Minor
Found in blocks/ads.php - About 1 hr to fix

    Function adslight_show has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    function adslight_show($options)
    {
        if (!class_exists(Helper::class)) {
            return [];
        }
    Severity: Minor
    Found in blocks/ads.php - About 55 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 static access to class '\XoopsModules\Adslight\Helper' in method 'adslight_show'.
    Open

        $helper = Helper::getInstance();
    Severity: Minor
    Found in blocks/ads.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 '\XoopsModules\Adslight\Utility' in method 'adslight_show'.
    Open

            $a_item['type'] = Utility::getNameType($type);
    Severity: Minor
    Found in blocks/ads.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 '\MyTextSanitizer' in method 'adslight_show'.
    Open

        $myts  = \MyTextSanitizer::getInstance();
    Severity: Minor
    Found in blocks/ads.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 '$helper'.
    Open

        $helper = Helper::getInstance();
    Severity: Minor
    Found in blocks/ads.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 local variables such as '$myts'.
    Open

        $myts  = \MyTextSanitizer::getInstance();
    Severity: Minor
    Found in blocks/ads.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 local variables such as '$xoopsDB'.
    Open

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

    Line exceeds 120 characters; contains 187 characters
    Open

        $form .= '&nbsp;<br><br>' . constant("{$block_lang}_CHARS") . "&nbsp;<input type='text' name='options[]' value='{$options[2]}'>&nbsp;" . constant("{$block_lang}_LENGTH") . '<br><br>';
    Severity: Minor
    Found in blocks/ads.php by phpcodesniffer

    Line exceeds 120 characters; contains 140 characters
    Open

        $block['link'] = '<a href="' . XOOPS_URL . "/modules/{$moduleDirName}/\"><b>" . constant("{$block_lang}_ALL_LISTINGS") . '</b></a><br>';
    Severity: Minor
    Found in blocks/ads.php by phpcodesniffer

    Line exceeds 120 characters; contains 168 characters
    Open

        $form .= '&nbsp;' . constant($block_lang . '_DISP') . "&nbsp;<input type='text' name='options[]' value='{$options[1]}'>&nbsp;" . constant("{$block_lang}_LISTINGS");
    Severity: Minor
    Found in blocks/ads.php by phpcodesniffer

    Line exceeds 120 characters; contains 152 characters
    Open

            $a_item['link'] = '<a href="' . XOOPS_URL . "/modules/{$moduleDirName}/viewads.php?lid=" . addslashes($myrow['lid']) . "\"><b>{$title}</b></a>";
    Severity: Minor
    Found in blocks/ads.php by phpcodesniffer

    Line exceeds 120 characters; contains 134 characters
    Open

        $block['add']  = '<a href="' . XOOPS_URL . "/modules/{$moduleDirName}/\"><b>" . constant("{$block_lang}_ADDNOW") . '</b></a><br>';
    Severity: Minor
    Found in blocks/ads.php by phpcodesniffer

    Line exceeds 120 characters; contains 169 characters
    Open

        $sql    = 'SELECT lid, cid, title, type, date_created, hits FROM ' . $xoopsDB->prefix("{$moduleDirName}_listing") . " WHERE valid='Yes' ORDER BY {$options[0]} DESC";
    Severity: Minor
    Found in blocks/ads.php by phpcodesniffer

    The variable $block_lang is not named in camelCase.
    Open

    function adslight_show($options)
    {
        if (!class_exists(Helper::class)) {
            return [];
        }
    Severity: Minor
    Found in blocks/ads.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 $block_lang is not named in camelCase.
    Open

    function adslight_show($options)
    {
        if (!class_exists(Helper::class)) {
            return [];
        }
    Severity: Minor
    Found in blocks/ads.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 $a_item is not named in camelCase.
    Open

    function adslight_show($options)
    {
        if (!class_exists(Helper::class)) {
            return [];
        }
    Severity: Minor
    Found in blocks/ads.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 $block_lang is not named in camelCase.
    Open

    function adslight_show($options)
    {
        if (!class_exists(Helper::class)) {
            return [];
        }
    Severity: Minor
    Found in blocks/ads.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 $a_item is not named in camelCase.
    Open

    function adslight_show($options)
    {
        if (!class_exists(Helper::class)) {
            return [];
        }
    Severity: Minor
    Found in blocks/ads.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 $a_item is not named in camelCase.
    Open

    function adslight_show($options)
    {
        if (!class_exists(Helper::class)) {
            return [];
        }
    Severity: Minor
    Found in blocks/ads.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 $block_lang is not named in camelCase.
    Open

    function adslight_edit($options): string
    {
        global $xoopsDB;
        $moduleDirName = \basename(\dirname(__DIR__));
        $block_lang    = '_MB_' . mb_strtoupper($moduleDirName);
    Severity: Minor
    Found in blocks/ads.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 $a_item is not named in camelCase.
    Open

    function adslight_show($options)
    {
        if (!class_exists(Helper::class)) {
            return [];
        }
    Severity: Minor
    Found in blocks/ads.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 $a_item is not named in camelCase.
    Open

    function adslight_show($options)
    {
        if (!class_exists(Helper::class)) {
            return [];
        }
    Severity: Minor
    Found in blocks/ads.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 $a_item is not named in camelCase.
    Open

    function adslight_show($options)
    {
        if (!class_exists(Helper::class)) {
            return [];
        }
    Severity: Minor
    Found in blocks/ads.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 $a_item is not named in camelCase.
    Open

    function adslight_show($options)
    {
        if (!class_exists(Helper::class)) {
            return [];
        }
    Severity: Minor
    Found in blocks/ads.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 $block_lang is not named in camelCase.
    Open

    function adslight_edit($options): string
    {
        global $xoopsDB;
        $moduleDirName = \basename(\dirname(__DIR__));
        $block_lang    = '_MB_' . mb_strtoupper($moduleDirName);
    Severity: Minor
    Found in blocks/ads.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 $a_item is not named in camelCase.
    Open

    function adslight_show($options)
    {
        if (!class_exists(Helper::class)) {
            return [];
        }
    Severity: Minor
    Found in blocks/ads.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 $block_lang is not named in camelCase.
    Open

    function adslight_show($options)
    {
        if (!class_exists(Helper::class)) {
            return [];
        }
    Severity: Minor
    Found in blocks/ads.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 $block_lang is not named in camelCase.
    Open

    function adslight_show($options)
    {
        if (!class_exists(Helper::class)) {
            return [];
        }
    Severity: Minor
    Found in blocks/ads.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 $block_lang is not named in camelCase.
    Open

    function adslight_edit($options): string
    {
        global $xoopsDB;
        $moduleDirName = \basename(\dirname(__DIR__));
        $block_lang    = '_MB_' . mb_strtoupper($moduleDirName);
    Severity: Minor
    Found in blocks/ads.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 $block_lang is not named in camelCase.
    Open

    function adslight_edit($options): string
    {
        global $xoopsDB;
        $moduleDirName = \basename(\dirname(__DIR__));
        $block_lang    = '_MB_' . mb_strtoupper($moduleDirName);
    Severity: Minor
    Found in blocks/ads.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 $block_lang is not named in camelCase.
    Open

    function adslight_edit($options): string
    {
        global $xoopsDB;
        $moduleDirName = \basename(\dirname(__DIR__));
        $block_lang    = '_MB_' . mb_strtoupper($moduleDirName);
    Severity: Minor
    Found in blocks/ads.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 $block_lang is not named in camelCase.
    Open

    function adslight_edit($options): string
    {
        global $xoopsDB;
        $moduleDirName = \basename(\dirname(__DIR__));
        $block_lang    = '_MB_' . mb_strtoupper($moduleDirName);
    Severity: Minor
    Found in blocks/ads.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 $block_lang is not named in camelCase.
    Open

    function adslight_edit($options): string
    {
        global $xoopsDB;
        $moduleDirName = \basename(\dirname(__DIR__));
        $block_lang    = '_MB_' . mb_strtoupper($moduleDirName);
    Severity: Minor
    Found in blocks/ads.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 $block_lang is not named in camelCase.
    Open

    function adslight_edit($options): string
    {
        global $xoopsDB;
        $moduleDirName = \basename(\dirname(__DIR__));
        $block_lang    = '_MB_' . mb_strtoupper($moduleDirName);
    Severity: Minor
    Found in blocks/ads.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