YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/Mail/models/Config.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

        $dataReader = (new \App\Db\Query())->select(['name', 'value'])

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

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

        \App\Db::getInstance()->createCommand()->update('yetiforce_mail_config', ['value' => $val], [

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::createCommand
Open

        \App\Db::getInstance('admin')->createCommand()->update('s_#__mail_queue', ['status' => 1], [
Severity: Critical
Found in modules/Settings/Mail/models/Config.php by phan

Saw possibly unextractable annotation for a fragment of comment '* @param bool true/false': after bool, did not see an element name (will guess based on comment order)
Open

     * @param bool true/false

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

        $dataReader = (new \App\Db\Query())->select(['name', 'value'])
Severity: Critical
Found in modules/Settings/Mail/models/Config.php by phan

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

        \App\Db::getInstance()->createCommand()->update('yetiforce_mail_config', ['value' => $val], [
Severity: Critical
Found in modules/Settings/Mail/models/Config.php by phan

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

class Settings_Mail_Config_Model

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

    public static function acceptanceRecord($id)

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

The class Settings_Mail_Config_Model is not named in CamelCase.
Open

class Settings_Mail_Config_Model
{
    public static function updateConfig($name, $val, $type)
    {
        \App\Db::getInstance()->createCommand()->update('yetiforce_mail_config', ['value' => $val], [

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

    {

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

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

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 acceptanceRecord($id)

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

    public static function getConfig($type)

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

            ->from('yetiforce_mail_config')

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

     * Function to get instance.

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

    {

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

            ->createCommand()->query();

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

     * @param bool true/false

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

     * @return Settings_Mail_Config_Model

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

    public static function getInstance()

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

            'name' => $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

    /**

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

        $config = [];

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

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

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

        \App\Db::getInstance('admin')->createCommand()->update('s_#__mail_queue', ['status' => 1], [

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

    }

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 updateConfig($name, $val, $type)

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

        return $config;

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

        $dataReader = (new \App\Db\Query())->select(['name', 'value'])

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

        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

        \App\Db::getInstance()->createCommand()->update('yetiforce_mail_config', ['value' => $val], [

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

            'type' => $type,

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

            $config[$row['name']] = $row['value'];

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

     *

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

class Settings_Mail_Config_Model

There are no issues that match your filters.

Category
Status