qcubed/framework

View on GitHub
assets/php/examples/datagrid/columns.php

Summary

Maintainability
A
1 hr
Test Coverage

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

    protected function Form_Create() {
        // Define the DataGrid
        $this->tblPersons = new QHtmlTable($this);
        $this->tblPersons->CssClass = 'simple_table';
        $this->tblPersons->RowCssClass = 'odd_row';
Severity: Minor
Found in assets/php/examples/datagrid/columns.php - About 1 hr to fix

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

            $a[] = array ('Name' => 'Net', 1=>1000-500, 2=>2000-700, 3=>1500-2100);

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

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

            $a[] = array ('Name' => 'Expense', 1=>500, 2=>700, 3=>2100);

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

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

            $a[] = array ('Name' => 'Income', 1=>1000, 2=>2000, 3=>1500);

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

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

            $this->tblComplex->DataSource = $a;

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Missing class import via use statement (line '52', column '27').
    Open

            $this->tblPersons = new QHtmlTable($this);

    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 '78', column '26').
    Open

            $this->tblReport = new QHtmlTable($this);

    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 '105', column '37').
    Open

            $this->tblComplex->AddColumn (new ComplexColumn("2001", 2));

    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 '106', column '37').
    Open

            $this->tblComplex->AddColumn (new ComplexColumn("2002", 3));

    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 '60', column '20').
    Open

            $objColumn = new QHtmlTableCallableColumn('Full Name', [$this, 'getFullName']);

    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 '102', column '44').
    Open

            $col = $this->tblComplex->AddColumn (new ComplexColumn("", "Name"));

    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 '95', column '27').
    Open

            $this->tblComplex = new QHtmlTable($this);

    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 '104', column '37').
    Open

            $this->tblComplex->AddColumn (new ComplexColumn("2000", 1));

    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

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

        } else {
                return parent::RenderHeaderCell ();
            }

    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 'Person' in method 'tblPersons_Bind'.
    Open

            $this->tblPersons->DataSource = Person::LoadAll();

    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 variables with short names like $a. Configured minimum length is 3.
    Open

            $a[] = array ('Name' => 'Income', 1=>1000, 2=>2000, 3=>1500);

    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

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

            $a = parent::GetHeaderCellParams();

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

        public function RenderHeaderCell() {
            if ($this->objParentTable->CurrentHeaderRowIndex == 0 &&
                    $this->Index > 1) {
            return null; // don't draw, first col is a span
        } 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 tblReport_Bind is not named in camelCase.
    Open

        protected function tblReport_Bind() {
            // build the entire datasource as an array of arrays.
            $csv = '1997,Ford,E350,"ac, abs, moon",3000.00
    1999,Chevy,"Venture ""Extended Edition""","",4900.00
    1999,Chevy,"Venture ""Extended Edition, Very Large""","",5000.00

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

        public function FetchHeaderCellValue() {
            if ($this->objParentTable->CurrentHeaderRowIndex == 0 &&
                    $this->Index == 1) {
                return 'Year';
            }

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

        protected function tblComplex_Bind() {
            $a[] = array ('Name' => 'Income', 1=>1000, 2=>2000, 3=>1500);
            $a[] = array ('Name' => 'Expense', 1=>500, 2=>700, 3=>2100);
            $a[] = array ('Name' => 'Net', 1=>1000-500, 2=>2000-700, 3=>1500-2100);
    
    

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

        protected function tblPersons_Bind() {
            // We load the data source, and set it to the datagrid's DataSource parameter
            $this->tblPersons->DataSource = Person::LoadAll();
        }

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

        public function GetHeaderCellParams() {
            $a = parent::GetHeaderCellParams();
            if ($this->Index == 0) {
                //make background white
                $a['style'] = 'background-color: white';

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

        protected function Form_Create() {
            // Define the DataGrid
            $this->tblPersons = new QHtmlTable($this);
            $this->tblPersons->CssClass = 'simple_table';
            $this->tblPersons->RowCssClass = 'odd_row';

    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