XoopsModules25x/contact

View on GitHub

Showing 495 of 495 total issues

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

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

        $criteria->add(new \Criteria('contact_type', 'Contact'));
Severity: Minor
Found in class/ContactHandler.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 '370', column '28').
Open

        $criteria->add(new \Criteria('contact_type', 'Contact'));
Severity: Minor
Found in class/ContactHandler.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 '480', column '28').
Open

        $criteria->add(new \Criteria('contact_cid', '0'));
Severity: Minor
Found in class/ContactHandler.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 '369', column '28').
Open

        $criteria->add(new \Criteria($id, '0'));
Severity: Minor
Found in class/ContactHandler.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 '340', column '28').
Open

        $criteria->add(new \Criteria($id, '0'));
Severity: Minor
Found in class/ContactHandler.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 '407', column '25').
Open

        $criteria = new \CriteriaCompo();
Severity: Minor
Found in class/ContactHandler.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

Function contactToEmails has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function contactToEmails($department = null)
    {
        //        global $xoopsConfig;
        $department_mail[] = \xoops_getModuleOption('contact_recipient_std', 'contact');
        if (!empty($department)) {
Severity: Minor
Found in class/ContactHandler.php - About 25 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

Function createFolder has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function createFolder($folder)
    {
        //        try {
        //            if (!mkdir($folder) && !is_dir($folder)) {
        //                throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder));
Severity: Minor
Found in class/Utility.php - About 25 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

Function xoops_module_install_contact has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function xoops_module_install_contact(\XoopsModule $module)
{
    require dirname(__DIR__, 3) . '/mainfile.php';

    $moduleDirName = \basename(\dirname(__DIR__));
Severity: Minor
Found in include/oninstall.php - About 25 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

The function listBlocks() has 230 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    function listBlocks()
    {
        global $xoopsModule, $pathIcon16;
        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
        $moduleDirName = basename(dirname(__DIR__));
Severity: Minor
Found in admin/blocksadmin.php by phpmd

The method listBlocks uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $cachetimeOptions .= "<option value='$cachetime'>$cachetimeName</option>\n";
                }
Severity: Minor
Found in admin/blocksadmin.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 unused local variables such as '$moduleDirName'.
Open

    $moduleDirName = \basename(\dirname(__DIR__));
Severity: Minor
Found in include/onupdate.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 using static access to class '\XoopsModules\Contact\Helper' in method 'xoops_module_pre_update_contact'.
Open

    $helper        = Helper::getInstance();
Severity: Minor
Found in include/onupdate.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 '$k'.
Open

                    foreach ($templateList as $k => $v) {
Severity: Minor
Found in include/onupdate.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 method listBlocks uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $sel0 = ' checked';
            }
Severity: Minor
Found in admin/blocksadmin.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 '\XoopsDatabaseFactory' in method 'cloneBlock'.
Open

        $db = \XoopsDatabaseFactory::getDatabaseConnection();
Severity: Minor
Found in admin/blocksadmin.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 '$bmodule'.
Open

    function setOrder($bid, $title, $weight, $visible, $side, $bcachetime, $bmodule)
Severity: Minor
Found in admin/blocksadmin.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

The function xoops_module_update_contact() has 146 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

function xoops_module_update_contact(\XoopsModule $module, $previousVersion = null)
{
    $moduleDirName      = \basename(\dirname(__DIR__));
    $moduleDirNameUpper = mb_strtoupper($moduleDirName);

Severity: Minor
Found in include/onupdate.php by phpmd

Avoid using static access to class '\XoopsModules\Contact\Helper' in method 'contactGetElements'.
Open

    $helper = Contact\Helper::getInstance();
Severity: Minor
Found in blocks/block_contact_form_map.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

Severity
Category
Status
Source
Language