mambax7/extgallery

View on GitHub
assets/js/ml-slider/inc/metaslider.widget.class.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method form has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function form($instance)
    {
        $selected_slider = 0;
        $title           = '';
        $sliders         = false;
Severity: Minor
Found in assets/js/ml-slider/inc/metaslider.widget.class.php - About 1 hr to fix

    Function form has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function form($instance)
        {
            $selected_slider = 0;
            $title           = '';
            $sliders         = false;
    Severity: Minor
    Found in assets/js/ml-slider/inc/metaslider.widget.class.php - About 35 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

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

                    echo $before_title . $title . $after_title;

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

                echo $before_widget;

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

                    echo $before_title . $title . $after_title;

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

                echo $after_widget;

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

        } else {
            _e('No slideshows found', 'metaslider');
        } ?>

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

        public function update($new_instance, $old_instance)

    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

    Avoid unused local variables such as '$after_widget'.
    Open

                echo $after_widget;

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

                    echo $before_title . $title . $after_title;

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

                echo $before_widget;

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

                    echo $before_title . $title . $after_title;

    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

    Each class must be in a namespace of at least one level (a top-level vendor name)
    Open

    class MetaSlider_Widget extends WP_Widget

    The parameter $old_instance is not named in camelCase.
    Open

        public function update($new_instance, $old_instance)
        {
            $instance              = [];
            $instance['slider_id'] = strip_tags($new_instance['slider_id']);
            $instance['title']     = strip_tags($new_instance['title']);

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

        public function update($new_instance, $old_instance)
        {
            $instance              = [];
            $instance['slider_id'] = strip_tags($new_instance['slider_id']);
            $instance['title']     = strip_tags($new_instance['title']);

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

    class MetaSlider_Widget extends WP_Widget
    {
        /**
         * Register widget with WordPress.
         */

    CamelCaseClassName

    Since: 0.2

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

    Example

    class class_name {
    }

    Source

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

    <?php

    Line exceeds 120 characters; contains 189 characters
    Open

                <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>">

    Line exceeds 120 characters; contains 126 characters
    Open

            <select id="<?php echo $this->get_field_id('slider_id'); ?>" name="<?php echo $this->get_field_name('slider_id'); ?>">

    Line exceeds 120 characters; contains 121 characters
    Open

            <label for="<?php echo $this->get_field_id('slider_id'); ?>"><?php _e('Select Slider:', 'metaslider'); ?></label>

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        } ?>

    Closing brace indented incorrectly; expected 8 spaces, found 4
    Open

        } else {

    Multi-line function call not indented correctly; expected 12 spaces but found 28
    Open

                                ['description' => __('Meta Slider', 'metaslider')] // Args

    Multi-line function call not indented correctly; expected 12 spaces but found 28
    Open

                                'Meta Slider', // Name

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        } else {

    Class name "MetaSlider_Widget" is not in camel caps format
    Open

    class MetaSlider_Widget extends WP_Widget

    Opening parenthesis of a multi-line function call must be the last content on the line
    Open

            parent::__construct('metaslider_widget', // Base ID

    The variable $before_widget is not named in camelCase.
    Open

        public function widget($args, $instance)
        {
            extract($args);
    
            if (isset($instance['slider_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_instance is not named in camelCase.
    Open

        public function update($new_instance, $old_instance)
        {
            $instance              = [];
            $instance['slider_id'] = strip_tags($new_instance['slider_id']);
            $instance['title']     = strip_tags($new_instance['title']);

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

        public function widget($args, $instance)
        {
            extract($args);
    
            if (isset($instance['slider_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 $slider_id is not named in camelCase.
    Open

        public function widget($args, $instance)
        {
            extract($args);
    
            if (isset($instance['slider_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_instance is not named in camelCase.
    Open

        public function update($new_instance, $old_instance)
        {
            $instance              = [];
            $instance['slider_id'] = strip_tags($new_instance['slider_id']);
            $instance['title']     = strip_tags($new_instance['title']);

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

        public function form($instance)
        {
            $selected_slider = 0;
            $title           = '';
            $sliders         = false;

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

        public function widget($args, $instance)
        {
            extract($args);
    
            if (isset($instance['slider_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 $before_title is not named in camelCase.
    Open

        public function widget($args, $instance)
        {
            extract($args);
    
            if (isset($instance['slider_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 $selected_slider is not named in camelCase.
    Open

        public function form($instance)
        {
            $selected_slider = 0;
            $title           = '';
            $sliders         = false;

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

        public function form($instance)
        {
            $selected_slider = 0;
            $title           = '';
            $sliders         = false;

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

        public function widget($args, $instance)
        {
            extract($args);
    
            if (isset($instance['slider_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

    There are no issues that match your filters.

    Category
    Status