qcubed/framework

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

Summary

Maintainability
A
2 hrs
Test Coverage

Function GetChangedIds has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function GetChangedIds($blnRemember = false)
    {
        //because of formstate, this will even include ones not currently displayed.
        $childControls = $this->objDataGrid->GetChildControls();
        
Severity: Minor
Found in includes/base_controls/QCheckBoxLegacyColumn.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 GetSelectedIds has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function GetSelectedIds()
    {
        //because of formstate, this will even include ones not currently displayed.
        $childControls = $this->objDataGrid->GetChildControls();
        
Severity: Minor
Found in includes/base_controls/QCheckBoxLegacyColumn.class.php - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

    protected function GetColIndex()
    {
        //cached, to improve performance
        if($this->colIndex == -1)
        {
Severity: Minor
Found in includes/base_controls/QCheckBoxLegacyColumn.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

Missing class import via use statement (line '104', column '58').
Open

            $this->chkSelectAll->AddAction(new QClickEvent(), new QJavaScriptAction($strJavascript));

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 '264', column '14').
Open

            throw new exception('Select All Checkbox not found');

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

            $this->chkSelectAll = new QCheckBox($this->objDataGrid, $controlId);

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 '124', column '23').
Open

            $chkSelected = new QCheckBox($this->objDataGrid, $strControlId);

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

            $this->chkSelectAll->AddAction(new QClickEvent(), new QJavaScriptAction($strJavascript));

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 chkSelectAll_Render has a boolean flag argument $blnWithLabel, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function chkSelectAll_Render($blnWithLabel = false) {

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

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

    public function GetSelectedItems($strClass, $blnIndex = true, $objClauses = null)

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

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

    public function GetChangedIds($blnRemember = false)

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

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

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

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

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

            $this->chkSelectAll->Name = QApplication::Translate('Select All');

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

            $strOutput = QHtml::RenderTag('label', null,  $this->strName . ' ' . $strOutput);

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

        {
            $parent_class=get_parent_class($this);
            return call_user_func_array(array($parent_class, '__construct'), $arrParentArgs);
        }

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 'QQ' in method 'GetSelectedItems'.
Open

        $conditions = QQ::In($idQQNode, $itemIds);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

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

    public function __set($strName, $mixValue) {
        switch ($strName) {
            ///////////////////
            // Member Variables
            ///////////////////
Severity: Minor
Found in includes/base_controls/QCheckBoxLegacyColumn.class.php and 1 other location - About 45 mins to fix
includes/framework/QQuery.class.php on lines 307..325

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

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

Avoid excessively long variable names like $objOverrideParameters. Keep variable name length under 20.
Open

    public function __construct($strName = '', QDataGridLegacy $dataGrid, $objOverrideParameters = null)

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

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

Avoid excessively long variable names like $strCheckboxCallbackFunc. Keep variable name length under 20.
Open

    protected $strCheckboxCallbackFunc = null;

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

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

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

                $id = $arrParams[0];

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

    public function chkSelected_Render($_ITEM) {
        $intId = $_ITEM->{$this->strPrimaryKey};
        $colIndex = $this->GetColIndex();
        $strControlId = 'chkSelect' . $colIndex . $this->objDataGrid->ControlId . 'n' . $intId;
        

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

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

                    $id = $arrParams[0];

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

    public function chkSelected_Render($_ITEM) {
        $intId = $_ITEM->{$this->strPrimaryKey};
        $colIndex = $this->GetColIndex();
        $strControlId = 'chkSelect' . $colIndex . $this->objDataGrid->ControlId . 'n' . $intId;
        

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $parent_class is not named in camelCase.
Open

    public function __construct($strName = '', QDataGridLegacy $dataGrid, $objOverrideParameters = null)
    {
        $this->objDataGrid = $dataGrid;
        
        $arrParentArgs = func_get_args();

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_ITEM is not named in camelCase.
Open

    public function chkSelected_Render($_ITEM) {
        $intId = $_ITEM->{$this->strPrimaryKey};
        $colIndex = $this->GetColIndex();
        $strControlId = 'chkSelect' . $colIndex . $this->objDataGrid->ControlId . 'n' . $intId;
        

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $parent_class is not named in camelCase.
Open

    public function __construct($strName = '', QDataGridLegacy $dataGrid, $objOverrideParameters = null)
    {
        $this->objDataGrid = $dataGrid;
        
        $arrParentArgs = func_get_args();

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The method GetSelectedIds is not named in camelCase.
Open

    public function GetSelectedIds()
    {
        //because of formstate, this will even include ones not currently displayed.
        $childControls = $this->objDataGrid->GetChildControls();
        

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

    public function chkSelected_Render($_ITEM) {
        $intId = $_ITEM->{$this->strPrimaryKey};
        $colIndex = $this->GetColIndex();
        $strControlId = 'chkSelect' . $colIndex . $this->objDataGrid->ControlId . 'n' . $intId;
        

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

    public function AcceptChanges()
    {
        $this->GetChangedIds(true);
    }

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

    public function SetSelectAllCheckbox($value)
    {
        $colIndex = $this->GetColIndex();
        
        $controlId = 'chkSelectAll' . $colIndex.$this->objDataGrid->ControlId ;

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

    public function GetSelectedItems($strClass, $blnIndex = true, $objClauses = null)
    {
        $itemIds = $this->GetSelectedIds();
        
        //load these items, using QQ::In so that it's a single DB hit

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

    public function chkSelectAll_Render($blnWithLabel = false) {
        $colIndex = $this->GetColIndex();
        
        $controlId = 'chkSelectAll' . $colIndex . $this->objDataGrid->ControlId ;
        

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

    public function SetCheckbox($itemId, $value)
    {
        $colIndex = $this->GetColIndex();
        $controlId = 'chkSelect' . $colIndex.$this->objDataGrid->ControlId .'n'.$itemId;
        $checkbox = $this->objDataGrid->GetChildControl($controlId);

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

    protected function GetColIndex()
    {
        //cached, to improve performance
        if($this->colIndex == -1)
        {

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

    public function SetCheckboxCallback($objParent, $strFuncName)
    {
        $this->objCheckboxCallback = $objParent;
        $this->strCheckboxCallbackFunc = $strFuncName;
    }

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

    public function GetChangedIds($blnRemember = false)
    {
        //because of formstate, this will even include ones not currently displayed.
        $childControls = $this->objDataGrid->GetChildControls();
        

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