YetiForceCompany/YetiForceCRM

View on GitHub
tests/App/Validator.php

Summary

Maintainability
A
1 hr
Test Coverage
A
100%

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

    public function dataValidator(): array
    {
        return [
            ['url', true, 'ssl://imap.gmail.com:993'],
            ['url', true, 'ssl://imap.gmail.com'],
Severity: Minor
Found in tests/App/Validator.php - About 1 hr to fix

    Avoid using static access to class '\App\Validator' in method 'testValidator'.
    Open

            $this->assertSame($expected, \App\Validator::{$fn}($value));
    Severity: Minor
    Found in tests/App/Validator.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\Validator' in method 'testFloatIsEqual'.
    Open

            $this->assertSame($result, \App\Validator::floatIsEqual($value1, $value2, $precision), 'Expected ' . $result);
    Severity: Minor
    Found in tests/App/Validator.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 "urlDomain" 22 times.
    Open

                ['urlDomain', true, 'ssl://imap.gmail.com:993'],
    Severity: Critical
    Found in tests/App/Validator.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.

    Call to undeclared method \Tests\App\Validator::assertSame
    Open

            $this->assertSame($expected, \App\Validator::{$fn}($value));
    Severity: Critical
    Found in tests/App/Validator.php by phan

    Call to undeclared method \Tests\App\Validator::assertSame
    Open

            $this->assertSame($result, \App\Validator::floatIsEqual($value1, $value2, $precision), 'Expected ' . $result);
    Severity: Critical
    Found in tests/App/Validator.php by phan

    Call to method floatIsEqual from undeclared class \App\Validator (Did you mean class \Tests\App\Validator)
    Open

            $this->assertSame($result, \App\Validator::floatIsEqual($value1, $value2, $precision), 'Expected ' . $result);
    Severity: Critical
    Found in tests/App/Validator.php by phan

    Suspicious type bool of a variable or expression used to build a string. (Expected type to be able to cast to a string)
    Open

            $this->assertSame($result, \App\Validator::floatIsEqual($value1, $value2, $precision), 'Expected ' . $result);
    Severity: Minor
    Found in tests/App/Validator.php by phan

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

        public function testValidator(string $fn, bool $expected, $value)
    Severity: Minor
    Found in tests/App/Validator.php by phpmd

    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

        /**
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         */
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

            $this->assertSame($expected, \App\Validator::{$fn}($value));
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        }
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * Data provider for testValidator function.
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', true, 'google.pl'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', false, 'https://yetiforce*com/pl/'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * Provide test data for testFloatIsEqual function.
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

            ];
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        public function testFloatIsEqual(float $value1, float $value2, int $precision, bool $result)
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         */
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        public function testValidator(string $fn, bool $expected, $value)
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * @return array
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

            return [
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', false, 'https://1243yfcom%.pl'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         */
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        }
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', true, 'http://элтранс.рф'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        {
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * @param float $value1
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', false, 'https://yeti force.com/pl/'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', false, 'http*://yetiforce.com'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * @dataProvider floatIsEqualProvider
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        {
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['url', true, 'tls://imap.gmail.com'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', false, 'http://a-.bc.com'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', false, 'test@com.pl'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', true, 'http://yetiforce.com:2160/'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * @return array
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        public function floatIsEqualProvider()
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                [0.314111, 0.3199, 3, false],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         *
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * @return void
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', true, 'ssl://imap.gmail.com'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', false, '.'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         *
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * @param float $value2
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        }
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        /**
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * @dataProvider dataValidator
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * @param bool   $expected
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * @param string $value
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         *
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        public function dataValidator(): array
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['url', true, 'ssl://imap.gmail.com'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['url', true, 'imap.gmail.com:993'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', true, 'http://www.müller.de'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                [0.314001, 0.314, 6, false],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', true, 'http://google.pl'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

            return [
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        /**
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         *
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         */
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', true, 'tls://imap.gmail.com'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         *
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        /**
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', true, 'imap.gmail.com'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', false, '#'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', true, 'mailto://info@yetiforce.com'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        }
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                [0.314000, 0.314, 6, true],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

            $this->assertSame($result, \App\Validator::floatIsEqual($value1, $value2, $precision), 'Expected ' . $result);
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * @param string $fn
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', true, 'tel://600500100'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

            ];
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         *
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                [0.314001, 0.314, 5, true],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * @param bool  $result
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        {
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['url', true, 'imap.gmail.com'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', true, 'ftp://yetiforce.com'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['url', true, 'ssl://imap.gmail.com:993'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', true, 'ssl://imap.gmail.com:993'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', false, ' http://yetiforce.com/'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                [3.5768, 3.58, 3, false],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

                ['urlDomain', false, 'javascript:alert(1)'],
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * Testing process function.
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

         * @param int   $precision
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

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

        {
    Severity: Minor
    Found in tests/App/Validator.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status