YetiForceCompany/YetiForceCRM

View on GitHub
modules/MultiCompany/models/Record.php

Summary

Maintainability
A
0 mins
Test Coverage
F
50%

Avoid using static access to class 'CRMEntity' in method 'getHierarchy'.
Open

        $focus = CRMEntity::getInstance($this->getModuleName());

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 using static access to class 'Vtiger_Record_Model' in method 'getHierarchy'.
Open

                $recordModel = Vtiger_Record_Model::getCleanInstance('MultiCompany');

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 using static access to class '\App\MultiCompany' in method 'privilegeToDelete'.
Open

            $this->privileges['Deleted'] = parent::privilegeToDelete() && !\App\MultiCompany::getRolesByCompany($this->getId());

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 using static access to class '\App\UserPrivilegesFile' in method 'save'.
Open

            \App\UserPrivilegesFile::reloadByMultiCompany($this->getId());

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 using static access to class '\App\MultiCompany' in method 'privilegeToMoveToTrash'.
Open

            $this->privileges['MoveToTrash'] = parent::privilegeToMoveToTrash() && !\App\MultiCompany::getRolesByCompany($this->getId());

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 "Deleted" 3 times.
Open

        if (!isset($this->privileges['Deleted'])) {

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.

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

        if (!isset($this->privileges['MoveToTrash'])) {

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.

Call to undeclared method \CRMEntity::getHierarchy
Open

        $hierarchy = $focus->getHierarchy($this->getId());
Severity: Critical
Found in modules/MultiCompany/models/Record.php by phan

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

class MultiCompany_Record_Model extends Vtiger_Record_Model

The class MultiCompany_Record_Model is not named in CamelCase.
Open

class MultiCompany_Record_Model extends Vtiger_Record_Model
{
    /** {@inheritdoc} */
    public function getHierarchy()
    {

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

        $hierarchy = $focus->getHierarchy($this->getId());

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

        if (false !== $this->getPreviousValue('logo')) {

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

    {

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

                preg_match('/[.\s]+/', $storageInfo[0], $dashes);

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

    /** {@inheritdoc} */

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

        foreach ($hierarchy['entries'] as $id => $storageInfo) {

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

            if (!empty($matches)) {

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

                $hierarchy['entries'][$id][0] = ($dashes[0] ?? '') . '<a href=' . $recordModel->getDetailViewUrl() . '>' . $name[2] . '</a>';

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

    }

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

        if (!isset($this->privileges['MoveToTrash'])) {

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

            $this->privileges['Deleted'] = parent::privilegeToDelete() && !\App\MultiCompany::getRolesByCompany($this->getId());

Line exceeds 120 characters; contains 128 characters
Open

            $this->privileges['Deleted'] = parent::privilegeToDelete() && !\App\MultiCompany::getRolesByCompany($this->getId());

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

            preg_match('/<a href="+/', $storageInfo[0], $matches);

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

                $recordModel = Vtiger_Record_Model::getCleanInstance('MultiCompany');

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

        if (!isset($this->privileges['Deleted'])) {

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

        $focus = CRMEntity::getInstance($this->getModuleName());

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

        return $hierarchy;

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

    public function privilegeToMoveToTrash()

Line exceeds 120 characters; contains 137 characters
Open

            $this->privileges['MoveToTrash'] = parent::privilegeToMoveToTrash() && !\App\MultiCompany::getRolesByCompany($this->getId());

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

    {

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

        }

Line exceeds 120 characters; contains 141 characters
Open

                $hierarchy['entries'][$id][0] = ($dashes[0] ?? '') . '<a href=' . $recordModel->getDetailViewUrl() . '>' . $name[2] . '</a>';

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

        parent::save();

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

        return $this->privileges['MoveToTrash'];

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

    public function privilegeToDelete()

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

        }

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

    public function getHierarchy()

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

    }

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

                $recordModel->setId($id);

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

            \App\UserPrivilegesFile::reloadByMultiCompany($this->getId());

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

                preg_match('/<a(.*)>(.*)<\\/a>/i', $storageInfo[0], $name);

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

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 $this->privileges['Deleted'];

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

    {

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

            $this->privileges['MoveToTrash'] = parent::privilegeToMoveToTrash() && !\App\MultiCompany::getRolesByCompany($this->getId());

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

class MultiCompany_Record_Model extends Vtiger_Record_Model

There are no issues that match your filters.

Category
Status