qcubed/framework

View on GitHub
includes/base_controls/_utilities.inc.php

Summary

Maintainability
A
3 hrs
Test Coverage

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

function _r($obj, $strRenderFunc = null /*, $overrides */) {
    $aParams = func_get_args();
    array_shift($aParams);
    array_shift($aParams);
    if ($obj) {
Severity: Minor
Found in includes/base_controls/_utilities.inc.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 _nl has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function _nl($strText = null) {
    if (QApplication::$Minimize) {
        return $strText;
    } else {
        if ($strText === null) return "\n";
Severity: Minor
Found in includes/base_controls/_utilities.inc.php - About 55 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

Avoid too many return statements within this method.
Open

            return $strText . "\n";
Severity: Major
Found in includes/base_controls/_utilities.inc.php - About 30 mins to fix

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

    function _indent($strText, $intCount = 1) {
        if (!defined('__CODE_GENERATING__') && QApplication::$Minimize) {
            return $strText;
        } else {
            if (defined ('__CODE_GENERATING__')) {
    Severity: Minor
    Found in includes/base_controls/_utilities.inc.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 _b has a boolean flag argument $blnHtmlEntities, which is a certain sign of a Single Responsibility Principle violation.
    Open

    function _b($strString, $blnHtmlEntities = true) {

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

    function _p($strString, $blnHtmlEntities = true) {

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

    function _tp($strString, $blnHtmlEntities = true) {

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

        } else {
            if (defined ('__CODE_GENERATING__')) {
                $strRepeat = '    ';
            } else {
                $strRepeat = '  ';

    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

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

                else {
                    $strRenderFunc = 'Render';
                }

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

            print(QHtml::RenderString($strString));

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

        print(QApplication::Translate($strString));

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

            } else {
                return $obj->$strRenderFunc(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

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

        } else {
            if ($strText === null) return "\n";
            if (!$strText) return '';    // don't add a shadow newline
            if (substr($strText, -1) == "\n") {
                return $strText; // text already ends with a newline

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

        return QApplication::Translate($strString);

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

            } else {
                return $strText . "\n";
            }

    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

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

            } else {
                $strRepeat = '  ';
            }

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

            print(QApplication::HtmlEntities($strString));

    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

    TODO found
    Open

    /** TODO: Implement the following. */

    Avoid using short method names like ::_p(). The configured minimum method name length is 3.
    Open

    function _p($strString, $blnHtmlEntities = true) {
        // Standard Print
        if ($blnHtmlEntities && (gettype($strString) != 'object'))
            print(QApplication::HtmlEntities($strString));
        else

    ShortMethodName

    Since: 0.2

    Detects when very short method names are used.

    Example

    class ShortMethod {
        public function a( $index ) { // Violation
        }
    }

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

    Avoid using short method names like ::_b(). The configured minimum method name length is 3.
    Open

    function _b($strString, $blnHtmlEntities = true) {
        // Text Block Print
        if ($blnHtmlEntities && (gettype($strString) != 'object'))
            print(QHtml::RenderString($strString));
        else

    ShortMethodName

    Since: 0.2

    Detects when very short method names are used.

    Example

    class ShortMethod {
        public function a( $index ) { // Violation
        }
    }

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

    Avoid using short method names like ::_r(). The configured minimum method name length is 3.
    Open

    function _r($obj, $strRenderFunc = null /*, $overrides */) {
        $aParams = func_get_args();
        array_shift($aParams);
        array_shift($aParams);
        if ($obj) {

    ShortMethodName

    Since: 0.2

    Detects when very short method names are used.

    Example

    class ShortMethod {
        public function a( $index ) { // Violation
        }
    }

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

    Avoid using short method names like ::_t(). The configured minimum method name length is 3.
    Open

    function _t($strString) {
        // Print, via Translation (if applicable)
        print(QApplication::Translate($strString));
    }

    ShortMethodName

    Since: 0.2

    Detects when very short method names are used.

    Example

    class ShortMethod {
        public function a( $index ) { // Violation
        }
    }

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

    There are no issues that match your filters.

    Category
    Status