YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/Magento/actions/Active.php

Summary

Maintainability
B
5 hrs
Test Coverage
F
0%

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

    public function process(App\Request $request)
    {
        $sSingleOrderTabId = \App\Module::getModuleId('SSingleOrders');
        $fInvoiceTabId = \App\Module::getModuleId('FInvoice');
        $productCategoryId = \App\Module::getModuleId('ProductCategory');
Severity: Major
Found in modules/Settings/Magento/actions/Active.php - About 2 hrs to fix

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

        public function process(App\Request $request)
        {
            $sSingleOrderTabId = \App\Module::getModuleId('SSingleOrders');
            $fInvoiceTabId = \App\Module::getModuleId('FInvoice');
            $productCategoryId = \App\Module::getModuleId('ProductCategory');
    Severity: Minor
    Found in modules/Settings/Magento/actions/Active.php - About 55 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 '50', column '24').
    Open

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $sSingleOrderTabId, 'fieldname' => array_keys($fields)])->column();

    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 '60', column '24').
    Open

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $fInvoiceTabId, 'fieldname' => array_keys($fields)])->column();

    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 '69', column '24').
    Open

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $productCategoryId, 'fieldname' => array_keys($fields)])->column();

    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 '24', column '23').
    Open

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

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

                $fieldInstance = new Vtiger_Field_Model();

    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 'vtlib\Block' in method 'process'.
    Open

                    $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance('FInvoice'));

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

        public function process(App\Request $request)
        {
            $sSingleOrderTabId = \App\Module::getModuleId('SSingleOrders');
            $fInvoiceTabId = \App\Module::getModuleId('FInvoice');
            $productCategoryId = \App\Module::getModuleId('ProductCategory');

    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 'vtlib\Block' in method 'process'.
    Open

                $blockModel = vtlib\Block::getInstance('LBL_BASIC_INFORMATION', 'ProductCategory');

    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\Module' in method 'process'.
    Open

                    $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance('SSingleOrders'));

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

        public function process(App\Request $request)
        {
            $sSingleOrderTabId = \App\Module::getModuleId('SSingleOrders');
            $fInvoiceTabId = \App\Module::getModuleId('FInvoice');
            $productCategoryId = \App\Module::getModuleId('ProductCategory');

    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 'vtlib\Block' in method 'process'.
    Open

                $blockModel = vtlib\Block::getInstance('LBL_CUSTOM_INFORMATION', 'FInvoice');

    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\Module' in method 'process'.
    Open

            $sSingleOrderTabId = \App\Module::getModuleId('SSingleOrders');

    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\Cron' in method 'process'.
    Open

            \App\Cron::updateStatus(\App\Cron::STATUS_ENABLED, 'LBL_MAGENTO');

    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\Module' in method 'process'.
    Open

                    $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance('FInvoice'));

    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\Module' in method 'process'.
    Open

            $fInvoiceTabId = \App\Module::getModuleId('FInvoice');

    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\Block' in method 'process'.
    Open

                    $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance('ProductCategory'));

    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\Block' in method 'process'.
    Open

                $blockModel = vtlib\Block::getInstance('LBL_CUSTOM_INFORMATION', 'SSingleOrders');

    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\Block' in method 'process'.
    Open

                    $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance('SSingleOrders'));

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

        public function process(App\Request $request)
        {
            $sSingleOrderTabId = \App\Module::getModuleId('SSingleOrders');
            $fInvoiceTabId = \App\Module::getModuleId('FInvoice');
            $productCategoryId = \App\Module::getModuleId('ProductCategory');

    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\Module' in method 'process'.
    Open

            $productCategoryId = \App\Module::getModuleId('ProductCategory');

    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\EventHandler' in method 'process'.
    Open

            \App\EventHandler::setActive('IStorages_RecalculateStockHandler_Handler', 'IStoragesAfterUpdateStock');

    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\Module' in method 'process'.
    Open

                    $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance('ProductCategory'));

    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 "fieldname" 6 times.
    Open

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $sSingleOrderTabId, 'fieldname' => array_keys($fields)])->column();

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

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $sSingleOrderTabId, 'fieldname' => array_keys($fields)])->column();

    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 "maximumlength" 5 times.
    Open

                    'maximumlength' => '4294967295',

    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 "uitype" 5 times.
    Open

                    'uitype' => 325,

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

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $sSingleOrderTabId, 'fieldname' => array_keys($fields)])->column();

    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 "label" 5 times.
    Open

                    'label' => 'FL_MAGENTO_SERVER',

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

            $sSingleOrderTabId = \App\Module::getModuleId('SSingleOrders');

    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 "columntype" 5 times.
    Open

                    'columntype' => $importerType->integer(10)->defaultValue(0)->notNull()->unsigned(),

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

                    'picklistValues' => ['PLL_PENDING', 'PLL_PENDING_PAYMENT', 'PLL_PENDING_PAYPAL',  'PLL_PAID', 'PLL_PROCESSING', 'PLL_ON_HOLD', 'PLL_SEND', 'PLL_FRAUD', 'PLL_PAYMENT_REVIEW', 'PLL_PAYPAL_CANCELED_REVERSAL', 'PLL_PAYPAL_REVERSED', 'PLL_CANCELLED', 'PLL_CLOSED', 'PLL_COMPLETE']

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

            $productCategoryId = \App\Module::getModuleId('ProductCategory');

    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 "typeofdata" 5 times.
    Open

                    'typeofdata' => 'I~O'

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

            $fInvoiceTabId = \App\Module::getModuleId('FInvoice');

    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 "displaytype" 5 times.
    Open

                    'displaytype' => 2,

    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 defaultValue from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
    Open

                    'columntype' => $importerType->integer(10)->defaultValue(0)->notNull()->unsigned(),

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

                    'columntype' => $importerType->integer(10)->defaultValue(0)->notNull()->unsigned(),

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

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $productCategoryId, 'fieldname' => array_keys($fields)])->column();

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

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $sSingleOrderTabId, 'fieldname' => array_keys($fields)])->column();

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

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $fInvoiceTabId, 'fieldname' => array_keys($fields)])->column();

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

                    'columntype' => $importerType->stringType(255)->defaultValue(''),

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

            if ($fieldsToAdd = array_diff_key($fields, array_flip($fieldsExists))) {
                $blockModel = vtlib\Block::getInstance('LBL_CUSTOM_INFORMATION', 'FInvoice');
                if (!$blockModel) {
                    $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance('FInvoice'));
                    $blockModel = current($blocks);
    Severity: Major
    Found in modules/Settings/Magento/actions/Active.php and 2 other locations - About 50 mins to fix
    modules/Settings/Magento/actions/Active.php on lines 51..58
    modules/Settings/Magento/actions/Active.php on lines 70..77

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 97.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

            if ($fieldsToAdd = array_diff_key($fields, array_flip($fieldsExists))) {
                $blockModel = vtlib\Block::getInstance('LBL_CUSTOM_INFORMATION', 'SSingleOrders');
                if (!$blockModel) {
                    $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance('SSingleOrders'));
                    $blockModel = current($blocks);
    Severity: Major
    Found in modules/Settings/Magento/actions/Active.php and 2 other locations - About 50 mins to fix
    modules/Settings/Magento/actions/Active.php on lines 61..68
    modules/Settings/Magento/actions/Active.php on lines 70..77

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 97.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

            if ($fieldsToAdd = array_diff_key($fields, array_flip($fieldsExists))) {
                $blockModel = vtlib\Block::getInstance('LBL_BASIC_INFORMATION', 'ProductCategory');
                if (!$blockModel) {
                    $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance('ProductCategory'));
                    $blockModel = current($blocks);
    Severity: Major
    Found in modules/Settings/Magento/actions/Active.php and 2 other locations - About 50 mins to fix
    modules/Settings/Magento/actions/Active.php on lines 51..58
    modules/Settings/Magento/actions/Active.php on lines 61..68

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 97.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

    class Settings_Magento_Active_Action extends Settings_Vtiger_Save_Action

    The class Settings_Magento_Active_Action is not named in CamelCase.
    Open

    class Settings_Magento_Active_Action extends Settings_Vtiger_Save_Action
    {
        /** {@inheritdoc} */
        public function process(App\Request $request)
        {

    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

        public function process(App\Request $request)

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

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

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

                    'typeofdata' => 'I~O'

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

                    'typeofdata' => 'I~O'

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

                    'displaytype' => 2,

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

            if ($fieldsToAdd = array_diff_key($fields, array_flip($fieldsExists))) {

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

                'magento_server_id' => [

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

                ], 'magento_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

            unset($fields['status_magento']);

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

                    'maximumlength' => '4294967295',

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

                if (!$blockModel) {

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

            $fInvoiceTabId = \App\Module::getModuleId('FInvoice');

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

                $blockModel = vtlib\Block::getInstance('LBL_CUSTOM_INFORMATION', 'SSingleOrders');

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

            if ($fieldsToAdd = array_diff_key($fields, array_flip($fieldsExists))) {

    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

                }

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

            }

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

                    'columntype' => $importerType->integer(10)->defaultValue(0)->notNull()->unsigned(),

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

                    'columntype' => $importerType->integer(10)->defaultValue(0)->notNull()->unsigned(),

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

                if (!$blockModel) {

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

                    $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance('SSingleOrders'));

    Line exceeds 120 characters; contains 173 characters
    Open

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $fInvoiceTabId, 'fieldname' => array_keys($fields)])->column();

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

                    'typeofdata' => 'V~O',

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

                $blockModel = vtlib\Block::getInstance('LBL_CUSTOM_INFORMATION', 'FInvoice');

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

                }

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

                    'picklistValues' => ['PLL_PENDING', 'PLL_PENDING_PAYMENT', 'PLL_PENDING_PAYPAL',  'PLL_PAID', 'PLL_PROCESSING', 'PLL_ON_HOLD', 'PLL_SEND', 'PLL_FRAUD', 'PLL_PAYMENT_REVIEW', 'PLL_PAYPAL_CANCELED_REVERSAL', 'PLL_PAYPAL_REVERSED', 'PLL_CANCELLED', 'PLL_CLOSED', 'PLL_COMPLETE']

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

                    $blockModel = current($blocks);

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

        {

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

                    'uitype' => 325,

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

                    'label' => 'FL_MAGENTO_STATUS',

    Line exceeds 120 characters; contains 291 characters
    Open

                    'picklistValues' => ['PLL_PENDING', 'PLL_PENDING_PAYMENT', 'PLL_PENDING_PAYPAL',  'PLL_PAID', 'PLL_PROCESSING', 'PLL_ON_HOLD', 'PLL_SEND', 'PLL_FRAUD', 'PLL_PAYMENT_REVIEW', 'PLL_PAYPAL_CANCELED_REVERSAL', 'PLL_PAYPAL_REVERSED', 'PLL_CANCELLED', 'PLL_CLOSED', 'PLL_COMPLETE']

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

                $this->addFields($fieldsToAdd, $blockModel);

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

            }

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

                $blockModel = vtlib\Block::getInstance('LBL_BASIC_INFORMATION', 'ProductCategory');

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

                $fieldInstance = new Vtiger_Field_Model();

    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

                    'displaytype' => 2,

    Line exceeds 120 characters; contains 177 characters
    Open

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $sSingleOrderTabId, 'fieldname' => array_keys($fields)])->column();

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

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $fInvoiceTabId, 'fieldname' => array_keys($fields)])->column();

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

                if (!$blockModel) {

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

        {

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

                    'label' => 'FL_MAGENTO_SERVER',

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

                    'uitype' => 16,

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

        }

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

                    'maximumlength' => '4294967295',

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

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $sSingleOrderTabId, 'fieldname' => array_keys($fields)])->column();

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

                    $blockModel = current($blocks);

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

                    $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance('FInvoice'));

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

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $productCategoryId, 'fieldname' => array_keys($fields)])->column();

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

                $fieldInstance->set('name', $fieldName);

    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 addFields(array $fieldsToAdd, vtlib\Block $blockModel): void

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

                $fieldInstance->set('maximumlength', $fieldData['maximumlength']);

    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 177 characters
    Open

            $fieldsExists = (new \App\Db\Query())->select(['fieldname'])->from('vtiger_field')->where(['tabid' => $productCategoryId, 'fieldname' => array_keys($fields)])->column();

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

                    $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance('ProductCategory'));

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

                $this->addFields($fieldsToAdd, $blockModel);

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

            header('Location: index.php?parent=Settings&module=Magento&view=List');

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

         * @param array       $fieldsToAdd

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

         */

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

            foreach ($fieldsToAdd as $fieldName => $fieldData) {

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

            $sSingleOrderTabId = \App\Module::getModuleId('SSingleOrders');

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

                    'columntype' => $importerType->stringType(255)->defaultValue(''),

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

                    $blockModel = current($blocks);

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

         * @return void

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

                $fieldInstance->set('uitype', $fieldData['uitype']);

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

                ], 'status_magento' => [

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

                    'maximumlength' => '255',

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

            if ($fieldsToAdd = array_diff_key($fields, array_flip($fieldsExists))) {

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

                $this->addFields($fieldsToAdd, $blockModel);

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

                $fieldInstance->set('table', $blockModel->module->basetable);

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

                $fieldInstance->set('displaytype', $fieldData['displaytype']);

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

            $productCategoryId = \App\Module::getModuleId('ProductCategory');

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

                    'displaytype' => 2,

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

                    'label' => 'FL_MAGENTO_ID',

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

                    'uitype' => 7,

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

                ]

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

                $fieldInstance->save($blockModel);

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

                    $fieldInstance->setNoRolePicklistValues($fieldData['picklistValues']);

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

         * Add fields.

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

         * @param vtlib\Block $blockModel

    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\EventHandler::setActive('IStorages_RecalculateStockHandler_Handler', 'IStoragesAfterUpdateStock');

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

                $fieldInstance->set('columntype', $fieldData['columntype']);

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

                $fieldInstance->set('label', $fieldData['label']);

    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\Cron::updateStatus(\App\Cron::STATUS_ENABLED, 'LBL_MAGENTO');

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

         *

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

                $fieldInstance->set('column', $fieldName);

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

                if (isset($fieldData['picklistValues'])) {

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

                $fieldInstance->set('typeofdata', $fieldData['typeofdata']);

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

    class Settings_Magento_Active_Action extends Settings_Vtiger_Save_Action

    There are no issues that match your filters.

    Category
    Status