YetiForceCompany/YetiForceCRM

View on GitHub
app/Map/Address/YetiForceGeocoder.php

Summary

Maintainability
D
2 days
Test Coverage
F
3%

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

    public function find($value): array
    {
        $product = \App\YetiForce\Register::getProduct('YetiForceGeocoder');
        if (empty($value) || !\App\RequestUtil::isNetConnection() || empty($product['params']['login']) || empty($product['params']['pass'])) {
            return [];
Severity: Major
Found in app/Map/Address/YetiForceGeocoder.php - About 2 hrs to fix

    Function find has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        public function find($value): array
        {
            $product = \App\YetiForce\Register::getProduct('YetiForceGeocoder');
            if (empty($value) || !\App\RequestUtil::isNetConnection() || empty($product['params']['login']) || empty($product['params']['pass'])) {
                return [];
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.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

    The method find() has an NPath complexity of 580. The configured NPath complexity threshold is 200.
    Open

        public function find($value): array
        {
            $product = \App\YetiForce\Register::getProduct('YetiForceGeocoder');
            if (empty($value) || !\App\RequestUtil::isNetConnection() || empty($product['params']['login']) || empty($product['params']['pass'])) {
                return [];
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

    Source https://phpmd.org/rules/codesize.html#npathcomplexity

    The method find() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
    Open

        public function find($value): array
        {
            $product = \App\YetiForce\Register::getProduct('YetiForceGeocoder');
            if (empty($value) || !\App\RequestUtil::isNetConnection() || empty($product['params']['login']) || empty($product['params']['pass'])) {
                return [];
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    CyclomaticComplexity

    Since: 0.1

    Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

    Example

    // Cyclomatic Complexity = 11
    class Foo {
    1   public function example() {
    2       if ($a == $b) {
    3           if ($a1 == $b1) {
                    fiddle();
    4           } elseif ($a2 == $b2) {
                    fiddle();
                } else {
                    fiddle();
                }
    5       } elseif ($c == $d) {
    6           while ($c == $d) {
                    fiddle();
                }
    7        } elseif ($e == $f) {
    8           for ($n = 0; $n < $h; $n++) {
                    fiddle();
                }
            } else {
                switch ($z) {
    9               case 1:
                        fiddle();
                        break;
    10              case 2:
                        fiddle();
                        break;
    11              case 3:
                        fiddle();
                        break;
                    default:
                        fiddle();
                        break;
                }
            }
        }
    }

    Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

    Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.
    Open

        public function find($value): array
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by sonar-php

    Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

    See

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

    class YetiForceGeocoder extends Base
    {
        /** {@inheritdoc} */
        public $docUrl = 'index.php?module=YetiForce&parent=Settings&view=Shop&product=YetiForceGeocoder&mode=showProductModal';
    
    
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

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

                    throw new \App\Exceptions\AppException('Error with connection |' . $response->getReasonPhrase() . '|' . $response->getBody());
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Missing class import via use statement (line '90', column '21').
    Open

                $response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url, $options);
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Avoid using static access to class '\App\YetiForce\Register' in method 'find'.
    Open

            $product = \App\YetiForce\Register::getProduct('YetiForceGeocoder');
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\Config\Components\AddressFinder' in method 'find'.
    Open

                    $mainMapping = \Config\Components\AddressFinder::yetiForceRemapping();
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

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

                \App\Log::error('Error - ' . $ex->getMessage(), __CLASS__);
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\App\Map\Address' in method 'find'.
    Open

    }
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

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

            } else {
                $options['auth'] = [$product['params']['login'], $product['params']['pass']];
            }
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    ElseExpression

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class '\App\RequestUtil' in method 'find'.
    Open

            if (empty($value) || !\App\RequestUtil::isNetConnection() || empty($product['params']['login']) || empty($product['params']['pass'])) {
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\App\Json' in method 'find'.
    Open

                $body = \App\Json::isEmpty($body) ? [] : \App\Json::decode($body);
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\App\YetiForce\Shop' in method 'isActive'.
    Open

            return (bool) ($this->config['active'] ?? 0) && \App\YetiForce\Shop::check('YetiForceGeocoder');
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\App\Language' in method 'find'.
    Open

                'accept-language' => \App\Language::getLanguage() . ',' . \App\Config::main('default_language') . ',en-US',
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\Config\Components\AddressFinder' in method 'find'.
    Open

                    $countryMapping = \Config\Components\AddressFinder::yetiForceRemappingForCountry();
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

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

                \App\Log::beginProfile("GET|YetiForceGeocoder::find|{$url}", __NAMESPACE__);
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\App\YetiForce\Shop' in method 'isConfigured'.
    Open

            return \App\YetiForce\Shop::check('YetiForceGeocoder');
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\App\Config' in method 'find'.
    Open

                'accept-language' => \App\Language::getLanguage() . ',' . \App\Config::main('default_language') . ',en-US',
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\App\YetiForce\Register' in method 'find'.
    Open

                    'InsKey' => \App\YetiForce\Register::getInstanceKey(),
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\App\Json' in method 'find'.
    Open

                $body = \App\Json::isEmpty($body) ? [] : \App\Json::decode($body);
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

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

                \App\Log::endProfile("GET|YetiForceGeocoder::find|{$url}", __NAMESPACE__);
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\App\RequestHttp' in method 'find'.
    Open

                $response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url, $options);
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Define a constant instead of duplicating this literal "params" 6 times.
    Open

            if (empty($value) || !\App\RequestUtil::isNetConnection() || empty($product['params']['login']) || empty($product['params']['pass'])) {
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "YetiForceGeocoder" 3 times.
    Open

            return (bool) ($this->config['active'] ?? 0) && \App\YetiForce\Shop::check('YetiForceGeocoder');
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "country_code" 5 times.
    Open

                        if (isset($row['address']['country_code'], $countryMapping[strtoupper($row['address']['country_code'])])) {
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "address" 23 times.
    Open

                        if (isset($row['address']['country_code'], $countryMapping[strtoupper($row['address']['country_code'])])) {
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "country_codes" 3 times.
    Open

            'country_codes' => [
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Avoid unused private methods such as 'parseRow'.
    Open

        private function parseRow(array $row): array
        {
            return [
                'addresslevel1' => [$row['address']['country'] ?? '', strtoupper($row['address']['country_code'] ?? '')],
                'addresslevel2' => $row['address']['state'] ?? '',
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phpmd

    UnusedPrivateMethod

    Since: 0.2

    Unused Private Method detects when a private method is declared but is unused.

    Example

    class Something
    {
        private function foo() {} // unused
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

    Reference to undeclared property \App\Map\Address\YetiForceGeocoder->config
    Open

                $params['countrycodes'] = $this->config['country_codes'];
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phan

    Call to method request from undeclared class \GuzzleHttp\Client
    Open

                $response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url, $options);
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by phan

    Call to method yetiForceRemappingForCountry from undeclared class \Config\Components\AddressFinder
    Open

                    $countryMapping = \Config\Components\AddressFinder::yetiForceRemappingForCountry();
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by phan

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

                \App\Log::error('Error - ' . $ex->getMessage(), __CLASS__);
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by phan

    Call to method getProduct from undeclared class \App\YetiForce\Register
    Open

            $product = \App\YetiForce\Register::getProduct('YetiForceGeocoder');
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by phan

    Call to method getInstanceKey from undeclared class \App\YetiForce\Register
    Open

                    'InsKey' => \App\YetiForce\Register::getInstanceKey(),
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by phan

    Reference to undeclared property \App\Map\Address\YetiForceGeocoder->config
    Open

            return (bool) ($this->config['active'] ?? 0) && \App\YetiForce\Shop::check('YetiForceGeocoder');
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phan

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

                \App\Log::beginProfile("GET|YetiForceGeocoder::find|{$url}", __NAMESPACE__);
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by phan

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

            return (bool) ($this->config['active'] ?? 0) && \App\YetiForce\Shop::check('YetiForceGeocoder');
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by phan

    Call to method yetiForceRemapping from undeclared class \Config\Components\AddressFinder
    Open

                    $mainMapping = \Config\Components\AddressFinder::yetiForceRemapping();
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by phan

    Reference to undeclared property \App\Map\Address\YetiForceGeocoder->config
    Open

            if (!empty($this->config['country_codes'])) {
    Severity: Minor
    Found in app/Map/Address/YetiForceGeocoder.php by phan

    Class extends undeclared class \App\Map\Address\Base (Did you mean class \App\Base or class \App\Cache\Base or class \App\Cli\Base or class \App\Controller\Base or class \App\Controller\View\Base or class \App\Db\Importers\Base or class \Tests\Base)
    Open

    class YetiForceGeocoder extends Base
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by phan

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

            return \App\YetiForce\Shop::check('YetiForceGeocoder');
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by phan

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

                \App\Log::endProfile("GET|YetiForceGeocoder::find|{$url}", __NAMESPACE__);
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by phan

    Call to method __construct from undeclared class \GuzzleHttp\Client
    Open

                $response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url, $options);
    Severity: Critical
    Found in app/Map/Address/YetiForceGeocoder.php by phan

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

        private function parseRow(array $row): array
        {
            return [
                'addresslevel1' => [$row['address']['country'] ?? '', strtoupper($row['address']['country_code'] ?? '')],
                'addresslevel2' => $row['address']['state'] ?? '',
    Severity: Major
    Found in app/Map/Address/YetiForceGeocoder.php and 1 other location - About 1 day to fix
    app/Map/Address/NominatimGeocoder.php on lines 119..134

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

    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 ($body) {
                    $mainMapping = \Config\Components\AddressFinder::yetiForceRemapping();
                    if (!\is_callable($mainMapping)) {
                        $mainMapping = [$this, 'parseRow'];
                    }
    Severity: Major
    Found in app/Map/Address/YetiForceGeocoder.php and 1 other location - About 6 hrs to fix
    app/Map/Address/NominatimGeocoder.php on lines 87..105

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

    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

    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

            if (empty($value) || !\App\RequestUtil::isNetConnection() || empty($product['params']['login']) || empty($product['params']['pass'])) {

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

                'addressdetails' => 1,

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

                \App\Log::beginProfile("GET|YetiForceGeocoder::find|{$url}", __NAMESPACE__);

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

                        }

    Line exceeds 120 characters; contains 182 characters
    Open

     * The file is part of the paid functionality. Using the file is allowed only after purchasing a subscription. File modification allowed only with the consent of the system producer.

    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 \App\YetiForce\Shop::check('YetiForceGeocoder');

    Line exceeds 120 characters; contains 143 characters
    Open

            if (empty($value) || !\App\RequestUtil::isNetConnection() || empty($product['params']['login']) || empty($product['params']['pass'])) {

    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

                'q' => $value,

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

                $params['countrycodes'] = $this->config['country_codes'];

    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 ($body) {

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

        /**

    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

                'accept-language' => \App\Language::getLanguage() . ',' . \App\Config::main('default_language') . ',en-US',

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

                $response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url, $options);

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

                    if (!\is_callable($mainMapping)) {

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

                    }

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

                    $countryMapping = \Config\Components\AddressFinder::yetiForceRemappingForCountry();

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

                            'coordinates' => ['lat' => $row['lat'], 'lon' => $row['lon']],

    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

            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

        /** {@inheritdoc} */

    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

        public $docUrl = 'index.php?module=YetiForce&parent=Settings&view=Shop&product=YetiForceGeocoder&mode=showProductModal';

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

            $product = \App\YetiForce\Register::getProduct('YetiForceGeocoder');

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

                    'InsKey' => \App\YetiForce\Register::getInstanceKey(),

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

                $options['auth'] = [$product['params']['login'], $product['params']['pass']];

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

                            'address' => \call_user_func_array($mappingFunction, [$row]),

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

                \App\Log::error('Error - ' . $ex->getMessage(), __CLASS__);

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

         * Main function to parse information about address.

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

         *

    Line exceeds 120 characters; contains 124 characters
    Open

        public $docUrl = 'index.php?module=YetiForce&parent=Settings&view=Shop&product=YetiForceGeocoder&mode=showProductModal';

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

                'label' => 'LBL_COUNTRY_CODES',

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

                    'title' => 'LBL_COUNTRY_CODES_INFO',

    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 (isset($product['params']['token'])) {

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

                $params['yf_token'] = $product['params']['token'];

    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

                $body = \App\Json::isEmpty($body) ? [] : \App\Json::decode($body);

    Line exceeds 120 characters; contains 127 characters
    Open

                        if (isset($row['address']['country_code'], $countryMapping[strtoupper($row['address']['country_code'])])) {

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

            } catch (\Throwable $ex) {

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

            return $rows;

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

        public $customFields = [

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

                \App\Log::endProfile("GET|YetiForceGeocoder::find|{$url}", __NAMESPACE__);

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

                    throw new \App\Exceptions\AppException('Error with connection |' . $response->getReasonPhrase() . '|' . $response->getBody());

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

                        $mainMapping = [$this, 'parseRow'];

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

                    foreach ($body as $row) {

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

                        if (isset($row['address']['country_code'], $countryMapping[strtoupper($row['address']['country_code'])])) {

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

                        $rows[] = [

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

        }

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

                'link' => [

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

        {

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

                'format' => 'json',

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

            ];

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

            $options = [

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

                if (200 !== $response->getStatusCode()) {

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

                        $mappingFunction = $mainMapping;

    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

            }

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

            if (!empty($this->config['country_codes'])) {

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

                'version' => 2.0,

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

                    throw new \App\Exceptions\AppException('Error with connection |' . $response->getReasonPhrase() . '|' . $response->getBody());

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

                            $mappingFunction = $countryMapping[strtoupper($row['address']['country_code'])];

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

                            'label' => $row['display_name'],

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

                            'countryCode' => $row['address']['country_code'] ?? '',

    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

        ];

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

        }

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

            $params = [

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

                'headers' => [

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

                    'url' => 'https://wikipedia.org/wiki/List_of_ISO_3166_country_codes',

    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

            try {

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

                    $mainMapping = \Config\Components\AddressFinder::yetiForceRemapping();

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

                    }

    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

            return (bool) ($this->config['active'] ?? 0) && \App\YetiForce\Shop::check('YetiForceGeocoder');

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

        public function isConfigured()

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

                'limit' => \App\Map\Address::getConfig()['global']['result_num'],

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

                        ];

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

                'tooltip' => 'LBL_COUNTRY_CODES_PLACEHOLDER',

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

        public function isActive()

    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

            'country_codes' => [

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

                'uitype' => 1,

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

                'maximumlength' => '100',

    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 find($value): 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

                'timeout' => 30,

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

            $rows = [];

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

                $body = $response->getBody();

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

                'purifyType' => \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

                $url = 'https://osm-search.yetiforce.eu/?' . http_build_query($params);

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

        private function parseRow(array $row): array

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

                'localnumber' => $row['address']['local_number'] ?? '',

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

                'addresslevel6' => $row['address']['hamlet'] ?? $row['address']['suburb'] ?? $row['address']['neighbourhood'] ?? $row['address']['city_district'] ?? '',

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

                'addresslevel2' => $row['address']['state'] ?? '',

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

                'addresslevel4' => $row['address']['municipality'] ?? '',

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

                'company_name_' => $row['address']['office'] ?? '',

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

            ];

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

                'addresslevel3' => $row['address']['county'] ?? $row['address']['state_district'] ?? '',

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

                'addresslevel1' => [$row['address']['country'] ?? '', strtoupper($row['address']['country_code'] ?? '')],

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

                'addresslevel5' => $row['address']['city'] ?? $row['address']['town'] ?? $row['address']['village'] ?? '',

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

        }

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

                'addresslevel8' => $row['address']['road'] ?? '',

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

                'buildingnumber' => $row['address']['house_number'] ?? '',

    Line exceeds 120 characters; contains 164 characters
    Open

                'addresslevel6' => $row['address']['hamlet'] ?? $row['address']['suburb'] ?? $row['address']['neighbourhood'] ?? $row['address']['city_district'] ?? '',

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

                'addresslevel7' => $row['address']['postcode'] ?? '',

    There are no issues that match your filters.

    Category
    Status