qcubed/framework

View on GitHub
includes/codegen/controls/QHtmlTable_CodeGenerator.class.php

Summary

Maintainability
C
1 day
Test Coverage

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

<?php
/**
 * This is a base class to support classes that are derived from QHtmlTable. The methods here support the use
 * of QHtmlTable derived classes as a list connector, something that displays a list of records from a database,
 * and optionally allows the user to do CRUD operations on individual records.
Severity: Minor
Found in includes/codegen/controls/QHtmlTable_CodeGenerator.class.php - About 3 hrs to fix

    QHtmlTable_CodeGenerator has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class QHtmlTable_CodeGenerator extends QControl_CodeGenerator implements QDataList_CodeGenerator_Interface {
    
        /**
         * dtg stands for "DataGrid", a QCubed historical name for tables displaying data. Override if you want something else.
         * @param string $strPropName
    Severity: Minor
    Found in includes/codegen/controls/QHtmlTable_CodeGenerator.class.php - About 2 hrs to fix

      Function DataListColumnDeclarations has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function DataListColumnDeclarations(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
      
              $strCode = <<<TMPL
          // Publicly accessible columns that allow parent controls to directly manipulate them after creation.
      
      
      Severity: Minor
      Found in includes/codegen/controls/QHtmlTable_CodeGenerator.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

      Method DataListSet has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function DataListSet(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
              $strCode = <<<TMPL
          /**
           * This will set the property \$strName to be \$mixValue
           *
      Severity: Minor
      Found in includes/codegen/controls/QHtmlTable_CodeGenerator.class.php - About 1 hr to fix

        Function DataListCreateColumns has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function DataListCreateColumns(QCodeGenBase $objCodeGen, QSqlTable $objTable)
            {
                $strVarName = $objCodeGen->DataListVarName($objTable);
        
                $strCode = <<<TMPL
        Severity: Minor
        Found in includes/codegen/controls/QHtmlTable_CodeGenerator.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

        Function DataListSubclassOverrides has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function DataListSubclassOverrides(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strVarName = $objCodeGen->DataListVarName($objTable);
                $strPropertyName = QCodeGen::DataListPropertyName($objTable);
        
                $strCode = <<<TMPL
        Severity: Minor
        Found in includes/codegen/controls/QHtmlTable_CodeGenerator.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 unused parameters such as '$objTable'.
        Open

            public function DataListCreatePaginator(QCodeGenBase $objCodeGen, QSqlTable $objTable)

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

            protected function DataListGetClauses(QCodeGenBase $objCodeGen, QSqlTable $objTable) {

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

            protected function DataListGetCondition(QCodeGenBase $objCodeGen, QSqlTable $objTable)

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

            protected function DataListGetCondition(QCodeGenBase $objCodeGen, QSqlTable $objTable)

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

            public function DataListConnectorComments(QCodeGenBase $objCodeGen, QSqlTable $objTable) {

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

            public function DataListConnectorComments(QCodeGenBase $objCodeGen, QSqlTable $objTable) {

        UnusedFormalParameter

        Since: 0.2

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

        Example

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

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

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

                $strVarName = $objCodeGen->DataListVarName($objTable);

        UnusedLocalVariable

        Since: 0.2

        Detects when a local variable is declared and/or assigned, but not used.

        Example

        class Foo {
            public function doSomething()
            {
                $i = 5; // Unused
            }
        }

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

        Avoid unused parameters such as '$objTable'.
        Open

            protected function DataListGet(QCodeGenBase $objCodeGen, QSqlTable $objTable) {

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

            public function DataListCreatePaginator(QCodeGenBase $objCodeGen, QSqlTable $objTable)

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

            protected function DataListSet(QCodeGenBase $objCodeGen, QSqlTable $objTable) {

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

            protected function DataListGet(QCodeGenBase $objCodeGen, QSqlTable $objTable) {

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

            protected function DataListSet(QCodeGenBase $objCodeGen, QSqlTable $objTable) {

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

            protected function DataListConstructor(QCodeGenBase $objCodeGen, QSqlTable $objTable) {

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

            protected function DataListGetClauses(QCodeGenBase $objCodeGen, QSqlTable $objTable) {

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

                $strPropertyName = QCodeGen::DataListPropertyName($objTable);

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

            protected function DataListParentCreate(QCodeGenBase $objCodeGen, QSqlTable $objTable)
            {
                $strPropertyName = $objCodeGen->DataListPropertyName($objTable);
                $strVarName = $objCodeGen->DataListVarName($objTable);
        
        

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

        abstract class QHtmlTable_CodeGenerator extends QControl_CodeGenerator implements QDataList_CodeGenerator_Interface {
        
            /**
             * dtg stands for "DataGrid", a QCubed historical name for tables displaying data. Override if you want something else.
             * @param string $strPropName

        CamelCaseClassName

        Since: 0.2

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

        Example

        class class_name {
        }

        Source

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

                if (($o = $objTable->Options) && isset ($o['Name'])) { // Did developer default?

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

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

        The method DataListCreatePaginator is not named in camelCase.
        Open

            public function DataListCreatePaginator(QCodeGenBase $objCodeGen, QSqlTable $objTable)
            {
                $strCode = <<<TMPL
            /**
             * Creates the paginator. Override to add an additional paginator, or to remove it.

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

            protected function DataListConstructor(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strClassName = $this->GetControlClass();
        
                $strCode = <<<TMPL
        
        

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

            protected function DataListGetRowParams(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strVarName = $objCodeGen->DataListVarName($objTable);
        
                $strCode = <<<TMPL
            public function {$strVarName}_GetRowParams(\$objRowObject, \$intRowIndex) {

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

            protected function DataListGetCondition(QCodeGenBase $objCodeGen, QSqlTable $objTable)
            {
                $strCode = <<<TMPL
            /**
             * Returns the condition to use when querying the data. Default is to return the condition put in the local

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

            public function DataListHelperMethods(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strCode = $this->DataListParentCreate($objCodeGen, $objTable);
                $strCode .= $this->DataListParentCreateColumns($objCodeGen, $objTable);
                $strCode .= $this->DataListParentMakeEditable($objCodeGen, $objTable);
                $strCode .= $this->DataListGetRowParams($objCodeGen, $objTable);

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

            protected function DataListParentCreate(QCodeGenBase $objCodeGen, QSqlTable $objTable)
            {
                $strPropertyName = $objCodeGen->DataListPropertyName($objTable);
                $strVarName = $objCodeGen->DataListVarName($objTable);
        
        

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

            protected function DataListMembers(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strCode = <<<TMPL
            /**
             * @var null|QQCondition    Condition to use to filter the list.
             * @access protected

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

            protected function DataListGet(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strCode = <<<TMPL
            /**
             * This will get the value of \$strName
             *

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

            protected function DataListSet(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strCode = <<<TMPL
            /**
             * This will set the property \$strName to be \$mixValue
             *

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

            public function VarName($strPropName) {
                return 'dtg' . $strPropName;
            }

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

            public function DataListConnector(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strCode = $this->DataListMembers($objCodeGen, $objTable);
                $strCode .= $this->DataListConstructor($objCodeGen, $objTable);
                $strCode .= $this->DataListCreatePaginator($objCodeGen, $objTable);
                $strCode .= $this->DataListCreateColumns($objCodeGen, $objTable);

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

            public function DataListInstantiate(QCodeGenBase $objCodeGen, QSqlTable $objTable)
            {
                $strVarName = $objCodeGen->DataListVarName($objTable);
        
                $strCode = <<<TMPL

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

            public function DataListCreateColumns(QCodeGenBase $objCodeGen, QSqlTable $objTable)
            {
                $strVarName = $objCodeGen->DataListVarName($objTable);
        
                $strCode = <<<TMPL

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

            protected function DataListDataBinder(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strObjectType = $objTable->ClassName;
                $strCode = <<<TMPL
           /**
            * Called by the framework to access the data for the control and load it into the table. By default, this function will be

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

            protected function DataListParentMakeEditable(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strVarName = $objCodeGen->DataListVarName($objTable);
        
                $strCode = <<<TMPL
        
        

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

            protected function DataListParentCreateColumns(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strVarName = $objCodeGen->DataListVarName($objTable);
        
                $strCode = <<<TMPL
        
        

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

            protected function DataListColumnDeclarations(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
        
                $strCode = <<<TMPL
            // Publicly accessible columns that allow parent controls to directly manipulate them after creation.
        
        

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

            public function DataListRefresh(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strVarName = $objCodeGen->DataListVarName($objTable);
                $strCode = <<<TMPL
                \$this->{$strVarName}->Refresh();
        
        

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

            public function DataListSubclassOverrides(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strVarName = $objCodeGen->DataListVarName($objTable);
                $strPropertyName = QCodeGen::DataListPropertyName($objTable);
        
                $strCode = <<<TMPL

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

            public function DataListConnectorComments(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strCode = <<<TMPL
         * @property QQCondition     \$Condition Any condition to use during binding
         * @property QQClauses         \$Clauses Any clauses to use during binding
        
        

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

            protected function DataListGetClauses(QCodeGenBase $objCodeGen, QSqlTable $objTable) {
                $strCode = <<<TMPL
            /**
             * Returns the clauses to use when querying the data. Default is to return the clauses put in the local
             * objClauses member variable. You can also override this to return clauses.

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

            public function DataListHasFilter() {
                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

        There are no issues that match your filters.

        Category
        Status