YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Missing class import via use statement (line '20', 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 using static access to class 'Vtiger_Link_Model' in method 'getLinks'.
Open

            $relatedLink['RELATEDLIST_MASSACTIONS'][] = Vtiger_Link_Model::getInstanceFromValues([
                'linktype' => 'RELATEDLIST_MASSACTIONS',
                'linklabel' => 'LBL_SPECIFY_THE_MARGINP',
                'linkurl' => 'javascript:PriceBooks_RelatedList_Js.triggerMassMargin()',
                'linkclass' => '',

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

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.

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

class PriceBooks_RelationListView_Model extends Vtiger_RelationListView_Model

The class PriceBooks_RelationListView_Model is not named in CamelCase.
Open

class PriceBooks_RelationListView_Model extends Vtiger_RelationListView_Model
{
    /** {@inheritdoc} */
    public function getHeaders()
    {

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

            $field->set('maximumlength', '99999999999999999999');

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

        return $relatedLink;

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

    {

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

    }

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

                'linkclass' => '',

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 getHeaders()

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

            $relatedLink['RELATEDLIST_MASSACTIONS'][] = Vtiger_Link_Model::getInstanceFromValues([

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

    {

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('label', 'List Price');

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

        $headerFields = parent::getHeaders();

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

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

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

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

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

    }

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

                'linklabel' => 'LBL_SPECIFY_THE_MARGINP',

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

        if ('Services' === $this->getRelatedModuleModel()->getName() || 'Products' === $this->getRelatedModuleModel()->getName()) {

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

            //Added to support List Price

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

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

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

            $field->set('class', 'validate[required,funcCall[Vtiger_Currency_Validator_Js.invokeValidation]]');

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

        if (!$this->getParentRecordModel()->isReadOnly()) {

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

                'linkurl' => 'javascript:PriceBooks_RelatedList_Js.triggerMassMargin()',

Line exceeds 120 characters; contains 131 characters
Open

        if ('Services' === $this->getRelatedModuleModel()->getName() || 'Products' === $this->getRelatedModuleModel()->getName()) {

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 getLinks(): array

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

                'linkicon' => 'fas fa-hand-holding-usd',

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

            ]);

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

        $relatedLink = parent::getLinks();

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

                'linktype' => 'RELATEDLIST_MASSACTIONS',

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

class PriceBooks_RelationListView_Model extends Vtiger_RelationListView_Model

There are no issues that match your filters.

Category
Status