YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

The method Settings_TimeControlProcesses_Module_Model::getConfigInstance() calls the typical debug function print_r() which is mostly only used during development.
Open

        \App\Log::trace('Start ' . __METHOD__ . ' | Type: ' . print_r($type, true));

DevelopmentCodeFragment

Since: 2.3.0

Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.

Example

class SuspectCode {

    public function doSomething(array $items)
    {
        foreach ($items as $i => $item) {
            // …

            if ('qafoo' == $item) var_dump($i);

            // …
        }
    }
}

Source https://phpmd.org/rules/design.html#developmentcodefragment

The method getConfigInstance has a boolean flag argument $type, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function getConfigInstance($type = 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

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

        $query = (new App\Db\Query())->from('yetiforce_proc_tc');

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 '\App\Log' in method 'getConfigInstance'.
Open

        \App\Log::trace('Start ' . __METHOD__ . ' | Type: ' . print_r($type, true));

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\Log' in method 'setConfig'.
Open

        \App\Log::trace('Start ' . __METHOD__);

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\Log' in method 'getConfigInstance'.
Open

        \App\Log::trace('End ' . __METHOD__);

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\Log' in method 'setConfig'.
Open

        \App\Log::trace('End ' . __METHOD__);

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

            $output[$row['type']][$row['param']] = $row['value'];

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

            $output[$row['type']][$row['param']] = $row['value'];

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 \App\Db\Query::from
Open

        $query = (new App\Db\Query())->from('yetiforce_proc_tc');

Call to method trace from undeclared class \App\Log
Open

        \App\Log::trace('Start ' . __METHOD__);

Call to method trace from undeclared class \App\Log
Open

        \App\Log::trace('End ' . __METHOD__);

Call to method trace from undeclared class \App\Log
Open

        \App\Log::trace('Start ' . __METHOD__ . ' | Type: ' . print_r($type, true));

Call to method trace from undeclared class \App\Log
Open

        \App\Log::trace('End ' . __METHOD__);

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

        \App\Db::getInstance()->createCommand()

Avoid excessively long class names like Settings_TimeControlProcesses_Module_Model. Keep class name length under 40.
Open

class Settings_TimeControlProcesses_Module_Model extends \App\Base
{
    public static function getCleanInstance()
    {
        return new self();

LongClassName

Since: 2.9

Detects when classes or interfaces are declared with excessively long names.

Example

class ATooLongClassNameThatHintsAtADesignProblem {

}

interface ATooLongInterfaceNameThatHintsAtADesignProblem {

}

Source https://phpmd.org/rules/naming.html#longclassname

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

class Settings_TimeControlProcesses_Module_Model extends \App\Base

The class Settings_TimeControlProcesses_Module_Model is not named in CamelCase.
Open

class Settings_TimeControlProcesses_Module_Model extends \App\Base
{
    public static function getCleanInstance()
    {
        return new self();

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

        $query = (new App\Db\Query())->from('yetiforce_proc_tc');

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

            $query->where(['type' => $type]);

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

    public function setConfig($param)

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 new self();

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 true;

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

    public static function getCleanInstance()

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

        $this->setData($output);

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

            $output[$row['type']][$row['param']] = $row['value'];

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

        \App\Log::trace('Start ' . __METHOD__);

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

        \App\Log::trace('Start ' . __METHOD__ . ' | Type: ' . print_r($type, true));

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

        if ($type) {

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

        \App\Log::trace('End ' . __METHOD__);

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

        }

Line exceeds 120 characters; contains 139 characters
Open

            ->update('yetiforce_proc_tc', ['value' => $param['value']], ['type' => $param['type'], 'param' => $param['param']])->execute();

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;

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

        \App\Log::trace('End ' . __METHOD__);

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

    {

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

        \App\Db::getInstance()->createCommand()

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

        $output = [];

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 getConfigInstance($type = false)

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

            ->update('yetiforce_proc_tc', ['value' => $param['value']], ['type' => $param['type'], 'param' => $param['param']])->execute();

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

class Settings_TimeControlProcesses_Module_Model extends \App\Base

There are no issues that match your filters.

Category
Status