core/modules/admin/AdminSystemController.php

Summary

Maintainability
C
7 hrs
Test Coverage

The class AdminSystemController has 11 public methods. Consider refactoring AdminSystemController to keep number of public methods under 10.
Open

class AdminSystemController extends AdminController
{
    protected $_allowedActions = [
        'chromeApp',
        'chromeAppDownload',

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

File AdminSystemController.php has 266 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

class AdminSystemController extends AdminController
{
    protected $_allowedActions = [
Severity: Minor
Found in core/modules/admin/AdminSystemController.php - About 2 hrs to fix

    Method chromeAppDownload has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function chromeAppDownload()
        {
            // Temp dir
            $appdir = TMP_DIR.'app'.DIRECTORY_SEPARATOR;
            mkdir($appdir);
    Severity: Major
    Found in core/modules/admin/AdminSystemController.php - About 2 hrs to fix

      Method check has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function check()
          {
              Ajde::app()->getDocument()->setTitle('System check');
      
              $checks = [];
      Severity: Minor
      Found in core/modules/admin/AdminSystemController.php - About 1 hr to fix

        Function check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function check()
            {
                Ajde::app()->getDocument()->setTitle('System check');
        
                $checks = [];
        Severity: Minor
        Found in core/modules/admin/AdminSystemController.php - About 45 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 method chromeAppDownload() has 107 lines of code. Current threshold is set to 100. Avoid really long methods.
        Open

            public function chromeAppDownload()
            {
                // Temp dir
                $appdir = TMP_DIR.'app'.DIRECTORY_SEPARATOR;
                mkdir($appdir);

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

                $this->getView()->assign('results', $results);

        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 '$results' which will lead to PHP notices.
        Open

                        $results[] = [

        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

        The class AdminSystemController has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13.
        Open

        class AdminSystemController extends AdminController
        {
            protected $_allowedActions = [
                'chromeApp',
                'chromeAppDownload',

        CouplingBetweenObjects

        Since: 1.1.0

        A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

        Example

        class Foo {
            /**
             * @var \foo\bar\X
             */
            private $x = null;
        
            /**
             * @var \foo\bar\Y
             */
            private $y = null;
        
            /**
             * @var \foo\bar\Z
             */
            private $z = null;
        
            public function setFoo(\Foo $foo) {}
            public function setBar(\Bar $bar) {}
            public function setBaz(\Baz $baz) {}
        
            /**
             * @return \SplObjectStorage
             * @throws \OutOfRangeException
             * @throws \InvalidArgumentException
             * @throws \ErrorException
             */
            public function process(\Iterator $it) {}
        
            // ...
        }

        Source https://phpmd.org/rules/design.html#couplingbetweenobjects

        Missing class import via use statement (line '272', column '32').
        Open

                $unused->addFilter(new Ajde_Filter_Where('id', Ajde_Filter::FILTER_EQUALS, '-9999'));

        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 '271', column '23').
        Open

                $unused = new MediaCollection();

        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 '270', column '21').
        Open

                $used = new MediaCollection();

        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 '138', column '20').
        Open

                $zip = new ZipArchive();

        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 '304', column '25').
        Open

                $allMedia = new MediaCollection();

        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 'Ajde_Fs_Find' in method 'chromeAppDownload'.
        Open

                $appfiles = Ajde_Fs_Find::findFiles($appdir, '*');

        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 'Ajde_Session_Flash' in method 'doCleanuploads'.
        Open

                Ajde_Session_Flash::alert('Orphan files cleaned');

        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 'Ajde_Core_Updater' in method 'updateHtml'.
        Open

                $updater = Ajde_Core_Updater::getInstance();

        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 'Ajde_Core_Updater' in method 'updateJson'.
        Open

                    $updater = Ajde_Core_Updater::getInstance();

        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 'Ajde_Fs_Directory' in method 'chromeAppDownload'.
        Open

                Ajde_Fs_Directory::truncate($appdir);

        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 'Ajde_Session_Flash' in method 'doCleanthumbs'.
        Open

                Ajde_Session_Flash::alert('Thumbnails will be refreshed next time they are loaded');

        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 'Ajde_Session_Flash' in method 'doDeleteunused'.
        Open

                Ajde_Session_Flash::alert('Unused media deleted');

        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 'Ajde_Fs_Directory' in method 'chromeAppDownload'.
        Open

                Ajde_Fs_Directory::delete($appdir);

        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 assigning values to variables in if clauses and the like (line '308', column '18').
        Open

            private function _tobecleaned()
            {
                $allMedia = new MediaCollection();
                $toBeCleaned = Ajde_Fs_Find::findFilenames(UPLOAD_DIR, '*.*');
        
        

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

        Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

        Avoid using static access to class 'Ajde_Exception_Log' in method 'updateJson'.
        Open

                        Ajde_Exception_Log::logException($e);

        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 assigning values to variables in if clauses and the like (line '312', column '18').
        Open

            private function _tobecleaned()
            {
                $allMedia = new MediaCollection();
                $toBeCleaned = Ajde_Fs_Find::findFilenames(UPLOAD_DIR, '*.*');
        
        

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

        Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

        Avoid using static access to class 'Ajde_Fs_Find' in method '_tobecleaned'.
        Open

                $toBeCleaned = Ajde_Fs_Find::findFilenames(UPLOAD_DIR, '*.*');

        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 'Ajde_Fs_Find' in method 'doCleanthumbs'.
        Open

                $toBeCleaned = Ajde_Fs_Find::findFilenames(UPLOAD_DIR.Ajde_Resource_Image::$_thumbDir.DIRECTORY_SEPARATOR,
                    '*.*');

        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 private methods such as 'checkWritable'.
        Open

            private function checkWritable()
            {
                $dirs = [
                    TMP_DIR,
                    LOG_DIR,

        UnusedPrivateMethod

        Since: 0.2

        Unused Private Method detects when a private method is declared but is unused.

        Example

        class Something
        {
            private function foo() {} // unused
        }

        Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

        Avoid unused private methods such as 'checkProduction'.
        Open

            private function checkProduction()
            {
                $files = [
                    'phpinfo.php',
                    'loadtest.php',

        UnusedPrivateMethod

        Since: 0.2

        Unused Private Method detects when a private method is declared but is unused.

        Example

        class Something
        {
            private function foo() {} // unused
        }

        Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

        The method chromeAppDownload() contains an exit expression.
        Open

                exit;

        ExitExpression

        Since: 0.2

        An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

        Example

        class Foo {
            public function bar($param)  {
                if ($param === 42) {
                    exit(23);
                }
            }
        }

        Source https://phpmd.org/rules/design.html#exitexpression

        The property $_allowedActions is not named in camelCase.
        Open

        class AdminSystemController extends AdminController
        {
            protected $_allowedActions = [
                'chromeApp',
                'chromeAppDownload',

        CamelCasePropertyName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name attributes.

        Example

        class ClassName {
            protected $property_name;
        }

        Source

        Avoid variables with short names like $fh. Configured minimum length is 3.
        Open

                $fh = fopen($crxfile, 'wb');

        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

        Avoid variables with short names like $db. Configured minimum length is 3.
        Open

                $db = Ajde_Db::getInstance()->getConnection();

        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

        The method _tobecleaned is not named in camelCase.
        Open

            private function _tobecleaned()
            {
                $allMedia = new MediaCollection();
                $toBeCleaned = Ajde_Fs_Find::findFilenames(UPLOAD_DIR, '*.*');
        
        

        CamelCaseMethodName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name methods.

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method _unused is not named in camelCase.
        Open

            private function _unused()
            {
                $used = new MediaCollection();
                $unused = new MediaCollection();
                $unused->addFilter(new Ajde_Filter_Where('id', Ajde_Filter::FILTER_EQUALS, '-9999'));

        CamelCaseMethodName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name methods.

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        There are no issues that match your filters.

        Category
        Status