core/modules/_core/_coreComponentController.php

Summary

Maintainability
A
1 hr
Test Coverage

The class _coreComponentController has 12 public methods. Consider refactoring _coreComponentController to keep number of public methods under 10.
Open

class _coreComponentController extends Ajde_Controller
{
    /************************
     * Ajde_Component_Resource
     ************************/

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

Method formUploadJson has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function formUploadJson()
    {
        if (!Ajde::app()->getRequest()->hasPostParam('optionsId')) {
            return ['error' => 'Something went wrong'];
        }
Severity: Minor
Found in core/modules/_core/_coreComponentController.php - About 1 hr to fix

    Missing class import via use statement (line '102', column '23').
    Open

            $helper = new Ajde_Component_Form_UploadHelper();

    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 '98', column '24').
    Open

            $session = new Ajde_Session('AC.Form');

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

                throw new Ajde_Controller_Exception('Resource type could not be loaded');

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

            $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);

    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 '79', column '24').
    Open

            $session = new Ajde_Session('AC.Form');

    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_Component_String' in method 'formUploadJson'.
    Open

            $max_post = Ajde_Component_String::toBytes(ini_get('post_max_size'));

    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_Resource_Qrcode' in method 'qrcodeData'.
    Open

            $qr = Ajde_Resource_Qrcode::fromFingerprint($fingerprint);

    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_Component_String' in method 'formUploadJson'.
    Open

            $memory_limit = Ajde_Component_String::toBytes(ini_get('memory_limit'));

    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

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

            } else {
                $this->getView()->assign('href', $image->getLinkUrl());
            }

    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 'Ajde_Embed' in method 'embedInfoJson'.
    Open

            $embed = Ajde_Embed::fromCode($raw);

    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

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

            } else {
                return ['success' => false];
            }

    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 'Ajde_Component_String' in method 'formUploadJson'.
    Open

            $max_upload = Ajde_Component_String::toBytes(ini_get('upload_max_filesize'));

    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 'formUploadJson'.
    Open

                $filelist = Ajde_Fs_Find::findFiles($saveDir, $filename.'_*.'.$extension);

    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_Resource_Image' in method 'imageData'.
    Open

            $image = Ajde_Resource_Image::fromFingerprint($fingerprint);

    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 '$helper'.
    Open

            $helper = new Ajde_Component_Form_UploadHelper();

    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 class _coreComponentController is not named in CamelCase.
    Open

    class _coreComponentController extends Ajde_Controller
    {
        /************************
         * Ajde_Component_Resource
         ************************/

    CamelCaseClassName

    Since: 0.2

    It is considered best practice to use the CamelCase notation to name classes.

    Example

    class class_name {
    }

    Source

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

            $qr = $this->getQrcode();

    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 $qr. Configured minimum length is 3.
    Open

            $qr = Ajde_Resource_Qrcode::fromFingerprint($fingerprint);

    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 variable $max_post is not named in camelCase.
    Open

        public function formUploadJson()
        {
            if (!Ajde::app()->getRequest()->hasPostParam('optionsId')) {
                return ['error' => 'Something went wrong'];
            }

    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 $memory_limit is not named in camelCase.
    Open

        public function formUploadJson()
        {
            if (!Ajde::app()->getRequest()->hasPostParam('optionsId')) {
                return ['error' => 'Something went wrong'];
            }

    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 $memory_limit is not named in camelCase.
    Open

        public function formUploadJson()
        {
            if (!Ajde::app()->getRequest()->hasPostParam('optionsId')) {
                return ['error' => 'Something went wrong'];
            }

    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 $max_upload is not named in camelCase.
    Open

        public function formUploadJson()
        {
            if (!Ajde::app()->getRequest()->hasPostParam('optionsId')) {
                return ['error' => 'Something went wrong'];
            }

    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 $max_upload is not named in camelCase.
    Open

        public function formUploadJson()
        {
            if (!Ajde::app()->getRequest()->hasPostParam('optionsId')) {
                return ['error' => 'Something went wrong'];
            }

    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 $max_post is not named in camelCase.
    Open

        public function formUploadJson()
        {
            if (!Ajde::app()->getRequest()->hasPostParam('optionsId')) {
                return ['error' => 'Something went wrong'];
            }

    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 method _getLocalResource is not named in camelCase.
    Open

        protected function _getLocalResource()
        {
            return $this->_getResource('Ajde_Resource_Local');
        }

    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 _getCompressedResource is not named in camelCase.
    Open

        protected function _getCompressedResource()
        {
            return $this->_getResource('Ajde_Resource_Local_Compressed');
        }

    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 _getResource is not named in camelCase.
    Open

        protected function _getResource($className)
        {
            // get resource from request
            $fingerprint = Ajde::app()->getRequest()->getRaw('id');
            if (!class_exists($className)) {

    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