XoopsModules25x/tag

View on GitHub
sample.php

Summary

Maintainability
A
3 hrs
Test Coverage

mymodule_tag_block_cloud_show accesses the super-global variable $GLOBALS.
Open

function mymodule_tag_block_cloud_show(array $options)
{
    require_once $GLOBALS['xoops']->path('/modules/tag/blocks/block.php');

    $moduleDirName      = \basename(\dirname(__DIR__));
Severity: Minor
Found in sample.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

mymodule_tag_block_top_edit accesses the super-global variable $GLOBALS.
Open

function mymodule_tag_block_top_edit(array $options): string
{
    require_once $GLOBALS['xoops']->path('/modules/tag/blocks/block.php');

    return tag_block_top_edit($options);
Severity: Minor
Found in sample.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

mymodule_tag_block_cloud_edit accesses the super-global variable $GLOBALS.
Open

function mymodule_tag_block_cloud_edit(array $options): string
{
    require_once $GLOBALS['xoops']->path('/modules/tag/blocks/block.php');

    return tag_block_cloud_edit($options);
Severity: Minor
Found in sample.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

mymodule_tag_block_top_show accesses the super-global variable $GLOBALS.
Open

function mymodule_tag_block_top_show(array $options)
{
    require_once $GLOBALS['xoops']->path('/modules/tag/blocks/block.php');

    $moduleDirName      = \basename(\dirname(__DIR__));
Severity: Minor
Found in sample.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 mymodule_tag_iteminfo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function mymodule_tag_iteminfo(array $items): bool
{
    if (empty($items)) {
        return false;
    }
Severity: Minor
Found in sample.php - About 1 hr to fix

    Function mymodule_tag_iteminfo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.php - About 35 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

    Missing class import via use statement (line '97', column '49').
    Open

        $items_obj   = $itemHandler->getObjects(new \Criteria('itemid', '(' . implode(', ', $items_id) . ')', 'IN'), true);
    Severity: Minor
    Found in sample.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 using static access to class 'XoopsModules\Tag\Utility' in method 'mymodule_tag_iteminfo'.
    Open

                    'tags'    => XoopsModules\Tag\Utility::tag_parse_tag($item_obj->getVar('item_tags', 'n')), // optional
    Severity: Minor
    Found in sample.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\Mymodule\Helper' in method 'mymodule_tag_iteminfo'.
    Open

        $helper   = XoopsModules\Mymodule\Helper::getInstance();
    Severity: Minor
    Found in sample.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 parameters such as '$mid'.
    Open

    function mymodule_tag_synchronization(int $mid): void
    Severity: Minor
    Found in sample.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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        foreach (array_keys($items) as $cat_id) {
            foreach (array_keys($items[$cat_id]) as $item_id) {
                $item_obj                 = $items_obj[$item_id];
                $items[$cat_id][$item_id] = [
                    'title'   => $item_obj->getVar('item_title'),
    Severity: Major
    Found in sample.php and 3 other locations - About 2 hrs to fix
    plugin/article.php on lines 60..72
    plugin/newbb.php on lines 60..72
    plugin/publisher.php on lines 51..64

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 124.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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 81 and the first side effect is on line 20.
    Open

    <?php declare(strict_types=1);
    Severity: Minor
    Found in sample.php by phpcodesniffer

    There must be one blank line after the last USE statement; 0 found;
    Open

    use XoopsModules\Tag\Tagbar;
    Severity: Minor
    Found in sample.php by phpcodesniffer

    Line exceeds 120 characters; contains 272 characters
    Open

    catid:          extra parameter to identify an object. Only useful when you have more than one types of objects in the same module, for instance in a gallery module, type #1 tags are for images, type #2 tags for albums: (IDofImage, mid, catid=1), (IDofAlbum, mid, catid=2)
    Severity: Minor
    Found in sample.php by phpcodesniffer

    Line exceeds 120 characters; contains 134 characters
    Open

    itemid:         unique ID of the object to which the tag belonging, for instance topic_id for newbb topic, art_id for article article;
    Severity: Minor
    Found in sample.php by phpcodesniffer

    The variable $item_obj is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $item_id is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $item_id is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $item_id is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $items_id is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $item_id is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $item_obj is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $items_obj is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $item_id is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $item_obj is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $cat_id is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $cat_id is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $cat_id is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $items_obj is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $cat_id is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $items_obj is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $item_obj is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $items_id is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $items_id is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $cat_id is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $item_id is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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 $item_obj is not named in camelCase.
    Open

    function mymodule_tag_iteminfo(array $items): bool
    {
        if (empty($items)) {
            return false;
        }
    Severity: Minor
    Found in sample.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