mambax7/cardealer

View on GitHub
blocks/vehicle.php

Summary

Maintainability
D
2 days
Test Coverage

showCardealerVehicle accesses the super-global variable $GLOBALS.
Open

function showCardealerVehicle($options)
{

    $block        = [];
    $blockType    = $options[0];
Severity: Minor
Found in blocks/vehicle.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

editCardealerVehicle accesses the super-global variable $GLOBALS.
Open

function editCardealerVehicle($options)
{

    $form = MB_CARDEALER_DISPLAY;
    $form .= "<input type='hidden' name='options[0]' value='" . $options[0] . "' />";
Severity: Minor
Found in blocks/vehicle.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Missing class import via use statement (line '47', column '28').
Open

        $criteria->add(new \Criteria('id', 0, '!='));
Severity: Minor
Found in blocks/vehicle.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 '42', column '27').
Open

    $criteria       = new \CriteriaCompo();
Severity: Minor
Found in blocks/vehicle.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 '80', column '24').
Open

    $criteria->add(new Criteria('id', 0, '!='));
Severity: Minor
Found in blocks/vehicle.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 '76', column '21').
Open

    $criteria = new \CriteriaCompo();
Severity: Minor
Found in blocks/vehicle.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 unused local variables such as '$i'.
Open

    foreach (array_keys($vehicleArray) as $i) {
Severity: Minor
Found in blocks/vehicle.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

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

<?php

/*
 You may not change or alter any portion of this comment or credits
 of supporting developers from this source code or any supporting source code
Severity: Major
Found in blocks/vehicle.php and 5 other locations - About 2 days to fix
blocks/customer.php on lines 1..92
blocks/part.php on lines 1..93
blocks/service.php on lines 1..92
blocks/servpart.php on lines 1..93
blocks/workorder.php on lines 1..94

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

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

        $id   = $vehicleArray[$i]->getVar('id');
Severity: Minor
Found in blocks/vehicle.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

Line exceeds 120 characters; contains 176 characters
Open

        $form .= "<option value='" . $id . "' " . (false === in_array($id, $options) ? '' : "selected='selected'") . '>' . $vehicleArray[$i]->getVar('serialnum') . '</option>';
Severity: Minor
Found in blocks/vehicle.php by phpcodesniffer

Line exceeds 120 characters; contains 146 characters
Open

    $form .= MB_CARDEALER_TITLELENGTH . " : <input name='options[2]' size='5' maxlength='255' value='" . $options[2] . "' type='text' /><br><br>";
Severity: Minor
Found in blocks/vehicle.php by phpcodesniffer

Line exceeds 120 characters; contains 149 characters
Open

    $form         .= "<option value='0' " . (false === in_array(0, $options) ? '' : "selected='selected'") . '>' . MB_CARDEALER_ALLCAT . '</option>';
Severity: Minor
Found in blocks/vehicle.php by phpcodesniffer

There are no issues that match your filters.

Category
Status