mambax7/extgallery

View on GitHub
class/PublicCategoryHandler.php

Summary

Maintainability
A
3 hrs
Test Coverage

createCat accesses the super-global variable $GLOBALS.
Open

    public function createCat($data)
    {
        /** @var Extgallery\PublicCategory $cat */
        $cat = $this->create();
        $cat->setVars($data);
Severity: Minor
Found in class/PublicCategoryHandler.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

createCat accesses the super-global variable $GLOBALS.
Open

    public function createCat($data)
    {
        /** @var Extgallery\PublicCategory $cat */
        $cat = $this->create();
        $cat->setVars($data);
Severity: Minor
Found in class/PublicCategoryHandler.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

createCat accesses the super-global variable $GLOBALS.
Open

    public function createCat($data)
    {
        /** @var Extgallery\PublicCategory $cat */
        $cat = $this->create();
        $cat->setVars($data);
Severity: Minor
Found in class/PublicCategoryHandler.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 createCat has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function createCat($data)
    {
        /** @var Extgallery\PublicCategory $cat */
        $cat = $this->create();
        $cat->setVars($data);
Severity: Minor
Found in class/PublicCategoryHandler.php - About 1 hr to fix

    Function createCat has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function createCat($data)
        {
            /** @var Extgallery\PublicCategory $cat */
            $cat = $this->create();
            $cat->setVars($data);
    Severity: Minor
    Found in class/PublicCategoryHandler.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

    Missing class import via use statement (line '71', column '25').
    Open

            $criteria = new \CriteriaCompo();
    Severity: Minor
    Found in class/PublicCategoryHandler.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 '55', column '25').
    Open

            $criteria = new \CriteriaCompo();
    Severity: Minor
    Found in class/PublicCategoryHandler.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 '72', column '28').
    Open

            $criteria->add(new \Criteria('gperm_name', 'extgallery_public_mask'));
    Severity: Minor
    Found in class/PublicCategoryHandler.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 '73', column '28').
    Open

            $criteria->add(new \Criteria('gperm_modid', $moduleId));
    Severity: Minor
    Found in class/PublicCategoryHandler.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\Extgallery\PublicPermHandler' in method 'getPermHandler'.
    Open

            return Extgallery\PublicPermHandler::getInstance();
    Severity: Minor
    Found in class/PublicCategoryHandler.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 '$glist'.
    Open

            $glist         = $memberHandler->getGroupList();
    Severity: Minor
    Found in class/PublicCategoryHandler.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 '$groups'.
    Open

            $groups           = $GLOBALS['xoopsUser']->getGroups();
    Severity: Minor
    Found in class/PublicCategoryHandler.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 variables with short names like $db. Configured minimum length is 3.
    Open

        public function __construct(\XoopsDatabase $db = null)
    Severity: Minor
    Found in class/PublicCategoryHandler.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Line exceeds 120 characters; contains 134 characters
    Open

                        $grouppermHandler->addRight($permMask['name'], $cat->getVar('cat_id'), $perm->getVar('gperm_groupid'), $moduleId);

    Line exceeds 120 characters; contains 134 characters
    Open

                        $grouppermHandler->addRight($permMask['name'], $cat->getVar('cat_id'), $perm->getVar('gperm_groupid'), $moduleId);

    There are no issues that match your filters.

    Category
    Status