YetiForceCompany/YetiForceCRM

View on GitHub
modules/Products/models/Stocktaking.php

Summary

Maintainability
B
6 hrs
Test Coverage
F
0%

Method compare has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function compare(App\Request $request): array
    {
        $this->parseCsv->heading = false;
        $this->parseCsv->auto($this->path);
        $this->storage = $request->getInteger('storage');
Severity: Minor
Found in modules/Products/models/Stocktaking.php - About 1 hr to fix

    Function compare has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function compare(App\Request $request): array
        {
            $this->parseCsv->heading = false;
            $this->parseCsv->auto($this->path);
            $this->storage = $request->getInteger('storage');
    Severity: Minor
    Found in modules/Products/models/Stocktaking.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

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

        public function updateStockInStorage(string $name): array
        {
            $igin = $iidn = [];
            foreach ($this->toUpdate as $crmId => $product) {
                if ($product['difference'] > 0) {
    Severity: Minor
    Found in modules/Products/models/Stocktaking.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

    The class Products_Stocktaking_Model has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13.
    Open

    class Products_Stocktaking_Model
    {
        /**
         * CSV file path.
         *

    CouplingBetweenObjects

    Since: 1.1.0

    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

    Example

    class Foo {
        /**
         * @var \foo\bar\X
         */
        private $x = null;
    
        /**
         * @var \foo\bar\Y
         */
        private $y = null;
    
        /**
         * @var \foo\bar\Z
         */
        private $z = null;
    
        public function setFoo(\Foo $foo) {}
        public function setBar(\Bar $bar) {}
        public function setBaz(\Baz $baz) {}
    
        /**
         * @return \SplObjectStorage
         * @throws \OutOfRangeException
         * @throws \InvalidArgumentException
         * @throws \ErrorException
         */
        public function process(\Iterator $it) {}
    
        // ...
    }

    Source https://phpmd.org/rules/design.html#couplingbetweenobjects

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

            return (new \App\Db\Query())->select(['u_#__istorages.istorageid', 'u_#__istorages.subject'])

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

                throw new \App\Exceptions\NoPermitted('LBL_RECORD_NOT_FOUND', 406);

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

                $queryGenerator = new \App\QueryGenerator('Products');

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

            $self->parseCsv = new \ParseCsv\Csv();

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

                $products = (new \App\Db\Query())->select([

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

                    throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);

    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\Encryption' in method 'analyzeFile'.
    Open

            $randomKey = 'filePath' . App\Encryption::generatePassword(5);

    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 compare uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                    } else {
                        ++$same;
                    }

    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\Json' in method 'compare'.
    Open

                \App\Json::save(\App\Fields\File::getTmpPath() . 'json' . $this->importKey, $toUpdate);

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

        public function compare(App\Request $request): array
        {
            $this->parseCsv->heading = false;
            $this->parseCsv->auto($this->path);
            $this->storage = $request->getInteger('storage');

    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 'Vtiger_Inventory_Action' in method 'buildInventoryData'.
    Open

    }

    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\Config' in method 'load'.
    Open

            if ($fileEncoding !== \App\Config::main('default_charset', 'UTF-8')) {

    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\Config' in method 'load'.
    Open

                $self->parseCsv->encoding($fileEncoding, \App\Config::main('default_charset', 'UTF-8'));

    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 compare uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                unlink($this->path);
            }

    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\Fields\File' in method 'analyzeFile'.
    Open

            $target = App\Fields\File::getTmpPath() . $randomKey;

    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 compare uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    $notFound[] = $ean;
                }

    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

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

            } else {
                $referenceInfo = \Vtiger_Relation_Model::getReferenceTableInfo('Products', 'IStorages');
                $products = (new \App\Db\Query())->select([
                    'ean' => 'vtiger_products.ean',
                    'id' => $referenceInfo['table'] . '.' . $referenceInfo['rel'],

    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\Session' in method 'loadByKey'.
    Open

            $path = \App\Session::get($importKey);

    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\Session' in method 'analyzeFile'.
    Open

            \App\Session::set($randomKey, $target);

    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\Fields\File' in method 'compare'.
    Open

                \App\Json::save(\App\Fields\File::getTmpPath() . 'json' . $this->importKey, $toUpdate);

    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 updateStockInStorage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    $product['difference'] = -$product['difference'];
                    $iidn[$crmId] = $product;
                }

    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\Json' in method 'import'.
    Open

            $this->toUpdate = \App\Json::read(\App\Fields\File::getTmpPath() . 'json' . $this->importKey);

    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 'updateStockInStorage'.
    Open

                $recordModel = Vtiger_Record_Model::getCleanInstance('IGIN');

    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 'updateStockInStorage'.
    Open

                $recordModel = Vtiger_Record_Model::getCleanInstance('IIDN');

    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 import uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $return = $this->updateStockInStorage($request->getByType('recordName', \App\Purifier::TEXT));
            }

    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\Fields\File' in method 'import'.
    Open

            $this->toUpdate = \App\Json::read(\App\Fields\File::getTmpPath() . 'json' . $this->importKey);

    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 'updateStockInProduct'.
    Open

                $recordModel = Vtiger_Record_Model::getInstanceById($crmId, 'Products');

    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_Relation_Model' in method 'getProducts'.
    Open

                $referenceInfo = \Vtiger_Relation_Model::getReferenceTableInfo('Products', 'IStorages');

    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\Fields\File' in method 'import'.
    Open

            unlink(\App\Fields\File::getTmpPath() . 'json' . $this->importKey);

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

                    $crmStock = (float) $product['qtyinstock'];

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

                    'price' => $productDetails['price'],

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

                    'id' => $referenceInfo['table'] . '.' . $referenceInfo['rel'],

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

            $fileEncoding = \strtoupper(mb_detect_encoding(file_get_contents($filePath), ['UTF-8', 'ISO-8859-1'], true));

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

                            'difference' => $crmStock - $fileStock,

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

                $queryGenerator = new \App\QueryGenerator('Products');

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

                            'fileStock' => $fileStock,

    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.

    Property \Products_Stocktaking_Model->parseCsv has undeclared type \ParseCsv\Csv
    Open

        private $parseCsv;

    Reference to undeclared property \Products_Stocktaking_Model->toUpdate
    Open

            $this->toUpdate = \App\Json::read(\App\Fields\File::getTmpPath() . 'json' . $this->importKey);

    Call to method generatePassword from undeclared class \App\Encryption (Did you mean class \Tests\App\Encryption)
    Open

            $randomKey = 'filePath' . App\Encryption::generatePassword(5);
    Severity: Critical
    Found in modules/Products/models/Stocktaking.php by phan

    Reference to instance property data from undeclared class \ParseCsv\Csv
    Open

                'count' => \count($this->parseCsv->data),

    Call to method __construct from undeclared class \ParseCsv\Csv
    Open

            $self->parseCsv = new \ParseCsv\Csv();
    Severity: Critical
    Found in modules/Products/models/Stocktaking.php by phan

    Call to method encoding from undeclared class \ParseCsv\Csv
    Open

                $self->parseCsv->encoding($fileEncoding, \App\Config::main('default_charset', 'UTF-8'));
    Severity: Critical
    Found in modules/Products/models/Stocktaking.php by phan

    Reference to undeclared class \ParseCsv\Csv
    Open

            $headers = array_shift($this->parseCsv->data);

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

                $products = $queryGenerator->createQuery()->createCommand()->queryAllByGroup(1);
    Severity: Critical
    Found in modules/Products/models/Stocktaking.php by phan

    Reference to instance property titles from undeclared class \ParseCsv\Csv
    Open

                'column' => $this->parseCsv->titles,

    Reference to instance property data from undeclared class \ParseCsv\Csv
    Open

            foreach ($this->parseCsv->data as $row) {

    Reference to instance property heading from undeclared class \ParseCsv\Csv
    Open

            $this->parseCsv->heading = false;

    Call to method auto from undeclared class \ParseCsv\Csv
    Open

            $this->parseCsv->auto($this->path);
    Severity: Critical
    Found in modules/Products/models/Stocktaking.php by phan

    Reference to undeclared property \Products_Stocktaking_Model->toUpdate
    Open

            foreach ($this->toUpdate as $crmId => $product) {

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

            return (new \App\Db\Query())->select(['u_#__istorages.istorageid', 'u_#__istorages.subject'])
    Severity: Critical
    Found in modules/Products/models/Stocktaking.php by phan

    Reference to instance property input_encoding from undeclared class \ParseCsv\Csv
    Open

                'encoding' => $this->parseCsv->input_encoding,

    Reference to undeclared property \Products_Stocktaking_Model->toUpdate
    Open

            foreach ($this->toUpdate as $crmId => $product) {

    Call to method auto from undeclared class \ParseCsv\Csv
    Open

            $this->parseCsv->auto($this->path);
    Severity: Critical
    Found in modules/Products/models/Stocktaking.php by phan

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

                $queryGenerator->setFields(['ean', 'id', 'qtyinstock']);
    Severity: Critical
    Found in modules/Products/models/Stocktaking.php by phan

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

                $queryGenerator = new \App\QueryGenerator('Products');
    Severity: Critical
    Found in modules/Products/models/Stocktaking.php by phan

    Reference to instance property use_mb_convert_encoding from undeclared class \ParseCsv\Csv
    Open

            $self->parseCsv->use_mb_convert_encoding = true;

    Reference to instance property data from undeclared class \ParseCsv\Csv
    Open

            $headers = array_shift($this->parseCsv->data);

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

                $products = (new \App\Db\Query())->select([
    Severity: Critical
    Found in modules/Products/models/Stocktaking.php by phan

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

            if ($iidn) {
                $recordModel = Vtiger_Record_Model::getCleanInstance('IIDN');
                $recordModel->set('subject', $name)->set('storageid', $this->storage)->set('iidn_status', 'PLL_IN_REALIZATION')->set('acceptance_date', date('Y-m-d'));
                $recordModel->initInventoryData($this->buildInventoryData($iidn, 'IIDN'), false);
                $recordModel->save();
    Severity: Major
    Found in modules/Products/models/Stocktaking.php and 1 other location - About 1 hr to fix
    modules/Products/models/Stocktaking.php on lines 265..271

    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 111.

    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 2 locations. Consider refactoring.
    Open

            if ($igin) {
                $recordModel = Vtiger_Record_Model::getCleanInstance('IGIN');
                $recordModel->set('subject', $name)->set('storageid', $this->storage)->set('igin_status', 'PLL_IN_REALIZATION')->set('acceptance_date', date('Y-m-d'));
                $recordModel->initInventoryData($this->buildInventoryData($igin, 'IGIN'), false);
                $recordModel->save();
    Severity: Major
    Found in modules/Products/models/Stocktaking.php and 1 other location - About 1 hr to fix
    modules/Products/models/Stocktaking.php on lines 272..278

    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 111.

    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 Products_Stocktaking_Model

    The class Products_Stocktaking_Model is not named in CamelCase.
    Open

    class Products_Stocktaking_Model
    {
        /**
         * CSV file path.
         *

    CamelCaseClassName

    Since: 0.2

    It is considered best practice to use the CamelCase notation to name classes.

    Example

    class class_name {
    }

    Source

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

            $i = 0;

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

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

         * @var string

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

         *

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

            return (new \App\Db\Query())->select(['u_#__istorages.istorageid', 'u_#__istorages.subject'])

    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

            $self->parseCsv->use_mb_convert_encoding = true;

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

        private $parseCsv;

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

        /**

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

         *

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

        /**

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

         * Load CSV file by request.

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

         * @return self

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

            $fileEncoding = \strtoupper(mb_detect_encoding(file_get_contents($filePath), ['UTF-8', 'ISO-8859-1'], true));

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

            return $self;

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

                $self->parseCsv->encoding($fileEncoding, \App\Config::main('default_charset', 'UTF-8'));

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

        /**

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

        /**

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

        /**

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

         * @var int

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

        private $importKey;

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

         */

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

        {

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

         *

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

            $self = new self();

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

         * EAN/SKU column seq.

    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

                ->where(['vtiger_crmentity.deleted' => 0, 'u_#__istorages.storage_status' => 'PLL_ACTIVE'])

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

            $self->path = $filePath;

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

        private $path;

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

         * Storage id.

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

        private $eanColumnSeq;

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

         * Qty column seq.

    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 \ParseCsv\Csv

    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

         * Load CSV file by session key.

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

         * Import temp key.

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

        /**

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

         *

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

         */

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

        /**

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

         */

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

                ->from('u_#__istorages')

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

         *

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

                ->innerJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = u_#__istorages.istorageid')

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

            $self->parseCsv = new \ParseCsv\Csv();

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

         * @var int

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

        private $qtyColumnSeq;

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

         * Get active storages.

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

                ->createCommand()->queryAllByGroup(0);

    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 static function load(string $filePath): self

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

        {

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

            if ($fileEncoding !== \App\Config::main('default_charset', 'UTF-8')) {

    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 static function getStorage(): array

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

         * CSV file path.

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

         * Parse CSV instance.

    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

        private $storage;

    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 int

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

         */

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

         * @var string

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

         * @param string $filePath

    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

            $update = $same = 0;

    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

         *

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

         *

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

         * Update stock (qtyinstock) in product.

    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

            if ($igin) {

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

            foreach ($row['data'] as $key => $value) {

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

            }

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

                if ($product = ($products[$ean] ?? null)) {

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

                        ];

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

            if ($toUpdate) {

    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

                    ->innerJoin('vtiger_crmentity', 'vtiger_products.productid = vtiger_crmentity.crmid')

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

         *

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

                    $product['difference'] = -$product['difference'];

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

        private function buildInventoryData(array $rows, string $moduleName): array

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

         *

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

         * @param string $importKey

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

            $self->importKey = $importKey;

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

            $this->parseCsv->auto($this->path);

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

            ];

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

         */

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

            }

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

                'notFound' => implode(', ', $notFound),

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

                $products = (new \App\Db\Query())->select([

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

         * @param App\Request $request

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

                $return = $this->updateStockInProduct();

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

         * @return array

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

            $igin = $iidn = [];

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

                $recordModel->initInventoryData($this->buildInventoryData($igin, 'IGIN'), false);

    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

        public function analyzeFile(): array

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

            $target = App\Fields\File::getTmpPath() . $randomKey;

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

            move_uploaded_file($this->path, $target);

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

            \App\Session::set($randomKey, $target);

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

            $this->storage = $request->getInteger('storage');

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

                    $notFound[] = $ean;

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

         * @return array

    Line exceeds 120 characters; contains 130 characters
    Open

                    ->where(['vtiger_crmentity.deleted' => 0, "{$referenceInfo['table']}.{$referenceInfo['base']}" => $this->storage])

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

            if (0 === $this->storage) {

    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 updateStockInProduct(): array

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

                $recordModel = Vtiger_Record_Model::getCleanInstance('IGIN');

    Line exceeds 120 characters; contains 163 characters
    Open

                $recordModel->set('subject', $name)->set('storageid', $this->storage)->set('igin_status', 'PLL_IN_REALIZATION')->set('acceptance_date', date('Y-m-d'));

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

                $recordModel->save();

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

                $recordModel = Vtiger_Record_Model::getCleanInstance('IIDN');

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

         * Build inventory items data.

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

            $itemsSeq = 0;

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

            foreach ($rows as $crmId => $product) {

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

                    'total' => $productDetails['price'] * $product['difference'],

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

        private function buildComment(array $row): string

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

                throw new \App\Exceptions\NoPermitted('LBL_RECORD_NOT_FOUND', 406);

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

        {

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

                    $crmStock = (float) $product['qtyinstock'];

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

                            'data' => array_combine($headers, $row),

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

                'counterNotFound' => \count($notFound),

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

                'update' => $update,

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

        {

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

         * Update stock in storage (IGIN,IIDN).

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

         * @param array  $rows

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

                $productDetails = Vtiger_Inventory_Action::getRecordDetail($crmId, null, $moduleName, 'name')[$crmId];

    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 compare(App\Request $request): array

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

        {

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

        {

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

                    ->where(['vtiger_crmentity.deleted' => 0, "{$referenceInfo['table']}.{$referenceInfo['base']}" => $this->storage])

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

         *

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

         * Get file columns.

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

                if (!$recordModel->isViewable()) {

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

         * Get file columns.

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

                    throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);

    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->parseCsv->heading = false;

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

            if ($iidn) {

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

            $this->eanColumnSeq = $request->getInteger('skuColumnSeq');

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

        }

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

                    $fileStock = (float) $row[$this->qtyColumnSeq];

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

            return $comment;

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

                        ++$same;

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

        /**

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

            } else {

    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 = $this->updateStockInStorage($request->getByType('recordName', \App\Purifier::TEXT));

    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

                array_merge($productDetails['autoFields'], [

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

         * @return self

    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 array

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

                            'ean' => $ean,

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

                            'crmStock' => $crmStock,

    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\Json::save(\App\Fields\File::getTmpPath() . 'json' . $this->importKey, $toUpdate);

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

         */

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

        private function getProducts(): array

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

                $queryGenerator = new \App\QueryGenerator('Products');

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

                $products = $queryGenerator->createQuery()->createCommand()->queryAllByGroup(1);

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

                    'ean' => 'vtiger_products.ean',

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

         */

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

            unlink($this->path);

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

            } else {

    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

                    $iidn[$crmId] = $product;

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

            }

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

            $items = [];

    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

         * @return array

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

                'randomKey' => $randomKey,

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

                $ean = $row[$this->eanColumnSeq];

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

                'toUpdate' => $toUpdate,

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

            $i = 0;

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

                $recordModel->save();

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

         *

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

                }

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

                $recordModel->set('subject', $name)->set('storageid', $this->storage)->set('igin_status', 'PLL_IN_REALIZATION')->set('acceptance_date', date('Y-m-d'));

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

                $recordModel->initInventoryData($this->buildInventoryData($iidn, 'IIDN'), false);

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

                $recordModel->save();

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

         *

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

            return $items;

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

        public static function loadByKey(string $importKey): self

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

         */

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

                            'fileStock' => $fileStock,

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

                'same' => $same,

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

        public function updateStockInStorage(string $name): array

    Line exceeds 120 characters; contains 163 characters
    Open

                $recordModel->set('subject', $name)->set('storageid', $this->storage)->set('iidn_status', 'PLL_IN_REALIZATION')->set('acceptance_date', date('Y-m-d'));

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

                    'qty' => $product['difference'],

    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

            $path = \App\Session::get($importKey);

    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 [

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

         * @param App\Request $request

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

            $this->parseCsv->auto($this->path);

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

            $this->qtyColumnSeq = $request->getInteger('qtyColumnSeq');

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

                            'difference' => $crmStock - $fileStock,

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

            } else {

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

                    ->innerJoin('vtiger_products', "{$referenceInfo['table']}.{$referenceInfo['rel']} = vtiger_products.productid")

    Line exceeds 120 characters; contains 127 characters
    Open

                    ->innerJoin('vtiger_products', "{$referenceInfo['table']}.{$referenceInfo['rel']} = vtiger_products.productid")

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

         * Import of stock adjustments.

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

            $this->toUpdate = \App\Json::read(\App\Fields\File::getTmpPath() . 'json' . $this->importKey);

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

        }

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

                $recordModel->set('qtyinstock', $product['fileStock']);

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

                if ($product['difference'] > 0) {

    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

         * @return array

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

                $items[$itemsSeq] =

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

         *

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

            $self = self::load($path);

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

         *

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

            $headers = array_shift($this->parseCsv->data);

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

            foreach ($this->parseCsv->data as $row) {

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

                    if ($crmStock !== $fileStock) {

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

        }

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

                $referenceInfo = \Vtiger_Relation_Model::getReferenceTableInfo('Products', 'IStorages');

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

                    'qtyinstock' => $referenceInfo['table'] . '.qtyinstock',

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

        }

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

            unlink(\App\Fields\File::getTmpPath() . 'json' . $this->importKey);

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

            return ['product' => $i];

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

         * @param string $name

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

         * @return int[]

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

                    $igin[$crmId] = $product;

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

                    'price' => $productDetails['price'],

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

                    'comment1' => $this->buildComment($product)

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

        /**

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

         * Build comment.

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

         *

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

         *

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

         *

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

                'encoding' => $this->parseCsv->input_encoding,

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

                'column' => $this->parseCsv->titles,

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

        }

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

                        $toUpdate[$product['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

        public function import(App\Request $request): array

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

         */

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

                $recordModel = Vtiger_Record_Model::getInstanceById($crmId, 'Products');

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

                ++$i;

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

                } else {

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

                $return['igin'] = $recordModel->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

                    'ean' => $product['ean'],

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

                ]);

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

         * @param array $row

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

                $comment .= "$key: $value<br/>\n";

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

            if (!file_exists($path)) {

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

            $randomKey = 'filePath' . App\Encryption::generatePassword(5);

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

                'count' => \count($this->parseCsv->data),

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

         *

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

            $products = $this->getProducts();

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

                        ++$update;

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

                    } else {

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

                    }

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

                ])->from($referenceInfo['table'])

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

            return $products;

    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 ($this->toUpdate as $crmId => $product) {

    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['iidn'] = $recordModel->getId();

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

                ++$itemsSeq;

    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 $self;

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

        /**

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

            $toUpdate = $notFound = [];

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

                } else {

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

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

    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

                $recordModel->set('subject', $name)->set('storageid', $this->storage)->set('iidn_status', 'PLL_IN_REALIZATION')->set('acceptance_date', date('Y-m-d'));

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

         * @param string $moduleName

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

                unlink($this->path);

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

         * Get all products stock.

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

            if (0 === $this->storage) {

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

                    'id' => $referenceInfo['table'] . '.' . $referenceInfo['rel'],

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

                    ->createCommand()->queryAllByGroup(1);

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

         * @return array

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

            $this->storage = $request->getInteger('storage');

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

            return $return;

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

            foreach ($this->toUpdate as $crmId => $product) {

    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 $return;

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

                    'name' => $crmId,

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

            $comment = "{$row['crmStock']} >> {$row['fileStock']}<br/>\n";

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

        }

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

    class Products_Stocktaking_Model

    There are no issues that match your filters.

    Category
    Status