kai-jacobsen/kontentblocks

View on GitHub
core/Ajax/Actions/Frontend/UpdateModule.php

Summary

Maintainability
A
1 hr
Test Coverage

Method action has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function action(Request $request, $send = true)
    {
        global $post;

        $postdata = self::setupPostData($request);
Severity: Minor
Found in core/Ajax/Actions/Frontend/UpdateModule.php - About 1 hr to fix

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

            $stdClass = new \stdClass();

    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

    The method action has a boolean flag argument $send, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public static function action(Request $request, $send = true)

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    Avoid using static access to class '\Kontentblocks\Utils\Utilities' in method 'action'.
    Open

            $environment = Utilities::getPostEnvironment($postdata->postId);

    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 '\Kontentblocks\Utils\Utilities' in method 'action'.
    Open

                    $targetEnv = Utilities::getPostEnvironment($revid);

    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 '\Kontentblocks\Utils\Utilities' in method 'action'.
    Open

            $mergedData = Utilities::arrayMergeRecursive($new, $old);

    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 '\Kontentblocks\Utils\Utilities' in method 'action'.
    Open

            Utilities::remoteConcatGet($module->properties->postId);

    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

    There are no issues that match your filters.

    Category
    Status