YetiForceCompany/YetiForceCRM

View on GitHub
tests/App/Configurator.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Missing class import via use statement (line '35', column '25').
Open

        self::$instance = new \App\ConfigFile('component', 'YetiForce');
Severity: Minor
Found in tests/App/Configurator.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\Config' in method 'testSave'.
Open

        $this->assertNotSame($previousValue, \App\Config::component('YetiForce', $flagName, false));
Severity: Minor
Found in tests/App/Configurator.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 'testSave'.
Open

        $previousValue = \App\Config::component('YetiForce', $flagName, false);
Severity: Minor
Found in tests/App/Configurator.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 "YetiForce" 3 times.
Open

        self::$instance = new \App\ConfigFile('component', 'YetiForce');
Severity: Critical
Found in tests/App/Configurator.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.

Assigning false to property but \Tests\App\Configurator::$instance is \App\ConfigFile
Open

    public static $instance = false;
Severity: Minor
Found in tests/App/Configurator.php by phan

Call to undeclared method \Tests\App\Configurator::assertInstanceOf
Open

        $this->assertInstanceOf('\App\ConfigFile', self::$instance);
Severity: Critical
Found in tests/App/Configurator.php by phan

Call to undeclared method \Tests\App\Configurator::assertNotSame
Open

        $this->assertNotSame($previousValue, \App\Config::component('YetiForce', $flagName, false));
Severity: Critical
Found in tests/App/Configurator.php by phan

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

        $this->assertInstanceOf('\App\ConfigFile', self::$instance);
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

        self::$instance->create();
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

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

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

    public static $instance = false;
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

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

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

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

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

     * Testing constructor method.
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

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

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

     * @throws \App\Exceptions\AppException
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

        self::$instance->set($flagName, !$previousValue);
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

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

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

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

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

        $previousValue = \App\Config::component('YetiForce', $flagName, false);
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

     * @throws \App\Exceptions\AppException
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

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

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

     * @throws \ReflectionException
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

        self::$instance = new \App\ConfigFile('component', 'YetiForce');
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

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

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

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

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

     * @var \App\ConfigFile
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

        $this->assertNotSame($previousValue, \App\Config::component('YetiForce', $flagName, false));
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

        $flagName = \array_search('bool', \App\YetiForce\Watchdog::$variables);
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

     * Instance container.
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

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

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

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

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

     * @throws \App\Exceptions\IllegalValue
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

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

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

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

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

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

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

     * Testing set and save methods.
Severity: Minor
Found in tests/App/Configurator.php by phpcodesniffer

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

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

There are no issues that match your filters.

Category
Status