qcubed/framework

View on GitHub
includes/base_controls/QMenuGen.class.php

Summary

Maintainability
C
1 day
Test Coverage

The class QMenuGen has 21 public methods. Consider refactoring QMenuGen to keep number of public methods under 10.
Open

    class QMenuGen extends QPanel    {
        protected $strJavaScripts = __JQUERY_EFFECTS__;
        protected $strStyleSheets = __JQUERY_CSS__;
        /** @var boolean */
        protected $blnDisabled = null;

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

The class QMenuGen has an overall complexity of 55 which is very high. The configured complexity threshold is 50.
Open

    class QMenuGen extends QPanel    {
        protected $strJavaScripts = __JQUERY_EFFECTS__;
        protected $strStyleSheets = __JQUERY_CSS__;
        /** @var boolean */
        protected $blnDisabled = null;

QMenuGen has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

    class QMenuGen extends QPanel    {
        protected $strJavaScripts = __JQUERY_EFFECTS__;
        protected $strStyleSheets = __JQUERY_CSS__;
        /** @var boolean */
        protected $blnDisabled = null;
Severity: Minor
Found in includes/base_controls/QMenuGen.class.php - About 3 hrs to fix

    Method __set has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public function __set($strName, $mixValue) {
                switch ($strName) {
                    case 'Disabled':
                        try {
                            $this->blnDisabled = QType::Cast($mixValue, QType::Boolean);
    Severity: Major
    Found in includes/base_controls/QMenuGen.class.php - About 2 hrs to fix

      Function __set has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

              public function __set($strName, $mixValue) {
                  switch ($strName) {
                      case 'Disabled':
                          try {
                              $this->blnDisabled = QType::Cast($mixValue, QType::Boolean);
      Severity: Minor
      Found in includes/base_controls/QMenuGen.class.php - About 1 hr 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 too many return statements within this method.
      Open

                              return parent::__get($strName); 
      Severity: Major
      Found in includes/base_controls/QMenuGen.class.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        case 'Role': return $this->strRole;
        Severity: Major
        Found in includes/base_controls/QMenuGen.class.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          case 'Position': return $this->mixPosition;
          Severity: Major
          Found in includes/base_controls/QMenuGen.class.php - About 30 mins to fix

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

                    protected function MakeJqOptions() {
                        $jqOptions = null;
                        if (!is_null($val = $this->Disabled)) {$jqOptions['disabled'] = $val;}
                        if (!is_null($val = $this->Icons)) {$jqOptions['icons'] = $val;}
                        if (!is_null($val = $this->Items)) {$jqOptions['items'] = $val;}
            Severity: Minor
            Found in includes/base_controls/QMenuGen.class.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 __set() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
            Open

                    public function __set($strName, $mixValue) {
                        switch ($strName) {
                            case 'Disabled':
                                try {
                                    $this->blnDisabled = QType::Cast($mixValue, QType::Boolean);

            CyclomaticComplexity

            Since: 0.1

            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

            Example

            // Cyclomatic Complexity = 11
            class Foo {
            1   public function example() {
            2       if ($a == $b) {
            3           if ($a1 == $b1) {
                            fiddle();
            4           } elseif ($a2 == $b2) {
                            fiddle();
                        } else {
                            fiddle();
                        }
            5       } elseif ($c == $d) {
            6           while ($c == $d) {
                            fiddle();
                        }
            7        } elseif ($e == $f) {
            8           for ($n = 0; $n < $h; $n++) {
                            fiddle();
                        }
                    } else {
                        switch ($z) {
            9               case 1:
                                fiddle();
                                break;
            10              case 2:
                                fiddle();
                                break;
            11              case 3:
                                fiddle();
                                break;
                            default:
                                fiddle();
                                break;
                        }
                    }
                }
            }

            Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

            Missing class import via use statement (line '483', column '9').
            Open

                            new QModelConnectorParam (get_called_class(), 'Disabled', 'Disables the menu if set to true.', QType::Boolean),

            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 '486', column '9').
            Open

                            new QModelConnectorParam (get_called_class(), 'Role', 'Customize the ARIA roles used for the menu and menu items. The defaultuses \"menuitem\" for items. Setting the role option to \"listbox\" willuse \"option\" for items. If set to null, no roles will be set, which isuseful if the menu is being controlled by another element that ismaintaining focus. Note: The role option should not be changed afterinitialization. Existing (sub)menus and menu items will not beupdated.', QType::String),

            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 '484', column '9').
            Open

                            new QModelConnectorParam (get_called_class(), 'Items', 'Selector for the elements that serve as the menu items. Note: Theitems option should not be changed after initialization. (versionadded: 1.11.0)', QType::String),

            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 '485', column '9').
            Open

                            new QModelConnectorParam (get_called_class(), 'Menus', 'Selector for the elements that serve as the menu container, includingsub-menus. Note: The menus option should not be changed afterinitialization. Existing submenus will not be updated.', QType::String),

            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 assigning values to variables in if clauses and the like (line '130', column '17').
            Open

                    protected function MakeJqOptions() {
                        $jqOptions = null;
                        if (!is_null($val = $this->Disabled)) {$jqOptions['disabled'] = $val;}
                        if (!is_null($val = $this->Icons)) {$jqOptions['icons'] = $val;}
                        if (!is_null($val = $this->Items)) {$jqOptions['items'] = $val;}

            IfStatementAssignment

            Since: 2.7.0

            Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($foo = 'bar') { // possible typo
                        // ...
                    }
                    if ($baz = 0) { // always false
                        // ...
                    }
                }
            }

            Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

            Avoid using static access to class 'QApplication' in method 'Option2'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $optionName, $value, QJsPriority::Low);

            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 'QApplication' in method 'Enable'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "enable", QJsPriority::Low);

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

                        } else {
                            QApplication::ExecuteControlCommand($strId, $strFunc, $jqOptions, QJsPriority::High);
                        }

            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 'QApplication' in method 'Destroy'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "destroy", QJsPriority::Low);

            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 'QApplication' in method 'Previous'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "previous", $event, QJsPriority::Low);

            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 assigning values to variables in if clauses and the like (line '133', column '17').
            Open

                    protected function MakeJqOptions() {
                        $jqOptions = null;
                        if (!is_null($val = $this->Disabled)) {$jqOptions['disabled'] = $val;}
                        if (!is_null($val = $this->Icons)) {$jqOptions['icons'] = $val;}
                        if (!is_null($val = $this->Items)) {$jqOptions['items'] = $val;}

            IfStatementAssignment

            Since: 2.7.0

            Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($foo = 'bar') { // possible typo
                        // ...
                    }
                    if ($baz = 0) { // always false
                        // ...
                    }
                }
            }

            Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

            Avoid using static access to class 'QApplication' in method 'GetEndScript'.
            Open

                            QApplication::ExecuteControlCommand($strId, $strFunc, $jqOptions, QJsPriority::High);

            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 'QApplication' in method 'IsLastItem'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "isLastItem", QJsPriority::Low);

            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 'QApplication' in method 'Next'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "next", $event, QJsPriority::Low);

            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 'QApplication' in method 'NextPage'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "nextPage", $event, QJsPriority::Low);

            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 'QApplication' in method 'Expand'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "expand", $event, QJsPriority::Low);

            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 'QApplication' in method 'Refresh'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "refresh", QJsPriority::Low);

            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 'QApplication' in method 'CollapseAll'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "collapseAll", $event, $all, QJsPriority::Low);

            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 assigning values to variables in if clauses and the like (line '132', column '17').
            Open

                    protected function MakeJqOptions() {
                        $jqOptions = null;
                        if (!is_null($val = $this->Disabled)) {$jqOptions['disabled'] = $val;}
                        if (!is_null($val = $this->Icons)) {$jqOptions['icons'] = $val;}
                        if (!is_null($val = $this->Items)) {$jqOptions['items'] = $val;}

            IfStatementAssignment

            Since: 2.7.0

            Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($foo = 'bar') { // possible typo
                        // ...
                    }
                    if ($baz = 0) { // always false
                        // ...
                    }
                }
            }

            Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

            Avoid using static access to class 'QApplication' in method 'Focus'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "focus", $item, $event, QJsPriority::Low);

            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 'QApplication' in method 'Blur'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "blur", $event, QJsPriority::Low);

            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 'QApplication' in method 'Disable'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "disable", QJsPriority::Low);

            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 'QApplication' in method 'Option1'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", QJsPriority::Low);

            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 'QApplication' in method 'PreviousPage'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "previousPage", $event, QJsPriority::Low);

            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 'QApplication' in method 'GetEndScript'.
            Open

                            QApplication::ExecuteControlCommand($strId, 'off', QJsPriority::High);

            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 'QApplication' in method 'GetEndScript'.
            Open

                            QApplication::ExecuteControlCommand($strId, $strFunc, QJsPriority::High);

            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 'QApplication' in method 'Collapse'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "collapse", $event, QJsPriority::Low);

            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 assigning values to variables in if clauses and the like (line '128', column '17').
            Open

                    protected function MakeJqOptions() {
                        $jqOptions = null;
                        if (!is_null($val = $this->Disabled)) {$jqOptions['disabled'] = $val;}
                        if (!is_null($val = $this->Icons)) {$jqOptions['icons'] = $val;}
                        if (!is_null($val = $this->Items)) {$jqOptions['items'] = $val;}

            IfStatementAssignment

            Since: 2.7.0

            Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($foo = 'bar') { // possible typo
                        // ...
                    }
                    if ($baz = 0) { // always false
                        // ...
                    }
                }
            }

            Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

            Avoid assigning values to variables in if clauses and the like (line '129', column '17').
            Open

                    protected function MakeJqOptions() {
                        $jqOptions = null;
                        if (!is_null($val = $this->Disabled)) {$jqOptions['disabled'] = $val;}
                        if (!is_null($val = $this->Icons)) {$jqOptions['icons'] = $val;}
                        if (!is_null($val = $this->Items)) {$jqOptions['items'] = $val;}

            IfStatementAssignment

            Since: 2.7.0

            Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($foo = 'bar') { // possible typo
                        // ...
                    }
                    if ($baz = 0) { // always false
                        // ...
                    }
                }
            }

            Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

            Avoid using static access to class 'QApplication' in method 'Option'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $optionName, QJsPriority::Low);

            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 'QApplication' in method 'IsFirstItem'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "isFirstItem", QJsPriority::Low);

            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 assigning values to variables in if clauses and the like (line '131', column '17').
            Open

                    protected function MakeJqOptions() {
                        $jqOptions = null;
                        if (!is_null($val = $this->Disabled)) {$jqOptions['disabled'] = $val;}
                        if (!is_null($val = $this->Icons)) {$jqOptions['icons'] = $val;}
                        if (!is_null($val = $this->Items)) {$jqOptions['items'] = $val;}

            IfStatementAssignment

            Since: 2.7.0

            Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($foo = 'bar') { // possible typo
                        // ...
                    }
                    if ($baz = 0) { // always false
                        // ...
                    }
                }
            }

            Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

            Avoid using static access to class 'QApplication' in method 'Instance'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "instance", QJsPriority::Low);

            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 'QApplication' in method 'Option3'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $options, QJsPriority::Low);

            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 'QType' in method '__set'.
            Open

                                    $this->strItems = QType::Cast($mixValue, QType::String);

            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 'QApplication' in method 'Select'.
            Open

                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "select", $event, QJsPriority::Low);

            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 'QType' in method '__set'.
            Open

                                    $this->strRole = QType::Cast($mixValue, QType::String);

            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 'QType' in method '__set'.
            Open

                                    $this->strMenus = QType::Cast($mixValue, QType::String);

            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 'QType' in method '__set'.
            Open

                                    $this->blnDisabled = QType::Cast($mixValue, QType::Boolean);

            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

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

                    public static function GetModelConnectorParams() {
                        return array_merge(parent::GetModelConnectorParams(), array(
                            new QModelConnectorParam (get_called_class(), 'Disabled', 'Disables the menu if set to true.', QType::Boolean),
                            new QModelConnectorParam (get_called_class(), 'Items', 'Selector for the elements that serve as the menu items. Note: Theitems option should not be changed after initialization. (versionadded: 1.11.0)', QType::String),
                            new QModelConnectorParam (get_called_class(), 'Menus', 'Selector for the elements that serve as the menu container, includingsub-menus. Note: The menus option should not be changed afterinitialization. Existing submenus will not be updated.', QType::String),
            Severity: Major
            Found in includes/base_controls/QMenuGen.class.php and 3 other locations - About 2 hrs to fix
            includes/base_controls/QAccordionGen.class.php on lines 411..418
            includes/base_controls/QAutocompleteGen.class.php on lines 501..508
            includes/base_controls/QSpinnerGen.class.php on lines 527..534

            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 126.

            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

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

                    public function __get($strName) {
                        switch ($strName) {
                            case 'Disabled': return $this->blnDisabled;
                            case 'Icons': return $this->mixIcons;
                            case 'Items': return $this->strItems;
            Severity: Major
            Found in includes/base_controls/QMenuGen.class.php and 3 other locations - About 50 mins to fix
            includes/base_controls/QFormBase.class.php on lines 111..128
            includes/base_controls/QImageBrowser.class.php on lines 459..475
            includes/base_controls/QNumericTextBox.class.php on lines 126..150

            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 97.

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

                class QMenu_SelectEvent extends QJqUiEvent {
                    const EventName = 'menuselect';
                }

            CamelCaseClassName

            Since: 0.2

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

            Example

            class class_name {
            }

            Source

            The class QMenu_FocusEvent is not named in CamelCase.
            Open

                class QMenu_FocusEvent extends QJqUiEvent {
                    const EventName = 'menufocus';
                }

            CamelCaseClassName

            Since: 0.2

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

            Example

            class class_name {
            }

            Source

            The class QMenu_BlurEvent is not named in CamelCase.
            Open

                class QMenu_BlurEvent extends QJqUiEvent {
                    const EventName = 'menublur';
                }

            CamelCaseClassName

            Since: 0.2

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

            Example

            class class_name {
            }

            Source

            The class QMenu_CreateEvent is not named in CamelCase.
            Open

                class QMenu_CreateEvent extends QJqUiEvent {
                    const EventName = 'menucreate';
                }

            CamelCaseClassName

            Since: 0.2

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

            Example

            class class_name {
            }

            Source

            Constant EventName should be defined in uppercase
            Open

                    const EventName = 'menublur';

            ConstantNamingConventions

            Since: 0.2

            Class/Interface constant names should always be defined in uppercase.

            Example

            class Foo {
                const MY_NUM = 0; // ok
                const myTest = ""; // fail
            }

            Source https://phpmd.org/rules/naming.html#constantnamingconventions

            Constant EventName should be defined in uppercase
            Open

                    const EventName = 'menuselect';

            ConstantNamingConventions

            Since: 0.2

            Class/Interface constant names should always be defined in uppercase.

            Example

            class Foo {
                const MY_NUM = 0; // ok
                const myTest = ""; // fail
            }

            Source https://phpmd.org/rules/naming.html#constantnamingconventions

            Constant EventName should be defined in uppercase
            Open

                    const EventName = 'menufocus';

            ConstantNamingConventions

            Since: 0.2

            Class/Interface constant names should always be defined in uppercase.

            Example

            class Foo {
                const MY_NUM = 0; // ok
                const myTest = ""; // fail
            }

            Source https://phpmd.org/rules/naming.html#constantnamingconventions

            Constant EventName should be defined in uppercase
            Open

                    const EventName = 'menucreate';

            ConstantNamingConventions

            Since: 0.2

            Class/Interface constant names should always be defined in uppercase.

            Example

            class Foo {
                const MY_NUM = 0; // ok
                const myTest = ""; // fail
            }

            Source https://phpmd.org/rules/naming.html#constantnamingconventions

            The method Expand is not named in camelCase.
            Open

                    public function Expand($event = null) {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "expand", $event, QJsPriority::Low);
                    }

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

                    public function Option1() {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", QJsPriority::Low);
                    }

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

                    public function NextPage($event = null) {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "nextPage", $event, QJsPriority::Low);
                    }

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

                    public function Select($event = null) {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "select", $event, QJsPriority::Low);
                    }

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

                    public function Focus($event = null, $item) {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "focus", $item, $event, QJsPriority::Low);
                    }

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

                    public function Refresh() {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "refresh", QJsPriority::Low);
                    }

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

                    public function Enable() {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "enable", QJsPriority::Low);
                    }

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

                    public function Previous($event = null) {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "previous", $event, QJsPriority::Low);
                    }

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

                    public function Blur($event = null) {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "blur", $event, QJsPriority::Low);
                    }

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

                    public function Next($event = null) {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "next", $event, QJsPriority::Low);
                    }

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

                    public function PreviousPage($event = null) {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "previousPage", $event, QJsPriority::Low);
                    }

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

                    public function Option($optionName) {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $optionName, QJsPriority::Low);
                    }

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

                    public function Option3($options) {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $options, QJsPriority::Low);
                    }

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

                    public function Destroy() {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "destroy", QJsPriority::Low);
                    }

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

                    public function CollapseAll($event = null, $all = null) {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "collapseAll", $event, $all, QJsPriority::Low);
                    }

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

                    public function IsLastItem() {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "isLastItem", QJsPriority::Low);
                    }

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

                    protected function MakeJqOptions() {
                        $jqOptions = null;
                        if (!is_null($val = $this->Disabled)) {$jqOptions['disabled'] = $val;}
                        if (!is_null($val = $this->Icons)) {$jqOptions['icons'] = $val;}
                        if (!is_null($val = $this->Items)) {$jqOptions['items'] = $val;}

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

                    public function IsFirstItem() {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "isFirstItem", QJsPriority::Low);
                    }

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

                    public function GetEndScript() {
                        $strId = $this->GetJqControlId();
                        $jqOptions = $this->makeJqOptions();
                        $strFunc = $this->getJqSetupFunction();
            
            

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

                    public function Instance() {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "instance", QJsPriority::Low);
                    }

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

                    public function GetJqSetupFunction() {
                        return 'menu';
                    }

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

                    public function Collapse($event = null) {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "collapse", $event, QJsPriority::Low);
                    }

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

                    public function Option2($optionName, $value) {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $optionName, $value, QJsPriority::Low);
                    }

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

                    public function Disable() {
                        QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "disable", QJsPriority::Low);
                    }

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

                    public static function GetModelConnectorParams() {
                        return array_merge(parent::GetModelConnectorParams(), array(
                            new QModelConnectorParam (get_called_class(), 'Disabled', 'Disables the menu if set to true.', QType::Boolean),
                            new QModelConnectorParam (get_called_class(), 'Items', 'Selector for the elements that serve as the menu items. Note: Theitems option should not be changed after initialization. (versionadded: 1.11.0)', QType::String),
                            new QModelConnectorParam (get_called_class(), 'Menus', 'Selector for the elements that serve as the menu container, includingsub-menus. Note: The menus option should not be changed afterinitialization. Existing submenus will not be updated.', QType::String),

            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