YetiForceCompany/YetiForceCRM

View on GitHub
modules/PriceBooks/models/ListView.php

Summary

Maintainability
A
0 mins
Test Coverage
F
46%

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

            $field = new Vtiger_Field_Model();

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 assigning values to variables in if clauses and the like (line '17', column '7').
Open

    public function getListViewEntries(Vtiger_Paging_Model $pagingModel)
    {
        if ($currencyId = $this->get('currency_id')) {
            $this->getQueryGenerator()->currencyId = $currencyId;
        }

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

Define a constant instead of duplicating this literal "listprice" 3 times.
Open

            $field->set('name', 'listprice');

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Reference to instance property currencyId from undeclared class \App\QueryGenerator
Open

            $this->getQueryGenerator()->currencyId = $currencyId;
Severity: Minor
Found in modules/PriceBooks/models/ListView.php by phan

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class PriceBooks_ListView_Model extends Vtiger_ListView_Model

The class PriceBooks_ListView_Model is not named in CamelCase.
Open

class PriceBooks_ListView_Model extends Vtiger_ListView_Model
{
    /** {@inheritdoc} */
    public function getListViewEntries(Vtiger_Paging_Model $pagingModel)
    {

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($this->get('currency_id')) {

Spaces must be used to indent lines; tabs are not allowed
Open

            $field->set('label', 'List Price');

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

            $field->set('column', 'listprice');

Spaces must be used to indent lines; tabs are not allowed
Open

        $headerFields = parent::getListViewHeaders();

Spaces must be used to indent lines; tabs are not allowed
Open

            $headerFields['listprice'] = $field;

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($currencyId = $this->get('currency_id')) {

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getListViewHeaders()

Spaces must be used to indent lines; tabs are not allowed
Open

        return $headerFields;

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc} */

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getListViewEntries(Vtiger_Paging_Model $pagingModel)

Spaces must be used to indent lines; tabs are not allowed
Open

        return parent::getListViewEntries($pagingModel);

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc} */

Spaces must be used to indent lines; tabs are not allowed
Open

            $field = new Vtiger_Field_Model();

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

            $field->set('typeofdata', 'N~O');

Spaces must be used to indent lines; tabs are not allowed
Open

            $field->set('fromOutsideList', true);

Spaces must be used to indent lines; tabs are not allowed
Open

            $this->getQueryGenerator()->currencyId = $currencyId;

Spaces must be used to indent lines; tabs are not allowed
Open

            $field->set('name', 'listprice');

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Class name "PriceBooks_ListView_Model" is not in camel caps format
Open

class PriceBooks_ListView_Model extends Vtiger_ListView_Model

There are no issues that match your filters.

Category
Status