mambax7/alumni-26x

View on GitHub
class/plugin/notifications.php

Summary

Maintainability
B
4 hrs
Test Coverage

Method item has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function item($category, $item_id)
    {
        $xoops   = Xoops::getInstance();
        $item    = [];
        $item_id = (int)$item_id;
Severity: Minor
Found in class/plugin/notifications.php - About 1 hr to fix

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

                $item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/listing.php?lid= ' . $item_id;
    Severity: Minor
    Found in class/plugin/notifications.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 '$module' which will lead to PHP notices.
    Open

                $item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/categories.php?cid=' . $item_id;
    Severity: Minor
    Found in class/plugin/notifications.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 static access to class 'Xoops' in method 'item'.
    Open

            $xoops   = Xoops::getInstance();
    Severity: Minor
    Found in class/plugin/notifications.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 '$item_id'.
    Open

        public function tags($category, $item_id, $event)
    Severity: Minor
    Found in class/plugin/notifications.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

    Avoid unused parameters such as '$category'.
    Open

        public function tags($category, $item_id, $event)
    Severity: Minor
    Found in class/plugin/notifications.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

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

            $xoops   = Xoops::getInstance();
    Severity: Minor
    Found in class/plugin/notifications.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 '$event'.
    Open

        public function tags($category, $item_id, $event)
    Severity: Minor
    Found in class/plugin/notifications.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

    TODO found
    Open

                $result       = $xoopsDB->query($sql); // TODO: error check
    Severity: Minor
    Found in class/plugin/notifications.php by fixme

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

            if ('category' === $category) {
    
                // Assume we have a valid topid id
                $sql          = 'SELECT title  FROM ' . $xoopsDB->prefix('alumni_categories') . ' WHERE cid = ' . $item_id . ' LIMIT 1';
                $result       = $xoopsDB->query($sql); // TODO: error check
    Severity: Major
    Found in class/plugin/notifications.php and 1 other location - About 1 hr to fix
    class/plugin/notifications.php on lines 62..71

    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 118.

    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

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

            if ('listing' === $category) {
                // Assume we have a valid post id
                $sql          = 'SELECT title FROM ' . $xoopsDB->prefix('alumni_listing') . ' WHERE lid = ' . $item_id . ' LIMIT 1';
                $result       = $xoopsDB->query($sql);
                $result_array = $xoopsDB->fetchArray($result);
    Severity: Major
    Found in class/plugin/notifications.php and 1 other location - About 1 hr to fix
    class/plugin/notifications.php on lines 50..60

    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 118.

    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

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

    class AlumniNotificationsPlugin extends Xoops\Module\Plugin\PluginAbstract implements NotificationsPluginInterface

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

    <?php

    The parameter $item_id is not named in camelCase.
    Open

        public function tags($category, $item_id, $event)
        {
            return [];
        }
    Severity: Minor
    Found in class/plugin/notifications.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

    The parameter $item_id is not named in camelCase.
    Open

        public function item($category, $item_id)
        {
            $xoops   = Xoops::getInstance();
            $item    = [];
            $item_id = (int)$item_id;
    Severity: Minor
    Found in class/plugin/notifications.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

    Blank line found at start of control structure
    Open

            if ('category' === $category) {

    Line exceeds 120 characters; contains 132 characters
    Open

                $sql          = 'SELECT title  FROM ' . $xoopsDB->prefix('alumni_categories') . ' WHERE cid = ' . $item_id . ' LIMIT 1';

    Line exceeds 120 characters; contains 128 characters
    Open

                $sql          = 'SELECT title FROM ' . $xoopsDB->prefix('alumni_listing') . ' WHERE lid = ' . $item_id . ' LIMIT 1';

    The variable $result_array is not named in camelCase.
    Open

        public function item($category, $item_id)
        {
            $xoops   = Xoops::getInstance();
            $item    = [];
            $item_id = (int)$item_id;
    Severity: Minor
    Found in class/plugin/notifications.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

        public function item($category, $item_id)
        {
            $xoops   = Xoops::getInstance();
            $item    = [];
            $item_id = (int)$item_id;
    Severity: Minor
    Found in class/plugin/notifications.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

        public function item($category, $item_id)
        {
            $xoops   = Xoops::getInstance();
            $item    = [];
            $item_id = (int)$item_id;
    Severity: Minor
    Found in class/plugin/notifications.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 $result_array is not named in camelCase.
    Open

        public function item($category, $item_id)
        {
            $xoops   = Xoops::getInstance();
            $item    = [];
            $item_id = (int)$item_id;
    Severity: Minor
    Found in class/plugin/notifications.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

        public function item($category, $item_id)
        {
            $xoops   = Xoops::getInstance();
            $item    = [];
            $item_id = (int)$item_id;
    Severity: Minor
    Found in class/plugin/notifications.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

        public function item($category, $item_id)
        {
            $xoops   = Xoops::getInstance();
            $item    = [];
            $item_id = (int)$item_id;
    Severity: Minor
    Found in class/plugin/notifications.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

        public function item($category, $item_id)
        {
            $xoops   = Xoops::getInstance();
            $item    = [];
            $item_id = (int)$item_id;
    Severity: Minor
    Found in class/plugin/notifications.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

        public function item($category, $item_id)
        {
            $xoops   = Xoops::getInstance();
            $item    = [];
            $item_id = (int)$item_id;
    Severity: Minor
    Found in class/plugin/notifications.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 $result_array is not named in camelCase.
    Open

        public function item($category, $item_id)
        {
            $xoops   = Xoops::getInstance();
            $item    = [];
            $item_id = (int)$item_id;
    Severity: Minor
    Found in class/plugin/notifications.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 $result_array is not named in camelCase.
    Open

        public function item($category, $item_id)
        {
            $xoops   = Xoops::getInstance();
            $item    = [];
            $item_id = (int)$item_id;
    Severity: Minor
    Found in class/plugin/notifications.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