YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using undefined variables such as '$modulesModels' which will lead to PHP notices.
Open

        return $modulesModels;

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

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

Avoid using undefined variables such as '$modulesModels' which will lead to PHP notices.
Open

            $modulesModels[$row['tabid']] = self::getInstance($row['name'], $row['tabid']);

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

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

Missing class import via use statement (line '83', column '38').
Open

            $success['sequenceNumber'] = (new App\Db\Query())->select(['cur_id'])

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

Missing class import via use statement (line '54', column '22').
Open

        $dataReader = (new App\Db\Query())->select(['tabid', 'name'])->from('vtiger_tab')->where(['isentitytype' => 1, 'presence' => 0, 'tabid' => $subQuery])->createCommand()->query();

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

Missing class import via use statement (line '53', column '20').
Open

        $subQuery = (new \App\Db\Query())->select(['tabid'])->from('vtiger_field')->where(['uitype' => 4])->distinct('tabid');

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

    public static function getInstance($moduleName, $tabId = 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 'CRMEntity' in method 'getFocus'.
Open

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

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 'setModuleSequence'.
Open

        $tabId = \App\Module::getModuleId($this->getName());

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\Fields\RecordNumber' in method 'setModuleSequence'.
Open

        $instance = \App\Fields\RecordNumber::getInstance($this->getName());

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

        $prefix = $this->get('prefix');

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 "tabid" 8 times.
Open

        $subQuery = (new \App\Db\Query())->select(['tabid'])->from('vtiger_field')->where(['uitype' => 4])->distinct('tabid');

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

        $postfix = $this->get('postfix');

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 undeclared property \Settings_RecordNumbering_Module_Model->focus
Open

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

Assigning string to property but \Settings_RecordNumbering_Module_Model->name is false
Open

        $moduleModel->name = $moduleName;

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

        $dataReader = (new App\Db\Query())->select(['tabid', 'name'])->from('vtiger_tab')->where(['isentitytype' => 1, 'presence' => 0, 'tabid' => $subQuery])->createCommand()->query();

Variable $modulesModels was undeclared, but array fields are being added to it.
Open

            $modulesModels[$row['tabid']] = self::getInstance($row['name'], $row['tabid']);

Call to method getInstance from undeclared class \App\Fields\RecordNumber (Did you mean class \Tests\Base\RecordNumber)
Open

        $instance = \App\Fields\RecordNumber::getInstance($this->getName());

Reference to undeclared property \Settings_RecordNumbering_Module_Model->focus
Open

        if (!isset($this->focus)) {

Reference to undeclared property \Settings_RecordNumbering_Module_Model->focus
Open

        return $this->focus;

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

            $success['sequenceNumber'] = (new App\Db\Query())->select(['cur_id'])

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

        $subQuery = (new \App\Db\Query())->select(['tabid'])->from('vtiger_field')->where(['uitype' => 4])->distinct('tabid');

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

class Settings_RecordNumbering_Module_Model extends Vtiger_Module_Model

The class Settings_RecordNumbering_Module_Model is not named in CamelCase.
Open

class Settings_RecordNumbering_Module_Model extends Vtiger_Module_Model
{
    /**
     * Function to get focus of this object.
     *

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

     * @param string $moduleName

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

        $moduleModel->name = $moduleName;

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 CRMEntity

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

     * @return self

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

     * @return array list of supported modules Vtiger_Module_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

        if ($tabId) {

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

    public static function getInstance($moduleName, $tabId = false)

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

Line exceeds 120 characters; contains 185 characters
Open

        $dataReader = (new App\Db\Query())->select(['tabid', 'name'])->from('vtiger_tab')->where(['isentitytype' => 1, 'presence' => 0, 'tabid' => $subQuery])->createCommand()->query();

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

        if (!isset($this->focus)) {

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

        $subQuery = (new \App\Db\Query())->select(['tabid'])->from('vtiger_field')->where(['uitype' => 4])->distinct('tabid');

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

        $dataReader = (new App\Db\Query())->select(['tabid', 'name'])->from('vtiger_tab')->where(['isentitytype' => 1, 'presence' => 0, 'tabid' => $subQuery])->createCommand()->query();

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 mixed  $tabId

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

     * Function to get focus of this object.

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 $moduleModel;

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

                ->from('vtiger_modentity_num')

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

        return $this->focus;

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

     */

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

     * Function to ger Supported modules for Custom record numbering.

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

        $instance->set('leading_zeros', $this->get('leading_zeros'));

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

                ->where(['tabid' => $tabId, 'prefix' => $prefix, 'postfix' => $postfix])

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

    public function getFocus()

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

        }

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

            $modulesModels[$row['tabid']] = self::getInstance($row['name'], $row['tabid']);

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

        $instance->set('postfix', $postfix);

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

        $status = $instance->save();

Line exceeds 120 characters; contains 126 characters
Open

        $subQuery = (new \App\Db\Query())->select(['tabid'])->from('vtiger_field')->where(['uitype' => 4])->distinct('tabid');

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

        $tabId = \App\Module::getModuleId($this->getName());

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

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

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 $modulesModels;

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

     * Function to get Instance of this 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

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

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

     * @return array result of success

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

        $moduleModel = new self();

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

            $moduleModel->id = $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

        $instance = \App\Fields\RecordNumber::getInstance($this->getName());

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

            $success['sequenceNumber'] = (new App\Db\Query())->select(['cur_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

                ->scalar();

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

        }

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

     * Function to set Module sequence.

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

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

        }

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

        $success = ['success' => $status];

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

        $prefix = $this->get('prefix');

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

        $postfix = $this->get('postfix');

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

        $instance->set('tabid', $tabId);

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

        $instance->set('cur_id', $this->get('sequenceNumber'));

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

    {

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

        $instance->set('prefix', $prefix);

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

    }

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

        $instance->set('reset_sequence', $this->get('reset_sequence'));

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

        return $success;

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

class Settings_RecordNumbering_Module_Model extends Vtiger_Module_Model

There are no issues that match your filters.

Category
Status