YetiForceCompany/YetiForceCRM

View on GitHub
modules/Calendar/ICalLastImport.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

            $importer = new \App\Db\Importers\Base();
Severity: Minor
Found in modules/Calendar/ICalLastImport.php by phpmd

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 '96', column '25').
Open

            $selectResult = (new \App\Db\Query())->select(['crmid'])->from($this->tableName)->where(['userid' => $userId, 'entitytype' => $moduleName])->column();
Severity: Minor
Found in modules/Calendar/ICalLastImport.php by phpmd

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

        $db = \App\Db::getInstance();
Severity: Minor
Found in modules/Calendar/ICalLastImport.php by phpmd

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 'vtlib\Utils' in method 'undo'.
Open

        if (vtlib\Utils::checkTable($this->tableName)) {
Severity: Minor
Found in modules/Calendar/ICalLastImport.php by phpmd

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 'vtlib\Utils' in method 'clearRecords'.
Open

        if (vtlib\Utils::checkTable($this->tableName)) {
Severity: Minor
Found in modules/Calendar/ICalLastImport.php by phpmd

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 "userid" 4 times.
Open

    public $fields = ['id', 'userid', 'entitytype', 'crmid'];
Severity: Critical
Found in modules/Calendar/ICalLastImport.php by sonar-php

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 "crmid" 4 times.
Open

    public $fields = ['id', 'userid', 'entitytype', 'crmid'];
Severity: Critical
Found in modules/Calendar/ICalLastImport.php by sonar-php

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

    public $fields = ['id', 'userid', 'entitytype', 'crmid'];
Severity: Critical
Found in modules/Calendar/ICalLastImport.php by sonar-php

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()->createCommand()->delete($this->tableName, ['userid' => $userId])->execute();
Severity: Critical
Found in modules/Calendar/ICalLastImport.php by phan

Argument 1 (length) is '200' but \App\Db\Importers\Base::stringType() takes int defined at /code/app/Db/Importers/Base.php:141
Open

                'entitytype' => $importer->stringType('200')->notNull(),
Severity: Minor
Found in modules/Calendar/ICalLastImport.php by phan

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

            $selectResult = (new \App\Db\Query())->select(['crmid'])->from($this->tableName)->where(['userid' => $userId, 'entitytype' => $moduleName])->column();
Severity: Critical
Found in modules/Calendar/ICalLastImport.php by phan

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

        \App\Db::getInstance()->createCommand()->insert($this->tableName, $this->fieldData)->execute();
Severity: Critical
Found in modules/Calendar/ICalLastImport.php by phan

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

            return \App\Db::getInstance()->createCommand()->update('vtiger_crmentity', ['deleted' => 1], ['crmid' => $selectResult])->execute();
Severity: Critical
Found in modules/Calendar/ICalLastImport.php by phan

Call to method notNull from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
Open

                'crmid' => $importer->integer(10)->notNull()]
Severity: Critical
Found in modules/Calendar/ICalLastImport.php by phan

Call to method notNull from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
Open

                'entitytype' => $importer->stringType('200')->notNull(),
Severity: Critical
Found in modules/Calendar/ICalLastImport.php by phan

Call to method notNull from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
Open

                'userid' => $importer->integer(10)->notNull(),
Severity: Critical
Found in modules/Calendar/ICalLastImport.php by phan

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

class ICalLastImport

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

        $db = \App\Db::getInstance();
Severity: Minor
Found in modules/Calendar/ICalLastImport.php by phpmd

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

     * @var array

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

     * Field data.

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

    /**

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

     * Table 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

     * Fields.

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

    public $fields = ['id', 'userid', 'entitytype', 'crmid'];

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

     * @var 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

     *

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 $tableName = 'vtiger_ical_import';

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

     * @var array

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

    public $fieldData = [];

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

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

        }

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

                'entitytype' => $importer->stringType('200')->notNull(),

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

        if (vtlib\Utils::checkTable($this->tableName)) {

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

     * Clear user records.

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 clearRecords($userId)

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

            foreach ($data as $name => $value) {

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

    }

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

     * Undo.

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

        }

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

                $this->fieldData[$name] = $value;

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

    /**

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

     * Save.

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

            return;

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

            return \App\Db::getInstance()->createCommand()->update('vtiger_crmentity', ['deleted' => 1], ['crmid' => $selectResult])->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

     * @param string $moduleName

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

     * @param int $userId

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

            $db->createTable($this->tableName, [

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

        \App\Db::getInstance()->createCommand()->insert($this->tableName, $this->fieldData)->execute();

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

     */

Line exceeds 120 characters; contains 144 characters
Open

            return \App\Db::getInstance()->createCommand()->update('vtiger_crmentity', ['deleted' => 1], ['crmid' => $selectResult])->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 function undo($moduleName, $userId)

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 (0 === \count($this->fieldData)) {

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

        if (vtlib\Utils::checkTable($this->tableName)) {

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

    }

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

     */

Line exceeds 120 characters; contains 162 characters
Open

            $selectResult = (new \App\Db\Query())->select(['crmid'])->from($this->tableName)->where(['userid' => $userId, 'entitytype' => $moduleName])->column();

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

    public function setFields($data)

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

            $importer = new \App\Db\Importers\Base();

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

     * @return bool|int

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

    {

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

            $selectResult = (new \App\Db\Query())->select(['crmid'])->from($this->tableName)->where(['userid' => $userId, 'entitytype' => $moduleName])->column();

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()->delete($this->tableName, ['userid' => $userId])->execute();

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

                'id' => 'pk',

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 (!empty($data)) {

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

                'crmid' => $importer->integer(10)->notNull()]

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 $data

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

        if (!$db->isTableExists($this->tableName)) {

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

     * Set fields.

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' => $importer->integer(10)->notNull(),

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 int    $userId

Expected 0 spaces before closing bracket; newline found
Open

            $db->createTable($this->tableName, [

There are no issues that match your filters.

Category
Status