kai-jacobsen/kontentblocks

View on GitHub
core/Extensions/LayoutConfigurations.php

Summary

Maintainability
A
0 mins
Test Coverage

getConfigurations accesses the super-global variable $_REQUEST.
Open

    public function getConfigurations()
    {
        check_ajax_referer( 'kb-read' );

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Avoid using static access to class '\Kontentblocks\Language\I18n' in method 'metaBox'.
Open

        $i18n = I18n::getPackage( 'Extensions.layoutConfigs' );

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 getConfigurations uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            wp_send_json_error();
        }

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 parameters such as '$post_id'.
Open

    private function _deleteConfiguration( $config, $id, $post_id )

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

TODO found
Open

     * @TODO add message for success/failure

The parameter $post_id is not named in camelCase.
Open

    private function _deleteConfiguration( $config, $id, $post_id )
    {
        $configurations = get_option( 'kb_layout_configurations' );
        $bucket = ( !empty( $configurations[$config] ) ) ? $configurations[$config] : array();

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

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

    private function _deleteConfiguration( $config, $id, $post_id )

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

    private function saveConfiguration( $config, $name, $post_id )
    {

        $configurations = get_option( 'kb_layout_configurations' );
        $id = sanitize_title( $name );

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The parameter $post_id is not named in camelCase.
Open

    private function prepareFromConfiguration( $index, $post_id )
    {
        $i = 1;
        $collection = array();
        $Storage = new ModuleStorage( $post_id );

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

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

        $id = sanitize_title( $name );

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

        $i = 1;

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

    private function normalizeConfiguration( $post_id )
    {
        $collection = array();
        $layout = get_post_meta( $post_id, 'kb_kontentblocks', true );

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The variable $post_id is not named in camelCase.
Open

    private function normalizeConfiguration( $post_id )
    {
        $collection = array();
        $layout = get_post_meta( $post_id, 'kb_kontentblocks', true );

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

    public function observeQuery()
    {
        $input = filter_input_array(
            INPUT_GET,
            array(

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

    public function observeQuery()
    {
        $input = filter_input_array(
            INPUT_GET,
            array(

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

    private function prepareFromConfiguration( $index, $post_id )
    {
        $i = 1;
        $collection = array();
        $Storage = new ModuleStorage( $post_id );

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

    private function saveConfiguration( $config, $name, $post_id )
    {

        $configurations = get_option( 'kb_layout_configurations' );
        $id = sanitize_title( $name );

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

    private function prepareFromConfiguration( $index, $post_id )
    {
        $i = 1;
        $collection = array();
        $Storage = new ModuleStorage( $post_id );

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

    public function setConfiguration()
    {
        check_ajax_referer( 'kb-update' );

        $data = $this->parseAjaxRequest();

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

    private function prepareFromConfiguration( $index, $post_id )
    {
        $i = 1;
        $collection = array();
        $Storage = new ModuleStorage( $post_id );

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

    private function prepareFromConfiguration( $index, $post_id )
    {
        $i = 1;
        $collection = array();
        $Storage = new ModuleStorage( $post_id );

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

    private function prepareFromConfiguration( $index, $post_id )
    {
        $i = 1;
        $collection = array();
        $Storage = new ModuleStorage( $post_id );

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

    private function prepareFromConfiguration( $index, $post_id )
    {
        $i = 1;
        $collection = array();
        $Storage = new ModuleStorage( $post_id );

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

    private function prepareFromConfiguration( $index, $post_id )
    {
        $i = 1;
        $collection = array();
        $Storage = new ModuleStorage( $post_id );

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

    public function deleteConfiguration()
    {
        check_ajax_referer( 'kb-delete' );

        $data = $this->parseAjaxRequest();

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

    public function deleteConfiguration()
    {
        check_ajax_referer( 'kb-delete' );

        $data = $this->parseAjaxRequest();

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

    private function prepareFromConfiguration( $index, $post_id )
    {
        $i = 1;
        $collection = array();
        $Storage = new ModuleStorage( $post_id );

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

    public function setConfiguration()
    {
        check_ajax_referer( 'kb-update' );

        $data = $this->parseAjaxRequest();

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

    private function _deleteConfiguration( $config, $id, $post_id )
    {
        $configurations = get_option( 'kb_layout_configurations' );
        $bucket = ( !empty( $configurations[$config] ) ) ? $configurations[$config] : array();

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