YetiForceCompany/YetiForceCRM

View on GitHub
modules/ModTracker/models/Relation.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Missing class import via use statement (line '52', column '14').
Open

        $id = (new \App\Db\Query())->from('u_#__reviewed_queue')->max('id') + 1;

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 reviewChanges has a boolean flag argument $userId, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function reviewChanges($recordsList, $userId = false)

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Avoid using static access to class 'Vtiger_Module_Model' in method 'getDetailViewUrl'.
Open

        $moduleModel = Vtiger_Module_Model::getInstance($this->get('targetmodule'));

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\Module' in method 'reviewChangesQueue'.
Open

            'tabid' => \App\Module::getModuleId($module),

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\Json' in method 'reviewChangesQueue'.
Open

            'data' => \App\Json::encode($data),

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 'Users_Record_Model' in method 'reviewChangesQueue'.
Open

        $currentUserModel = Users_Record_Model::getCurrentUserModel();

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 'ModTracker_Record_Model' in method 'reviewChanges'.
Open

            ModTracker_Record_Model::unsetReviewed($record, $userId, $result);

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\Db' in method 'reviewChangesQueue'.
Open

        $db = \App\Db::getInstance();

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 'ModTracker_Record_Model' in method 'reviewChanges'.
Open

            $result = ModTracker_Record_Model::setLastReviewed($record);

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\Record' in method 'getValue'.
Open

        return \App\Record::getLabel($this->get('targetid'));

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

Call to undeclared method \App\Db::createCommand
Open

        $db->createCommand()->insert('u_#__reviewed_queue', [
Severity: Critical
Found in modules/ModTracker/models/Relation.php by phan

Default value for int $userId can't be false
Open

    public static function reviewChanges($recordsList, $userId = false)
Severity: Minor
Found in modules/ModTracker/models/Relation.php by phan

Reference to undeclared property \ModTracker_Relation_Model->parent
Open

        return $this->parent;
Severity: Minor
Found in modules/ModTracker/models/Relation.php by phan

Reference to undeclared property \ModTracker_Relation_Model->parent (Did you mean $parent)
Open

        $this->parent = $parent;
Severity: Minor
Found in modules/ModTracker/models/Relation.php by phan

Call to undeclared method \App\Db\Query::from
Open

        $id = (new \App\Db\Query())->from('u_#__reviewed_queue')->max('id') + 1;
Severity: Critical
Found in modules/ModTracker/models/Relation.php by phan

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

class ModTracker_Relation_Model extends Vtiger_Record_Model

The class ModTracker_Relation_Model is not named in CamelCase.
Open

class ModTracker_Relation_Model extends Vtiger_Record_Model
{
    protected $linkedRecordCache = [];

    public function getValue()

CamelCaseClassName

Since: 0.2

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

Example

class class_name {
}

Source

Avoid variables with short names like $db. Configured minimum length is 3.
Open

        $db = \App\Db::getInstance();

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

Avoid variables with short names like $id. Configured minimum length is 3.
Open

        $id = (new \App\Db\Query())->from('u_#__reviewed_queue')->max('id') + 1;

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

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

    /**

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

Line exceeds 120 characters; contains 149 characters
Open

        return 'index.php?module=' . $this->get('targetmodule') . '&view=' . $moduleModel->getDetailViewName() . '&record=' . $this->get('targetid');

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

     * @param string $module - Module name

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

        $db = \App\Db::getInstance();

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

            'id' => $id,

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

            'data' => \App\Json::encode($data),

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

        $id = (new \App\Db\Query())->from('u_#__reviewed_queue')->max('id') + 1;

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

        return \App\Record::getLabel($this->get('targetid'));

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

            'tabid' => \App\Module::getModuleId($module),

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

        return $this->parent;

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

     */

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

            ModTracker_Record_Model::unsetReviewed($record, $userId, $result);

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 string

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

    /**

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

        $currentUserModel = Users_Record_Model::getCurrentUserModel();

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

    }

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

            'userid' => $currentUserModel->getRealId(),

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

            'time' => date('Y-m-d H:i:s'),

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 static function reviewChangesQueue($data, $module)

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 static function reviewChanges($recordsList, $userId = false)

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

    public function getDetailViewUrl()

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

     * @param array  $data   - List of records to update

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

        $db->createCommand()->insert('u_#__reviewed_queue', [

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 setParent($parent)

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

     */

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

            $result = ModTracker_Record_Model::setLastReviewed($record);

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

        return 'index.php?module=' . $this->get('targetmodule') . '&view=' . $moduleModel->getDetailViewName() . '&record=' . $this->get('targetid');

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

     * Function adds records to task queue that updates reviewing changes in records.

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

     * @param int   $userId      - User 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

     *

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

     * @param array $recordsList - List of records to update

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

    public function getValue()

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

        $this->parent = $parent;

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

     * Function return link to record.

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

        $moduleModel = Vtiger_Module_Model::getInstance($this->get('targetmodule'));

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

    }

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

        foreach ($recordsList as $record) {

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

    protected $linkedRecordCache = [];

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

        ])->execute();

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

     * Function marks forwarded records as reviewed.

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

class ModTracker_Relation_Model extends Vtiger_Record_Model

There are no issues that match your filters.

Category
Status