qcubed/framework

View on GitHub
assets/php/examples/events_actions/editable_listbox.php

Summary

Maintainability
A
2 hrs
Test Coverage

Missing class import via use statement (line '36', column '9').
Open

                new QToggleEnableAction($this->txtItem, false),

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 '38', column '9').
Open

                new QAjaxAction('AddListItem')

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

            $this->lstListbox->AddAction(new QChangeEvent(), new QAjaxAction('lstListbox_Change'));

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

            $this->lblSelected = new QLabel($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 '50', column '34').
Open

            $this->txtItem->AddAction(new QEnterKeyEvent(), new QTerminateAction());

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

            $this->lstListbox = new QListBox($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 '18', column '57').
Open

            $this->lstListbox->AddAction(new QChangeEvent(), new QAjaxAction('lstListbox_Change'));

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 '35', column '9').
Open

                new QToggleEnableAction($this->btnAdd, false),

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

            $this->txtItem->AddActionArray(new QEnterKeyEvent(), $objSubmitListItemActions);

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 '42', column '38').
Open

            $this->btnAdd->AddActionArray(new QClickEvent(), $objSubmitListItemActions);

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 '21', column '25').
Open

            $this->txtItem = new QTextBox($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 '37', column '9').
Open

                new QToggleEnableAction($this->lstListbox, false),

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

            $this->txtItem->AddAction(new QEnterKeyEvent(), new QTerminateAction());

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

            $this->btnAdd = new QButton($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

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

            } else {            
                // Add the new item
                $this->lstListbox->AddItem(trim($this->txtItem->Text), trim($this->txtItem->Text));
            }

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

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

        protected function AddListItem() {
            // First off, let's make sure that data was typed in
            if (!strlen(trim($this->txtItem->Text))) {
                $this->txtItem->Warning = 'Nothing was entered';
            } else {            
Severity: Major
Found in assets/php/examples/events_actions/editable_listbox.php and 1 other location - About 2 hrs to fix
assets/php/examples/events_actions/editable_listbox_2.php on lines 67..85

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

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 $objSubmitListItemActions. Keep variable name length under 20.
Open

            $objSubmitListItemActions = array(

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

The method AddListItem is not named in camelCase.
Open

        protected function AddListItem() {
            // First off, let's make sure that data was typed in
            if (!strlen(trim($this->txtItem->Text))) {
                $this->txtItem->Warning = 'Nothing was entered';
            } 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 lstListbox_Change is not named in camelCase.
Open

        protected function lstListbox_Change() {
            // Whenever the user changes the selected listbox item, let's
            // update the label to reflect the selected item
            $this->lblSelected->Text = $this->lstListbox->SelectedValue;
        }

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 Controls
            $this->lstListbox = new QListBox($this);
            $this->lstListbox->Name = 'Items to Choose From';
            $this->lstListbox->Rows = 6;

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