YetiForceCompany/YetiForceCRM

View on GitHub
modules/Contacts/crons/CardDav.php

Summary

Maintainability
A
1 hr
Test Coverage
A
95%

Method process has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function process()
    {
        \App\Log::trace('Start cron CardDAV');
        if(!\App\YetiForce\Shop::check('YetiForceDav')){
            $this->logs = \App\YetiForce\Shop::checkAlert('YetiForceDav');
Severity: Minor
Found in modules/Contacts/crons/CardDav.php - About 1 hr to fix

    Function process has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function process()
        {
            \App\Log::trace('Start cron CardDAV');
            if(!\App\YetiForce\Shop::check('YetiForceDav')){
                $this->logs = \App\YetiForce\Shop::checkAlert('YetiForceDav');
    Severity: Minor
    Found in modules/Contacts/crons/CardDav.php - About 25 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

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

            $cardDav = new API_CardDAV_Model();
    Severity: Minor
    Found in modules/Contacts/crons/CardDav.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 '23', column '14').
    Open

            $dav = new API_DAV_Model();
    Severity: Minor
    Found in modules/Contacts/crons/CardDav.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\YetiForce\Shop' in method 'process'.
    Open

            if(!\App\YetiForce\Shop::check('YetiForceDav')){
    Severity: Minor
    Found in modules/Contacts/crons/CardDav.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 '\App\Log' in method 'process'.
    Open

                    \App\Log::trace(__METHOD__ . ' | User is active ' . $user->getName());
    Severity: Minor
    Found in modules/Contacts/crons/CardDav.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 'API_DAV_Model' in method 'process'.
    Open

            $davUsers = API_DAV_Model::getAllUser(1);
    Severity: Minor
    Found in modules/Contacts/crons/CardDav.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 '\App\Log' in method 'process'.
    Open

            \App\Log::trace('End cron CardDAV');
    Severity: Minor
    Found in modules/Contacts/crons/CardDav.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 'Users_Record_Model' in method 'process'.
    Open

            foreach (Users_Record_Model::getAll() as $id => $user) {
    Severity: Minor
    Found in modules/Contacts/crons/CardDav.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 '\App\YetiForce\Shop' in method 'process'.
    Open

                $this->logs = \App\YetiForce\Shop::checkAlert('YetiForceDav');
    Severity: Minor
    Found in modules/Contacts/crons/CardDav.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

    The method process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else { // User is inactive
                    \App\Log::info(__METHOD__ . ' | User is inactive ' . $user->getName());
                }
    Severity: Minor
    Found in modules/Contacts/crons/CardDav.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Avoid using static access to class '\App\Log' in method 'process'.
    Open

            \App\Log::trace('Start cron CardDAV');
    Severity: Minor
    Found in modules/Contacts/crons/CardDav.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 '\App\Log' in method 'process'.
    Open

                    \App\Log::info(__METHOD__ . ' | User is inactive ' . $user->getName());
    Severity: Minor
    Found in modules/Contacts/crons/CardDav.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

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

            \App\Log::trace('End cron CardDAV');
    Severity: Critical
    Found in modules/Contacts/crons/CardDav.php by phan

    Call to method checkAlert from undeclared class \App\YetiForce\Shop
    Open

                $this->logs = \App\YetiForce\Shop::checkAlert('YetiForceDav');
    Severity: Critical
    Found in modules/Contacts/crons/CardDav.php by phan

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

                    \App\Log::info(__METHOD__ . ' | User is inactive ' . $user->getName());
    Severity: Critical
    Found in modules/Contacts/crons/CardDav.php by phan

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

            \App\Log::trace('Start cron CardDAV');
    Severity: Critical
    Found in modules/Contacts/crons/CardDav.php by phan

    Call to method getUserModel from undeclared class \App\User (Did you mean class \Tests\App\User)
    Open

                    $user->set('groups', \App\User::getUserModel($id)->getGroups());
    Severity: Critical
    Found in modules/Contacts/crons/CardDav.php by phan

    Call to method check from undeclared class \App\YetiForce\Shop
    Open

            if(!\App\YetiForce\Shop::check('YetiForceDav')){
    Severity: Critical
    Found in modules/Contacts/crons/CardDav.php by phan

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

                    \App\Log::trace(__METHOD__ . ' | User is active ' . $user->getName());
    Severity: Critical
    Found in modules/Contacts/crons/CardDav.php by phan

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

    class Contacts_CardDav_Cron extends \App\CronHandler

    The class Contacts_CardDav_Cron is not named in CamelCase.
    Open

    class Contacts_CardDav_Cron extends \App\CronHandler
    {
        /** {@inheritdoc} */
        public function process()
        {
    Severity: Minor
    Found in modules/Contacts/crons/CardDav.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

                    ++$users;

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

            $this->logs .= ' | dav2Crm: ' . $cardDav->dav2Crm();

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

                    $dav->davUsers[$id] = $user;

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

                    \App\Log::trace(__METHOD__ . ' | User is active ' . $user->getName());

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

            if ($this->checkTimeout()) {

    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

            $users = 0;

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

                if (isset($davUsers[$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

                    $user->set('david', $davUsers[$id]['david']);

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

            \App\Log::trace('End cron CardDAV');

    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

            $this->logs = 'crm2Dav: ' . $cardDav->crm2Dav();

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

        }

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

            $davUsers = API_DAV_Model::getAllUser(1);

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

                } else { // User is inactive

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

                    \App\Log::info(__METHOD__ . ' | User is inactive ' . $user->getName());

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

        public function process()

    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

            }

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

                $this->logs = \App\YetiForce\Shop::checkAlert('YetiForceDav');

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

                    $user->set('addressbooksid', $davUsers[$id]['addressbooksid']);

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

        /** {@inheritdoc} */

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

            foreach (Users_Record_Model::getAll() as $id => $user) {

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

            $cardDav->davUsers = $dav->davUsers;

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

            if(!\App\YetiForce\Shop::check('YetiForceDav')){

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

            $this->logs = "Users: $users";

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

            $dav = new API_DAV_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

                    $user->set('groups', \App\User::getUserModel($id)->getGroups());

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

            $cardDav = new API_CardDAV_Model();

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

            \App\Log::trace('Start cron CardDAV');

    Expected 1 space after IF keyword; 0 found
    Open

            if(!\App\YetiForce\Shop::check('YetiForceDav')){

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

    class Contacts_CardDav_Cron extends \App\CronHandler

    Expected 1 space after closing parenthesis; found 0
    Open

            if(!\App\YetiForce\Shop::check('YetiForceDav')){

    There are no issues that match your filters.

    Category
    Status