qcubed/framework

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

Summary

Maintainability
F
3 days
Test Coverage

File QRadioButtonList.class.php has 309 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
    /**
     * This file contains the QRadioButtonList class.
     *
     * @package Controls
Severity: Minor
Found in includes/base_controls/QRadioButtonList.class.php - About 3 hrs to fix

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

        class QRadioButtonList extends QListControl {
            const ButtonModeNone = 0;
            const ButtonModeJq = 1;
            const ButtonModeSet = 2;
            const ButtonModeList = 3;    // just a vanilla list of radio buttons with no row or column styling

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

            public function __set($strName, $mixValue) {
                switch ($strName) {
                    // APPEARANCE
                    case "TextAlign":
                        try {
    Severity: Major
    Found in includes/base_controls/QRadioButtonList.class.php - About 3 hrs to fix

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

              public function __set($strName, $mixValue) {
                  switch ($strName) {
                      // APPEARANCE
                      case "TextAlign":
                          try {
      Severity: Minor
      Found in includes/base_controls/QRadioButtonList.class.php - About 3 hrs 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 RenderButtonTable has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

              public function RenderButtonTable() {
                  // TODO: Do this without using a table, since this is really not a correct use of html
                  $strToReturn = '';
                  if ($this->ItemCount > 0) {
                      // Figure out the number of ROWS for this table
      Severity: Minor
      Found in includes/base_controls/QRadioButtonList.class.php - About 2 hrs 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

      Method GetItemHtml has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              protected function GetItemHtml($objItem, $intIndex, $strTabIndex, $blnWrapLabel) {
                  $objLabelStyles = new QTagStyler();
                  if ($this->objItemStyle) {
                      $objLabelStyles->Override($this->objItemStyle); // default style
                  }
      Severity: Minor
      Found in includes/base_controls/QRadioButtonList.class.php - About 1 hr to fix

        Method RenderButtonTable has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public function RenderButtonTable() {
                    // TODO: Do this without using a table, since this is really not a correct use of html
                    $strToReturn = '';
                    if ($this->ItemCount > 0) {
                        // Figure out the number of ROWS for this table
        Severity: Minor
        Found in includes/base_controls/QRadioButtonList.class.php - About 1 hr to fix

          Avoid too many return statements within this method.
          Open

                          case "ButtonMode": return $this->intButtonMode;
          Severity: Major
          Found in includes/base_controls/QRadioButtonList.class.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            case "RepeatColumns": return $this->intRepeatColumns;
            Severity: Major
            Found in includes/base_controls/QRadioButtonList.class.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              case "RepeatDirection": return $this->strRepeatDirection;
              Severity: Major
              Found in includes/base_controls/QRadioButtonList.class.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                case "ItemStyle": return $this->objItemStyle;
                Severity: Major
                Found in includes/base_controls/QRadioButtonList.class.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

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

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

                            protected function GetControlHtml() {
                                $intItemCount = $this->GetItemCount();
                                if (!$intItemCount) return '';
                    
                                if ($this->intButtonMode == self::ButtonModeSet || $this->intButtonMode == self::ButtonModeList) {
                    Severity: Minor
                    Found in includes/base_controls/QRadioButtonList.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

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

                            protected function GetItemHtml($objItem, $intIndex, $strTabIndex, $blnWrapLabel) {
                                $objLabelStyles = new QTagStyler();
                                if ($this->objItemStyle) {
                                    $objLabelStyles->Override($this->objItemStyle); // default style
                                }
                    Severity: Minor
                    Found in includes/base_controls/QRadioButtonList.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 21. The configured cyclomatic complexity threshold is 10.
                    Open

                            public function __set($strName, $mixValue) {
                                switch ($strName) {
                                    // APPEARANCE
                                    case "TextAlign":
                                        try {

                    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

                    The method __get() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                    Open

                            public function __get($strName) {
                                switch ($strName) {
                                    // APPEARANCE
                                    case "TextAlign": return $this->strTextAlign;
                    
                    

                    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 '180', column '22').
                    Open

                                    $objStyler = new QTagStyler();

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

                                    new QModelConnectorParam (get_called_class(), 'RepeatDirection', 'Whether to repeat horizontally or vertically', QModelConnectorParam::SelectionList,

                    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 '386', column '17').
                    Open

                                            throw new QCallerException("RepeatColumns must be greater than 0");

                    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 '66', column '30').
                    Open

                                $this->objItemStyle = new QListItemStyle();

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

                                    new QModelConnectorParam (get_called_class(), 'MaxHeight', 'If set, will wrap it in a scrollable pane with the given max height', QType::Integer)

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

                                    new QModelConnectorParam (get_called_class(), 'HtmlEntities', 'Set to false to have the browser interpret the labels as HTML', 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 '93', column '26').
                    Open

                                $objLabelStyles = new QTagStyler();

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

                                    new QModelConnectorParam (get_called_class(), 'TextAlign', '', QModelConnectorParam::SelectionList,

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

                                    new QModelConnectorParam (get_called_class(), 'ButtonMode', 'How to display the buttons', QModelConnectorParam::SelectionList,

                    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 '101', column '21').
                    Open

                                $objStyles = new QTagStyler();

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

                                    new QModelConnectorParam (get_called_class(), 'RepeatColumns', 'The number of columns of checkboxes to display', QType::Integer),

                    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 using static access to class 'QApplication' in method 'RefreshSelection'.
                    Open

                                    QApplication::ExecuteSelectorFunction(['input', '#' . $this->ControlId], 'button', "refresh");

                    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 '339', column '36').
                    Open

                            public function __set($strName, $mixValue) {
                                switch ($strName) {
                                    // APPEARANCE
                                    case "TextAlign":
                                        try {

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

                                            $this->objItemStyle = QType::Cast($mixValue, "QListItemStyle");

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

                                else {
                                    $strToReturn = $this->RenderButtonTable();
                                }

                    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 'Validate'.
                    Open

                                        $this->ValidationError = sprintf(QApplication::Translate('%s is required'), $this->strName);

                    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 '351', column '39').
                    Open

                            public function __set($strName, $mixValue) {
                                switch ($strName) {
                                    // APPEARANCE
                                    case "TextAlign":
                                        try {

                    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

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

                                } else {
                                    $this->SetSelectedItemsByIndex(array($val), false);
                                }

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

                                            $this->intCellSpacing = QType::Cast($mixValue, QType::Integer);

                    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 'GetLabelText'.
                    Open

                                    $strLabelText = QApplication::HtmlEntities($strLabelText);

                    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($ctrlId, 'buttonset', 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 'QHtml' in method 'RenderButtonTable'.
                    Open

                                        $strRowHtml = QHtml::RenderTag('tr', null, $strRowHtml);

                    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->intButtonMode = QType::Cast($mixValue, QType::Integer);

                    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->intRepeatColumns = QType::Cast($mixValue, QType::Integer);

                    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->strRepeatDirection = 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 'QHtml' in method 'GetControlHtml'.
                    Open

                                    $strToReturn = QHtml::RenderTag('div', $objStyler->RenderHtmlAttributes(), $strToReturn);

                    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

                                            if ($this->blnHtmlEntities !== ($mixValue = 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

                    Avoid using static access to class 'QType' in method '__set'.
                    Open

                                            $this->intCellPadding = QType::Cast($mixValue, QType::Integer);

                    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::ExecuteSelectorFunction(["input:radio", "#" . $ctrlId], 'button', 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 'QHtml' in method 'GetItemHtml'.
                    Open

                                $strHtml = QHtml::RenderLabeledInput(
                                    $strLabelText,
                                    $this->strTextAlign == QTextAlign::Left,
                                    $objStyles->RenderHtmlAttributes(),
                                    $objLabelStyles->RenderHtmlAttributes(),

                    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 'QHtml' in method 'RenderButtonTable'.
                    Open

                                            $strCellHtml = QHtml::RenderTag ('td', null, $strItemHtml);

                    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 'RefreshSelection'.
                    Open

                                QApplication::ExecuteSelectorFunction(['input', '#' . $this->ControlId], 'val', [$index]);

                    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 '97', column '8').
                    Open

                            protected function GetItemHtml($objItem, $intIndex, $strTabIndex, $blnWrapLabel) {
                                $objLabelStyles = new QTagStyler();
                                if ($this->objItemStyle) {
                                    $objLabelStyles->Override($this->objItemStyle); // default style
                                }

                    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 'QHtml' in method 'RenderButtonColumn'.
                    Open

                                    $strToReturn .= QHtml::RenderTag('div', $groupAttributes, $strHtml);

                    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

                                            if ($this->strTextAlign !== ($mixValue = 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 unused parameters such as '$objItemAttributes'.
                    Open

                            protected function OverrideItemAttributes ($objItem, QTagStyler $objItemAttributes, QTagStyler $objLabelAttributes) {}

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

                            protected function OverrideItemAttributes ($objItem, QTagStyler $objItemAttributes, QTagStyler $objLabelAttributes) {}

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

                            protected function OverrideItemAttributes ($objItem, QTagStyler $objItemAttributes, QTagStyler $objLabelAttributes) {}

                    UnusedFormalParameter

                    Since: 0.2

                    Avoid passing parameters to methods or constructors and then not using those parameters.

                    Example

                    class Foo
                    {
                        private function bar($howdy)
                        {
                            // $howdy is not used
                        }
                    }

                    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                    TODO found
                    Open

                                // TODO: Do this without using a table, since this is really not a correct use of html

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

                            public static function GetModelConnectorParams() {
                                return array_merge(parent::GetModelConnectorParams(), array(
                                    new QModelConnectorParam (get_called_class(), 'TextAlign', '', QModelConnectorParam::SelectionList,
                                        array (null=>'Default',
                                            'QTextAlign::Left'=>'Left',
                    Severity: Major
                    Found in includes/base_controls/QRadioButtonList.class.php and 1 other location - About 7 hrs to fix
                    includes/base_controls/QCheckBoxList.class.php on lines 460..481

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

                    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 5 locations. Consider refactoring.
                    Open

                            public function __get($strName) {
                                switch ($strName) {
                                    // APPEARANCE
                                    case "TextAlign": return $this->strTextAlign;
                    
                    
                    Severity: Major
                    Found in includes/base_controls/QRadioButtonList.class.php and 4 other locations - About 1 hr to fix
                    includes/base_controls/QAccordionGen.class.php on lines 307..325
                    includes/base_controls/QDroppableGen.class.php on lines 337..355
                    includes/base_controls/QImageControlBase.class.php on lines 542..566
                    includes/base_controls/QSelectableGen.class.php on lines 316..334

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

                    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 2 locations. Consider refactoring.
                    Open

                            public function GetEndScript() {
                                $ctrlId = $this->ControlId;
                                if ($this->intButtonMode == self::ButtonModeSet) {
                                    QApplication::ExecuteControlCommand($ctrlId, 'buttonset', QJsPriority::High);
                                } elseif ($this->intButtonMode == self::ButtonModeJq) {
                    Severity: Major
                    Found in includes/base_controls/QRadioButtonList.class.php and 1 other location - About 1 hr to fix
                    includes/base_controls/QCheckBoxList.class.php on lines 85..94

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

                    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

                    Constant ButtonModeJq should be defined in uppercase
                    Open

                            const ButtonModeJq = 1;

                    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 ButtonModeSet should be defined in uppercase
                    Open

                            const ButtonModeSet = 2;

                    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 ButtonModeNone should be defined in uppercase
                    Open

                            const ButtonModeNone = 0;

                    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 ButtonModeList should be defined in uppercase
                    Open

                            const ButtonModeList = 3;    // just a vanilla list of radio buttons with no row or column styling

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

                            public function RenderButtonColumn() {
                                $count = $this->ItemCount;
                                $strToReturn = '';
                                $groupAttributes = null;
                                if ($this->strButtonGroupClass) {

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

                            protected function OverrideItemAttributes ($objItem, QTagStyler $objItemAttributes, QTagStyler $objLabelAttributes) {}

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

                            protected function GetControlHtml() {
                                $intItemCount = $this->GetItemCount();
                                if (!$intItemCount) return '';
                    
                                if ($this->intButtonMode == self::ButtonModeSet || $this->intButtonMode == self::ButtonModeList) {

                    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(), 'TextAlign', '', QModelConnectorParam::SelectionList,
                                        array (null=>'Default',
                                            'QTextAlign::Left'=>'Left',

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

                            public function ParsePostData() {
                                $val = $this->objForm->CheckableControlValue($this->strControlId);
                                if ($val === null) {
                                    $this->UnselectAllItems(false);
                                } else {

                    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() {
                                $ctrlId = $this->ControlId;
                                if ($this->intButtonMode == self::ButtonModeSet) {
                                    QApplication::ExecuteControlCommand($ctrlId, 'buttonset', QJsPriority::High);
                                } elseif ($this->intButtonMode == self::ButtonModeJq) {

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

                            protected function RefreshSelection() {
                                $index = $this->SelectedIndex;
                                QApplication::ExecuteSelectorFunction(['input', '#' . $this->ControlId], 'val', [$index]);
                                if ($this->intButtonMode == self::ButtonModeSet ||
                                        $this->intButtonMode == self::ButtonModeJq) {

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

                            protected function GetItemHtml($objItem, $intIndex, $strTabIndex, $blnWrapLabel) {
                                $objLabelStyles = new QTagStyler();
                                if ($this->objItemStyle) {
                                    $objLabelStyles->Override($this->objItemStyle); // default style
                                }

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

                            protected function GetLabelText ($objItem) {
                                $strLabelText = $objItem->Label;
                                if (empty($strLabelText)) {
                                    $strLabelText = $objItem->Name;
                                }

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

                            public function RenderButtonSet() {
                                $count = $this->ItemCount;
                                $strToReturn = '';
                                for ($intIndex = 0; $intIndex < $count; $intIndex++) {
                                    $strToReturn .= $this->GetItemHtml($this->GetItem($intIndex), $intIndex, $this->GetHtmlAttribute('tabindex'), $this->blnWrapLabel) . "\n";

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

                            public function Validate() {
                                if ($this->blnRequired) {
                                    if ($this->SelectedIndex == -1) {
                                        $this->ValidationError = sprintf(QApplication::Translate('%s is required'), $this->strName);
                                        return false;

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

                            public function RenderButtonTable() {
                                // TODO: Do this without using a table, since this is really not a correct use of html
                                $strToReturn = '';
                                if ($this->ItemCount > 0) {
                                    // Figure out the number of ROWS for this table

                    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