YetiForceCompany/YetiForceCRM

View on GitHub
tests/Base/F_Library.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Avoid using static access to class '\App\Version' in method 'testLibraryVersion'.
Open

            $appVersion = \App\Version::get($lib['name']);
Severity: Minor
Found in tests/Base/F_Library.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 '\Settings_ModuleManager_Library_Model' in method 'testLibraryVersion'.
Open

        $libs = \Settings_ModuleManager_Library_Model::getAll();
Severity: Minor
Found in tests/Base/F_Library.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 '\Settings_ModuleManager_Library_Model' in method 'testLibraryVersion'.
Open

        \Settings_ModuleManager_Library_Model::downloadAll();
Severity: Minor
Found in tests/Base/F_Library.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 "version.php" 3 times.
Open

            $this->assertFileExists($lib['dir'] . 'version.php', 'File does not exist: ' . $lib['dir'] . 'version.php');
Severity: Critical
Found in tests/Base/F_Library.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\Base\F_Library::assertTrue
Open

            $this->assertTrue($appVersion == $libVersion, "Wrong library version: $name, library version: $libVersion, config version: $appVersion");
Severity: Critical
Found in tests/Base/F_Library.php by phan

Call to undeclared method \Tests\Base\F_Library::assertFileExists
Open

            $this->assertFileExists($lib['dir'] . 'version.php', 'File does not exist: ' . $lib['dir'] . 'version.php');
Severity: Critical
Found in tests/Base/F_Library.php by phan

The class F_Library is not named in CamelCase.
Open

class F_Library extends \Tests\Base
{
    /**
     * Testing library versions.
     */
Severity: Minor
Found in tests/Base/F_Library.php by phpmd

CamelCaseClassName

Since: 0.2

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

Example

class class_name {
}

Source

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

            $libVersions = require $lib['dir'] . 'version.php';
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

        $libs = \Settings_ModuleManager_Library_Model::getAll();
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

Line exceeds 120 characters; contains 149 characters
Open

            $this->assertTrue($appVersion == $libVersion, "Wrong library version: $name, library version: $libVersion, config version: $appVersion");
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

    /**
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

        \Settings_ModuleManager_Library_Model::downloadAll();
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

     * Testing library versions.
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

    public function testLibraryVersion()
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

    }
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

    {
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

        }
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

     */
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

            $this->assertTrue($appVersion == $libVersion, "Wrong library version: $name, library version: $libVersion, config version: $appVersion");
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

            $appVersion = \App\Version::get($lib['name']);
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

            $this->assertFileExists($lib['dir'] . 'version.php', 'File does not exist: ' . $lib['dir'] . 'version.php');
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

        foreach ($libs as $name => $lib) {
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

            $libVersion = $libVersions['version'];
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

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

class F_Library extends \Tests\Base
Severity: Minor
Found in tests/Base/F_Library.php by phpcodesniffer

There are no issues that match your filters.

Category
Status