YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/ModTracker/models/Module.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

        $query = (new \App\Db\Query())->select(['vtiger_tab.name', 'vtiger_tab.tabid', 'vtiger_modtracker_tabs.visible'])

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

    public function getModTrackerModules($active = 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

The method changeActiveStatus uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            CRMEntity::getInstance('ModTracker')->disableTrackingForModule($tabid);
        }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Call to undeclared method \CRMEntity::enableTrackingForModule
Open

            CRMEntity::getInstance('ModTracker')->enableTrackingForModule($tabid);

Call to undeclared method \CRMEntity::disableTrackingForModule
Open

            CRMEntity::getInstance('ModTracker')->disableTrackingForModule($tabid);

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

        $query = (new \App\Db\Query())->select(['vtiger_tab.name', 'vtiger_tab.tabid', 'vtiger_modtracker_tabs.visible'])

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

class Settings_ModTracker_Module_Model extends Settings_Vtiger_Module_Model

The class Settings_ModTracker_Module_Model is not named in CamelCase.
Open

class Settings_ModTracker_Module_Model extends Settings_Vtiger_Module_Model
{
    public function getModTrackerModules($active = false)
    {
        $restrictedModules = ['Integration', 'Dashboard'];

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

    public function getModTrackerModules($active = false)

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

            ->leftJoin('vtiger_modtracker_tabs', 'vtiger_tab.tabid = vtiger_modtracker_tabs.tabid')

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

            $modules[] = [

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

                'active' => 1 == $row['visible'] ? true : false,

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

        if ($active) {

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

        while ($row = $dataReader->read()) {

Line exceeds 120 characters; contains 121 characters
Open

        $query = (new \App\Db\Query())->select(['vtiger_tab.name', 'vtiger_tab.tabid', 'vtiger_modtracker_tabs.visible'])

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

        $dataReader = $query->createCommand()->query();

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

        return $modules;

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

                'id' => $row['tabid'],

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

            ->andWhere(['NOT IN', 'vtiger_tab.name', $restrictedModules]);

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

    {

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

                'module' => $row['name'],

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

            CRMEntity::getInstance('ModTracker')->enableTrackingForModule($tabid);

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

        } else {

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

            CRMEntity::getInstance('ModTracker')->disableTrackingForModule($tabid);

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

        $dataReader->close();

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

        if ($status) {

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 changeActiveStatus($tabid, $status)

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

            $query->andWhere(['tiger_modtracker_tabs.visible' => 1]);

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

        }

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

        $restrictedModules = ['Integration', 'Dashboard'];

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

            ->where(['vtiger_tab.presence' => [0, 2], 'vtiger_tab.isentitytype' => 1])

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

        $query = (new \App\Db\Query())->select(['vtiger_tab.name', 'vtiger_tab.tabid', 'vtiger_modtracker_tabs.visible'])

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

            ->from('vtiger_tab')

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

        $modules = [];

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

    }

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

class Settings_ModTracker_Module_Model extends Settings_Vtiger_Module_Model

There are no issues that match your filters.

Category
Status