mambax7/alumni-26x

View on GitHub
admin/category.php

Summary

Maintainability
D
1 day
Test Coverage

Method alumniCategoryDisplayChildren has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function alumniCategoryDisplayChildren($cid = 0, $categoryArray, $prefix = '', $order = '', &$class)
        {
            $xoops = Xoops::getInstance();

            $moduleDirName = basename(dirname(__DIR__));
Severity: Minor
Found in admin/category.php - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                        if (isset($cat_url)) {
                            $args = implode('&', $cat_url);
                        }
    Severity: Major
    Found in admin/category.php - About 45 mins to fix

      Method alumniCategoryDisplayChildren has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              function alumniCategoryDisplayChildren($cid = 0, $categoryArray, $prefix = '', $order = '', &$class)
      Severity: Minor
      Found in admin/category.php - About 35 mins to fix

        Missing class import via use statement (line '81', column '42').
        Open

                        $criteria2         = new CriteriaCompo();
        Severity: Minor
        Found in admin/category.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 '82', column '37').
        Open

                        $criteria2->add(new Criteria('pid', $categoryArray[$i]->getVar('cid')));
        Severity: Minor
        Found in admin/category.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 'Xoops' in method 'alumniCategoryDisplayChildren'.
        Open

                    $xoops = Xoops::getInstance();
        Severity: Minor
        Found in admin/category.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 '$pid'.
        Open

                        $pid   = $categoryArray[$i]->getVar('pid');
        Severity: Minor
        Found in admin/category.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 '$title'.
        Open

                        $title = $categoryArray[$i]->getVar('title');
        Severity: Minor
        Found in admin/category.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 '$img'.
        Open

                        $img   = $categoryArray[$i]->getVar('img');
        Severity: Minor
        Found in admin/category.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

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

                if (!empty($_FILES['scphoto']['name'])) {
                    include_once XOOPS_ROOT_PATH . '/class/uploader.php';
                    $uploaddir        = XOOPS_ROOT_PATH . "/uploads/{$moduleDirName}/photos/school_photos";
                    $photomax         = $xoops->getModuleConfig('alumni_photomax');
                    $maxwide          = $xoops->getModuleConfig('alumni_maxwide');
        Severity: Major
        Found in admin/category.php and 2 other locations - About 1 day to fix
        admin/alumni.php on lines 221..241
        admin/alumni.php on lines 243..263

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

        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 (isset($ok) && 1 == $ok) {
                    if (!$xoops->security()->check()) {
                        $xoops->redirect('category.php', 3, implode(',', $xoops->security()->getErrors()));
                    }
                    if ($categoriesHandler->delete($obj)) {
        Severity: Major
        Found in admin/category.php and 1 other location - About 3 hrs to fix
        admin/alumni.php on lines 302..313

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

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

        <?php
        Severity: Minor
        Found in admin/category.php by phpcodesniffer

        The CASE body must start on the line following the statement
        Open

            case 'edit_category':
        Severity: Minor
        Found in admin/category.php by phpcodesniffer

        Line exceeds 120 characters; contains 203 characters
        Open

                            echo '<td align="center"><img src="' . XOOPS_URL . "/modules/{$moduleDirName}/assets/images/cat/" . $categoryArray2[$i]->getVar('img') . '" height="16px" title="img" alt="img"></td>';
        Severity: Minor
        Found in admin/category.php by phpcodesniffer

        Line exceeds 120 characters; contains 121 characters
        Open

                    $prefix        = $prefix . '<img src=\'' . XOOPS_URL . "/modules/{$moduleDirName}/assets/images/arrow.gif'>";
        Severity: Minor
        Found in admin/category.php by phpcodesniffer

        Line exceeds 120 characters; contains 198 characters
        Open

                        echo '<td align="center"><img src="' . XOOPS_URL . "/modules/{$moduleDirName}/assets/images/cat/" . $categoryArray[$i]->getVar('img') . '" height="16px" title="img" alt="img"></td>';
        Severity: Minor
        Found in admin/category.php by phpcodesniffer

        Line exceeds 120 characters; contains 224 characters
        Open

                    echo $xoops->confirm(['ok' => 1, 'cid' => $cid, 'op' => 'delete_category'], 'category.php', XoopsLocale::Q_ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_ITEM . '<br><span class="red">' . $obj->getVar('title') . '<span>');
        Severity: Minor
        Found in admin/category.php by phpcodesniffer

        Arguments with default values must be at the end of the argument list
        Open

                function alumniCategoryDisplayChildren($cid = 0, $categoryArray, $prefix = '', $order = '', &$class)
        Severity: Minor
        Found in admin/category.php by phpcodesniffer

        Line exceeds 120 characters; contains 232 characters
        Open

                                <a href='category.php?op=delete_category&cid=" . $categoryArray[$i]->getVar('cid') . "'><img src='../images/dele.gif' alt='" . XoopsLocale::A_DELETE . "' title='" . XoopsLocale::A_DELETE . "'></a></td></tr>";
        Severity: Minor
        Found in admin/category.php by phpcodesniffer

        Line exceeds 120 characters; contains 225 characters
        Open

                        <a href='category.php?op=delete_category&cid=" . $categoryArray2[$i]->getVar('cid') . "'><img src='../images/dele.gif' alt='" . XoopsLocale::A_DELETE . "' title='" . XoopsLocale::A_DELETE . "'></a></td></tr>";
        Severity: Minor
        Found in admin/category.php by phpcodesniffer

        Line exceeds 120 characters; contains 214 characters
        Open

                                <a href='category.php?op=edit_category&cid=" . $categoryArray[$i]->getVar('cid') . "'><img src='../images/edit.gif' alt='" . XoopsLocale::A_EDIT . "' title='" . XoopsLocale::A_EDIT . "'></a>
        Severity: Minor
        Found in admin/category.php by phpcodesniffer

        Line exceeds 120 characters; contains 207 characters
        Open

                        <a href='category.php?op=edit_category&cid=" . $categoryArray2[$i]->getVar('cid') . "'><img src='../images/edit.gif' alt='" . XoopsLocale::A_EDIT . "' title='" . XoopsLocale::A_EDIT . "'></a>
        Severity: Minor
        Found in admin/category.php by phpcodesniffer

        The variable $cat_pid is not named in camelCase.
        Open

                function alumniCategoryDisplayChildren($cid = 0, $categoryArray, $prefix = '', $order = '', &$class)
                {
                    $xoops = Xoops::getInstance();
        
                    $moduleDirName = basename(dirname(__DIR__));
        Severity: Minor
        Found in admin/category.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 $num_pid is not named in camelCase.
        Open

                function alumniCategoryDisplayChildren($cid = 0, $categoryArray, $prefix = '', $order = '', &$class)
                {
                    $xoops = Xoops::getInstance();
        
                    $moduleDirName = basename(dirname(__DIR__));
        Severity: Minor
        Found in admin/category.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 $num_pid is not named in camelCase.
        Open

                function alumniCategoryDisplayChildren($cid = 0, $categoryArray, $prefix = '', $order = '', &$class)
                {
                    $xoops = Xoops::getInstance();
        
                    $moduleDirName = basename(dirname(__DIR__));
        Severity: Minor
        Found in admin/category.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_pid is not named in camelCase.
        Open

                function alumniCategoryDisplayChildren($cid = 0, $categoryArray, $prefix = '', $order = '', &$class)
                {
                    $xoops = Xoops::getInstance();
        
                    $moduleDirName = basename(dirname(__DIR__));
        Severity: Minor
        Found in admin/category.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