YetiForceCompany/YetiForceCRM

View on GitHub
app/TextParser/OverdueDeadlines.php

Summary

Maintainability
A
2 hrs
Test Coverage
F
0%

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

    public function process()
    {
        $moduleName = 'Calendar';
        $moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
        $currentUserModel = \App\User::getCurrentUserModel();
Severity: Minor
Found in app/TextParser/OverdueDeadlines.php - About 1 hr to fix

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

        public function process()
        {
            $moduleName = 'Calendar';
            $moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
            $currentUserModel = \App\User::getCurrentUserModel();
    Severity: Minor
    Found in app/TextParser/OverdueDeadlines.php - About 1 hr 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 '33', column '25').
    Open

            $queryGenerator = new \App\QueryGenerator($moduleName, $adminUser);
    Severity: Minor
    Found in app/TextParser/OverdueDeadlines.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 '\Vtiger_Module_Model' in method 'process'.
    Open

            $moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
    Severity: Minor
    Found in app/TextParser/OverdueDeadlines.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\User' in method 'process'.
    Open

            $adminUser = !$currentUserModel->isAdmin() ? \App\User::getActiveAdminId() : $currentUserModel->getId();
    Severity: Minor
    Found in app/TextParser/OverdueDeadlines.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\Language' in method 'process'.
    Open

                $html .= "<th style=\"{$headerStyle}\"><span>" . \App\Language::translate($fieldModel->get('label'), $moduleName) . '</span></th>';
    Severity: Minor
    Found in app/TextParser/OverdueDeadlines.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 assigning values to variables in if clauses and the like (line '45', column '10').
    Open

        public function process()
        {
            $moduleName = 'Calendar';
            $moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
            $currentUserModel = \App\User::getCurrentUserModel();
    Severity: Minor
    Found in app/TextParser/OverdueDeadlines.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

    Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

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

            $currentUserModel = \App\User::getCurrentUserModel();
    Severity: Minor
    Found in app/TextParser/OverdueDeadlines.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 '\Vtiger_Record_Model' in method 'process'.
    Open

                    $recordModel = \Vtiger_Record_Model::getInstanceById($recordId);
    Severity: Minor
    Found in app/TextParser/OverdueDeadlines.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 __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
    Open

            $queryGenerator = new \App\QueryGenerator($moduleName, $adminUser);
    Severity: Critical
    Found in app/TextParser/OverdueDeadlines.php by phan

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

            $adminUser = !$currentUserModel->isAdmin() ? \App\User::getActiveAdminId() : $currentUserModel->getId();
    Severity: Critical
    Found in app/TextParser/OverdueDeadlines.php by phan

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

            $currentUserModel = \App\User::getCurrentUserModel();
    Severity: Critical
    Found in app/TextParser/OverdueDeadlines.php by phan

    Call to method addNativeCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
    Open

            $queryGenerator->addNativeCondition(['vtiger_crmentity.smownerid' => $currentUserModel->getId()]);
    Severity: Critical
    Found in app/TextParser/OverdueDeadlines.php by phan

    Call to method addNativeCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
    Open

            $queryGenerator->addNativeCondition(['vtiger_activity.status' => 'PLL_OVERDUE']);
    Severity: Critical
    Found in app/TextParser/OverdueDeadlines.php by phan

    Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
    Open

            $queryGenerator->setFields(['id']);
    Severity: Critical
    Found in app/TextParser/OverdueDeadlines.php by phan

    Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
    Open

            $query = $queryGenerator->createQuery();
    Severity: Critical
    Found in app/TextParser/OverdueDeadlines.php by phan

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

            $queryGenerator->addNativeCondition(['vtiger_activity.status' => 'PLL_OVERDUE']);

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

                    $columnName = $column->getName();

    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

        /** @var string Class name */

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

        public $name = 'LBL_OVERDUE_DEADLINES';

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

            $adminUser = !$currentUserModel->isAdmin() ? \App\User::getActiveAdminId() : $currentUserModel->getId();

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

                }

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

            $counter = 0;

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

                    $recordModel = \Vtiger_Record_Model::getInstanceById($recordId);

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

                    $style = $bodyStyle;

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

                        $style = $bodyStyle . 'text-align:center;';

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

                $html .= "<th style=\"{$headerStyle}\"><span>" . \App\Language::translate($fieldModel->get('label'), $moduleName) . '</span></th>';

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

                foreach ($columns as $column) {

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

            return $html . '</tbody></table>';

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

        /** @var mixed Parser type */

    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

            $dataReader = $query->createCommand()->query();

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

            foreach (['subject', 'activitytype', 'date_start', 'link'] as $column) {

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

                if (!($fieldModel = $moduleModel->getFieldByColumn($column)) || !$fieldModel->isActiveField()) {

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

                $columns[$column] = $fieldModel;

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

            $query->limit(500);

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

            $html = '<table border="1" class="products-table" style="border-collapse:collapse;width:100%;"><thead><tr>';

    Line exceeds 120 characters; contains 143 characters
    Open

                $html .= "<th style=\"{$headerStyle}\"><span>" . \App\Language::translate($fieldModel->get('label'), $moduleName) . '</span></th>';

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

            $headerStyle = 'font-size:9px;padding:0px 4px;text-align:center;';

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

            $html .= '</tr></thead><tbody>';

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

            $queryGenerator->setFields(['id']);

    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

        public function process()

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

            $query = $queryGenerator->createQuery();

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

                    $recordId = $row['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

         * @return string

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

            $queryGenerator = new \App\QueryGenerator($moduleName, $adminUser);

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

            $queryGenerator->addNativeCondition(['vtiger_crmentity.smownerid' => $currentUserModel->getId()]);

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

                    continue;

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

                ++$counter;

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

            $columns = [];

    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 $type = 'pdf';

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

         */

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

            $moduleName = 'Calendar';

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

                    $html .= "<td style=\"{$style}\">" . $recordModel->getDisplayValue($columnName, false, true) . '</td>';

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

            $moduleModel = \Vtiger_Module_Model::getInstance($moduleName);

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

            $currentUserModel = \App\User::getCurrentUserModel();

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

                $html .= '</tr>';

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

         * Process.

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

            $bodyStyle = 'font-size:8px;border:1px solid #ddd;padding:0px 4px;';

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

                $html .= '<tr class="row-' . $counter . '">';

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

                    if (\in_array($columnName, ['activitytype', 'date_start'])) {

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

        }

    There are no issues that match your filters.

    Category
    Status