YetiForceCompany/YetiForceCRM

View on GitHub
modules/API/models/DAV.php

Summary

Maintainability
A
1 hr
Test Coverage
C
79%

Method getAllUser has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getAllUser($type = 0)
    {
        $db = new App\Db\Query();
        if (0 === $type) {
            $db->select([
Severity: Minor
Found in modules/API/models/DAV.php - About 1 hr to fix

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

            $db = new App\Db\Query();
    Severity: Minor
    Found in modules/API/models/DAV.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

    Define a constant instead of duplicating this literal "vtiger_users.id = dav_users.userid" 3 times.
    Open

                    ->innerJoin('vtiger_users', 'vtiger_users.id = dav_users.userid')
    Severity: Critical
    Found in modules/API/models/DAV.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 "vtiger_users.status" 3 times.
    Open

                    'vtiger_users.status',
    Severity: Critical
    Found in modules/API/models/DAV.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 "dav_users" 3 times.
    Open

                ])->from('dav_users')
    Severity: Critical
    Found in modules/API/models/DAV.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 "dav_principals.userid = dav_users.userid" 3 times.
    Open

                    ->innerJoin('dav_principals', 'dav_principals.userid = dav_users.userid')
    Severity: Critical
    Found in modules/API/models/DAV.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 "dav_principals" 3 times.
    Open

                    ->innerJoin('dav_principals', 'dav_principals.userid = dav_users.userid')
    Severity: Critical
    Found in modules/API/models/DAV.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 "userid" 4 times.
    Open

                    'userid' => 'vtiger_users.id',
    Severity: Critical
    Found in modules/API/models/DAV.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 "vtiger_users" 3 times.
    Open

                    ->innerJoin('vtiger_users', 'vtiger_users.id = dav_users.userid')
    Severity: Critical
    Found in modules/API/models/DAV.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 method close from undeclared class \yii\db\DataReader
    Open

            $dataReader->close();
    Severity: Critical
    Found in modules/API/models/DAV.php by phan

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

                $db->select([
    Severity: Critical
    Found in modules/API/models/DAV.php by phan

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

                $db->select([
    Severity: Critical
    Found in modules/API/models/DAV.php by phan

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

                $db->select([
    Severity: Critical
    Found in modules/API/models/DAV.php by phan

    Call to method read from undeclared class \yii\db\DataReader
    Open

            while ($row = $dataReader->read()) {
    Severity: Critical
    Found in modules/API/models/DAV.php by phan

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

    class API_DAV_Model
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

            $db = new App\Db\Query();
    Severity: Minor
    Found in modules/API/models/DAV.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

    The class API_DAV_Model is not named in CamelCase.
    Open

    class API_DAV_Model
    {
        public $davUsers = [];
    
        public static function getAllUser($type = 0)
    Severity: Minor
    Found in modules/API/models/DAV.php by phpmd

    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

                ])->from('dav_users')
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

        public static function getAllUser($type = 0)
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    'dav_principals.displayname',
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    'calendarsid' => 'dav_calendarinstances.calendarid',
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    ->innerJoin('vtiger_users', 'vtiger_users.id = dav_users.userid')
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    ->where(['vtiger_users.status' => 'Active']);
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    'userid' => 'dav_users.userid',
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                ])->from('dav_users')
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    'vtiger_users.status',
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

            } elseif (1 === $type) {
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    ->innerJoin('vtiger_users', 'vtiger_users.id = dav_users.userid')
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    'david' => 'dav_users.id',
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    'userid' => 'vtiger_users.id',
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    'dav_principals.email',
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    'vtiger_users.user_name',
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    ->innerJoin('dav_principals', 'dav_principals.userid = dav_users.userid')
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                ])->from('dav_users')
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

            $db = new App\Db\Query();
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                $db->select([
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

            }
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

        public $davUsers = [];
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

        {
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    'calendarsid' => 'dav_calendarinstances.calendarid',
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    ->where(['vtiger_users.status' => 'Active']);
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    'userid' => 'dav_users.userid',
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    'addressbooksid' => 'dav_addressbooks.id',
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                $db->select([
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    'dav_users.*',
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    'addressbooksid' => 'dav_addressbooks.id',
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    'david' => 'dav_users.id',
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    ->innerJoin('dav_principals', 'dav_principals.userid = dav_users.userid')
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    ->innerJoin('dav_addressbooks', 'dav_addressbooks.principaluri = dav_principals.uri')
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                $users[$row['userid']] = $row;
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

            $dataReader->close();
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

            return $users;
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

        }
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    ->leftJoin('dav_addressbooks', 'dav_addressbooks.principaluri = dav_principals.uri')
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

            } elseif (2 === $type) {
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

            }
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    ->innerJoin('dav_principals', 'dav_principals.userid = dav_users.userid')
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

            if (0 === $type) {
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                $db->select([
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    ->leftJoin('dav_calendarinstances', 'dav_calendarinstances.principaluri = dav_principals.uri');
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    ->innerJoin('vtiger_users', 'vtiger_users.id = dav_users.userid')
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

                    ->innerJoin('dav_calendarinstances', 'dav_calendarinstances.principaluri = dav_principals.uri')
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

            $dataReader = $db->createCommand()->query();
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

            while ($row = $dataReader->read()) {
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

            $users = [];
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

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

    class API_DAV_Model
    Severity: Minor
    Found in modules/API/models/DAV.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status