mambax7/songlist

View on GitHub
class/Form/SelectVoiceForm.php

Summary

Maintainability
F
6 days
Test Coverage

Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function __construct($caption, $name, $value = null, $size = 1, $multiple = false)
Severity: Minor
Found in class/Form/SelectVoiceForm.php - About 35 mins to fix

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

        public function __construct($caption, $name, $value = null, $size = 1, $multiple = false)
        {
            global $_form_object_options;
            \xoops_loadLanguage('modinfo', 'songlist');
    
    
    Severity: Minor
    Found in class/Form/SelectVoiceForm.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

    Function render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function render(): string
        {
            $ele_name    = $this->getName();
            $ele_title   = $this->getTitle();
            $ele_value   = $this->getValue();
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php - About 25 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 getOptions has a boolean flag argument $encode, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function getOptions($encode = false): array
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

    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

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

        public function getValue($encode = false): array
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

    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

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

        public function __construct($caption, $name, $value = null, $size = 1, $multiple = false)
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

    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

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

            } else {
                $ret .= ' name="' . $ele_name . '" id="' . $ele_name . '" title="' . $ele_title . '">';
            }
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

    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

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

            } else {
                $this->_options[$value] = $value;
            }
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

    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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    <?php declare(strict_types=1);
    
    namespace XoopsModules\Songlist\Form;
    
    /*
    Severity: Major
    Found in class/Form/SelectVoiceForm.php and 1 other location - About 5 days to fix
    class/Form/SelectGenreForm.php on lines 1..282

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 1049.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    The property $_options is not named in camelCase.
    Open

    class SelectVoiceForm extends XoopsFormElement
    {
        /**
         * Options
         *
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

    CamelCasePropertyName

    Since: 0.2

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

    Example

    class ClassName {
        protected $property_name;
    }

    Source

    The property $_multiple is not named in camelCase.
    Open

    class SelectVoiceForm extends XoopsFormElement
    {
        /**
         * Options
         *
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

    CamelCasePropertyName

    Since: 0.2

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

    Example

    class ClassName {
        protected $property_name;
    }

    Source

    The property $_size is not named in camelCase.
    Open

    class SelectVoiceForm extends XoopsFormElement
    {
        /**
         * Options
         *
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

    CamelCasePropertyName

    Since: 0.2

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

    Example

    class ClassName {
        protected $property_name;
    }

    Source

    The property $_value is not named in camelCase.
    Open

    class SelectVoiceForm extends XoopsFormElement
    {
        /**
         * Options
         *
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

    CamelCasePropertyName

    Since: 0.2

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

    Example

    class ClassName {
        protected $property_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 54 and the first side effect is on line 44.
    Open

    <?php declare(strict_types=1);

    Property name "$_value" should not be prefixed with an underscore to indicate visibility
    Open

        public $_value = [];

    Property name "$_size" should not be prefixed with an underscore to indicate visibility
    Open

        public $_size;

    Property name "$_options" should not be prefixed with an underscore to indicate visibility
    Open

        public $_options = [];

    Property name "$_multiple" should not be prefixed with an underscore to indicate visibility
    Open

        public $_multiple = false;

    Line exceeds 120 characters; contains 121 characters
    Open

                $ret .= ' name="' . $ele_name . '[]" id="' . $ele_name . '" title="' . $ele_title . '" multiple="multiple">';

    Line exceeds 120 characters; contains 123 characters
    Open

         * Note: both name and value should be sanitized. However, for backward compatibility, only value is sanitized for now.

    Line exceeds 120 characters; contains 149 characters
    Open

                       . 'for (i = 0; i < selectBox.options.length; i++ ) { if (selectBox.options[i].selected === true) { hasSelected = true; break; } }'

    Line exceeds 120 characters; contains 138 characters
    Open

                $value[$encode ? \htmlspecialchars($val, \ENT_QUOTES) : $val] = ($encode > 1) ? \htmlspecialchars($name, \ENT_QUOTES) : $name;

    Line exceeds 120 characters; contains 129 characters
    Open

         * @param bool|int $encode To sanitizer the text? potential values: 0 - skip; 1 - only for value; 2 - for both value and name

    The variable $ele_name is not named in camelCase.
    Open

        public function render(): string
        {
            $ele_name    = $this->getName();
            $ele_title   = $this->getTitle();
            $ele_value   = $this->getValue();
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function render(): string
        {
            $ele_name    = $this->getName();
            $ele_title   = $this->getTitle();
            $ele_value   = $this->getValue();
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function render(): string
        {
            $ele_name    = $this->getName();
            $ele_title   = $this->getTitle();
            $ele_value   = $this->getValue();
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function render(): string
        {
            $ele_name    = $this->getName();
            $ele_title   = $this->getTitle();
            $ele_value   = $this->getValue();
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function render(): string
        {
            $ele_name    = $this->getName();
            $ele_title   = $this->getTitle();
            $ele_value   = $this->getValue();
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function __construct($caption, $name, $value = null, $size = 1, $multiple = false)
        {
            global $_form_object_options;
            \xoops_loadLanguage('modinfo', 'songlist');
    
    
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function render(): string
        {
            $ele_name    = $this->getName();
            $ele_title   = $this->getTitle();
            $ele_value   = $this->getValue();
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function render(): string
        {
            $ele_name    = $this->getName();
            $ele_title   = $this->getTitle();
            $ele_value   = $this->getValue();
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function __construct($caption, $name, $value = null, $size = 1, $multiple = false)
        {
            global $_form_object_options;
            \xoops_loadLanguage('modinfo', 'songlist');
    
    
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function render(): string
        {
            $ele_name    = $this->getName();
            $ele_title   = $this->getTitle();
            $ele_value   = $this->getValue();
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function __construct($caption, $name, $value = null, $size = 1, $multiple = false)
        {
            global $_form_object_options;
            \xoops_loadLanguage('modinfo', 'songlist');
    
    
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function render(): string
        {
            $ele_name    = $this->getName();
            $ele_title   = $this->getTitle();
            $ele_value   = $this->getValue();
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function __construct($caption, $name, $value = null, $size = 1, $multiple = false)
        {
            global $_form_object_options;
            \xoops_loadLanguage('modinfo', 'songlist');
    
    
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function __construct($caption, $name, $value = null, $size = 1, $multiple = false)
        {
            global $_form_object_options;
            \xoops_loadLanguage('modinfo', 'songlist');
    
    
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function render(): string
        {
            $ele_name    = $this->getName();
            $ele_title   = $this->getTitle();
            $ele_value   = $this->getValue();
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function render(): string
        {
            $ele_name    = $this->getName();
            $ele_title   = $this->getTitle();
            $ele_value   = $this->getValue();
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function render(): string
        {
            $ele_name    = $this->getName();
            $ele_title   = $this->getTitle();
            $ele_value   = $this->getValue();
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

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

        public function render(): string
        {
            $ele_name    = $this->getName();
            $ele_title   = $this->getTitle();
            $ele_value   = $this->getValue();
    Severity: Minor
    Found in class/Form/SelectVoiceForm.php by phpmd

    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