qcubed/framework

View on GitHub
assets/php/qcubed_unit_tests.php

Summary

Maintainability
B
4 hrs
Test Coverage

Function printResult has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function printResult(PHPUnit_Framework_TestResult $result)
    {
        echo('<h1>QCubed ' . QCUBED_VERSION_NUMBER_ONLY . ' Unit Tests - PHPUnit ' . PHPUnit_Runner_Version::id() . '</h1>');

        foreach ($this->results as $suiteName=>$suite) {
Severity: Minor
Found in assets/php/qcubed_unit_tests.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 printResult has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function printResult(PHPUnit_Framework_TestResult $result)
    {
        echo('<h1>QCubed ' . QCUBED_VERSION_NUMBER_ONLY . ' Unit Tests - PHPUnit ' . PHPUnit_Runner_Version::id() . '</h1>');

        foreach ($this->results as $suiteName=>$suite) {
Severity: Minor
Found in assets/php/qcubed_unit_tests.php - About 1 hr to fix

    Missing class import via use statement (line '159', column '22').
    Open

            $t1->AddAction(new QTimerExpiredEvent(), new QAjaxAction ('preTest'));
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 '161', column '64').
    Open

            $t2->AddAction(new QTimerExpiredEvent(0,null,null,true), new QAjaxAction ('preTest2'));
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

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

            $this->pnlOutput = new QPanel($this, 'outputPanel');
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 '162', column '13').
    Open

            $t3 = new QJsTimer($this, 52, false, true, 'timer3');
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

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

            $t2->AddAction(new QTimerExpiredEvent(0,null,null,true), new QAjaxAction ('preTest2'));
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 '148', column '56').
    Open

            $this->btnRunTests->AddAction(new QClickEvent(), new QAjaxAction('startTesting'));
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 '163', column '48').
    Open

            $t3->AddAction(new QTimerExpiredEvent(), new QAjaxAction ('preTest3'));
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

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

            $this->btnRunTests->AddAction(new QClickEvent(), new QAjaxAction('startTesting'));
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 '158', column '13').
    Open

            $t1 = new QJsTimer($this, 50, false, true, 'timer1');
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

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

            $this->lblRunning = new QLabel($this);
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 '164', column '13').
    Open

            $t4 = new QJsTimer($this, 600, false, true, 'timer4');
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 '159', column '48').
    Open

            $t1->AddAction(new QTimerExpiredEvent(), new QAjaxAction ('preTest'));
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 '144', column '24').
    Open

            $this->ctlTest = new QTestControl($this);
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 '146', column '28').
    Open

            $this->btnRunTests = new QButton($this);
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

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

            $t4->AddAction(new QTimerExpiredEvent(), new QServerAction ('runTests'));
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 '160', column '13').
    Open

            $t2 = new QJsTimer($this, 51, false, true, 'timer2');
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

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

            $t3->AddAction(new QTimerExpiredEvent(), new QAjaxAction ('preTest3'));
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 '165', column '48').
    Open

            $t4->AddAction(new QTimerExpiredEvent(), new QServerAction ('runTests'));
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

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

            $tester = new PHPUnit_TextUI_Command();
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 'PHPUnit_Runner_Version' in method 'printResult'.
    Open

            echo('<h1>QCubed ' . QCUBED_VERSION_NUMBER_ONLY . ' Unit Tests - PHPUnit ' . PHPUnit_Runner_Version::id() . '</h1>');
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

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

                    } else {
                        $status = '<span style="color:green">' . $status . '</span>';
                    }
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 'PHPUnit_Util_Filter' in method 'printResult'.
    Open

                        $lines = explode ("\n", PHPUnit_Util_Filter::getFilteredStacktrace($error['e']));
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

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

        public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

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

        public function write($buffer)
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

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

            $t1 = new QJsTimer($this, 50, false, true, 'timer1');
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 $e. Configured minimum length is 3.
    Open

        public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) {
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 $e. Configured minimum length is 3.
    Open

        public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 $t3. Configured minimum length is 3.
    Open

            $t3 = new QJsTimer($this, 52, false, true, 'timer3');
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 $t. Configured minimum length is 3.
    Open

            $t = &$this->results[$this->currentSuite][$test->getName()];
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 $e. Configured minimum length is 3.
    Open

        public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 $t2. Configured minimum length is 3.
    Open

            $t2 = new QJsTimer($this, 51, false, true, 'timer2');
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 $e. Configured minimum length is 3.
    Open

        public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) {
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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 $t4. Configured minimum length is 3.
    Open

            $t4 = new QJsTimer($this, 600, false, true, 'timer4');
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

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

        protected function Form_Create() {
            $this->ctlTest = new QTestControl($this);
            $this->pnlOutput = new QPanel($this, 'outputPanel');
            $this->btnRunTests = new QButton($this);
            $this->btnRunTests->Text = "Run Tests";
    Severity: Minor
    Found in assets/php/qcubed_unit_tests.php by phpmd

    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