jaroslavtyc/drd-plus-tables

View on GitHub
tests/Tables/Theurgist/Demons/DemonsTableTest.php

Summary

Maintainability
F
3 days
Test Coverage

Avoid using static access to class '\DrdPlus\Tables\Tables' in method 'I_can_get_demon_will'.
Open

        $demonsTable = new DemonsTable(Tables::getIt());

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 '\DrdPlus\Tables\Tables' in method 'I_can_get_demon_traits'.
Open

        $demonsTable = new DemonsTable(Tables::getIt());

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 '\DrdPlus\Codes\Theurgist\DemonCode' in method 'I_can_get_demon_area'.
Open

                $demonsTable->getDemonArea(DemonCode::getIt($demonCodeValue))

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 '\DrdPlus\Codes\Theurgist\DemonBodyCode' in method 'I_can_get_demon_body_code'.
Open

            DemonBodyCode::getIt($expectedDemonBodyCodeValue),

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 '\DrdPlus\Codes\Theurgist\DemonCode' in method 'I_can_get_demon_will'.
Open

            $demonsTable->getDemonWill(DemonCode::getIt($demonCodeValue))

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 '\DrdPlus\Codes\Theurgist\DemonCode' in method 'I_can_get_demon_body_code'.
Open

            $demonsTable->getDemonBodyCode(DemonCode::getIt($demonCodeValue))

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 '\DrdPlus\Codes\Theurgist\DemonCode' in method 'I_can_get_demon_area'.
Open

            self::assertNull($demonsTable->getDemonArea(DemonCode::getIt($demonCodeValue)));

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 '\DrdPlus\Tables\Tables' in method 'I_can_get_demon_traits'.
Open

            fn(string $demonTraitCodeValue) => new DemonTrait(DemonTraitCode::getIt($demonTraitCodeValue), Tables::getIt()),

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 '\DrdPlus\Tables\Tables' in method 'I_can_get_demon_body_code'.
Open

        $demonsTable = new DemonsTable(Tables::getIt());

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 '\DrdPlus\Codes\Theurgist\DemonCode' in method 'I_can_get_demon_traits'.
Open

        $demonTraits = $demonsTable->getDemonTraits(DemonCode::getIt($demonCodeValue));

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 '\DrdPlus\Tables\Tables' in method 'I_can_get_demon_kind'.
Open

        $demonsTable = new DemonsTable(Tables::getIt());

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 '\DrdPlus\Codes\Theurgist\DemonKindCode' in method 'I_can_get_demon_kind'.
Open

            DemonKindCode::getIt($expectedDemonKindCodeValue),

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 '\DrdPlus\Codes\Theurgist\DemonCode' in method 'I_can_get_demon_kind'.
Open

            $demonsTable->getDemonKindCode(DemonCode::getIt($demonCodeValue))

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 '\DrdPlus\Tables\Tables' in method 'I_can_get_demon_will'.
Open

            new DemonWill([$expectedDemonWillValue, 0], Tables::getIt()),

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 '\DrdPlus\Tables\Tables' in method 'I_can_get_demon_area'.
Open

                new DemonArea([$expectedDemonAreaValue, 1, 4], Tables::getIt()),

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 '\DrdPlus\Codes\Theurgist\DemonTraitCode' in method 'I_can_get_demon_traits'.
Open

            fn(string $demonTraitCodeValue) => new DemonTrait(DemonTraitCode::getIt($demonTraitCodeValue), Tables::getIt()),

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 '\DrdPlus\Tables\Tables' in method 'I_can_get_demon_area'.
Open

        $demonsTable = new DemonsTable(Tables::getIt());

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

        } else {
            self::assertEquals(
                new DemonArea([$expectedDemonAreaValue, 1, 4], Tables::getIt()),
                $demonsTable->getDemonArea(DemonCode::getIt($demonCodeValue))
            );

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

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

    public function provideDemonAndExpectedKind(): array
    {
        return [
            DemonCode::CRON => [DemonCode::CRON, DemonKindCode::BARE],
            DemonCode::DEMON_OF_MOVEMENT => [DemonCode::DEMON_OF_MOVEMENT, DemonKindCode::ANIMATING],
Severity: Major
Found in tests/Tables/Theurgist/Demons/DemonsTableTest.php and 1 other location - About 1 day to fix
tests/Tables/Theurgist/Demons/DemonsTableTest.php on lines 109..131

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

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

    public function provideDemonAndExpectedBody(): array
    {
        return [
            DemonCode::CRON => [DemonCode::CRON, DemonBodyCode::CLOCK],
            DemonCode::DEMON_OF_MOVEMENT => [DemonCode::DEMON_OF_MOVEMENT, DemonBodyCode::PEBBLE],
Severity: Major
Found in tests/Tables/Theurgist/Demons/DemonsTableTest.php and 1 other location - About 1 day to fix
tests/Tables/Theurgist/Demons/DemonsTableTest.php on lines 148..170

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

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

Avoid excessively long variable names like $expectedDemonAreaValue. Keep variable name length under 20.
Open

    public function I_can_get_demon_area(string $demonCodeValue, ?int $expectedDemonAreaValue)

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

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

Avoid excessively long variable names like $expectedDemonWillValue. Keep variable name length under 20.
Open

    public function I_can_get_demon_will(string $demonCodeValue, int $expectedDemonWillValue)

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

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

Avoid excessively long variable names like $expectedDemonTraitCodeValues. Keep variable name length under 20.
Open

    public function I_can_get_demon_traits(string $demonCodeValue, array $expectedDemonTraitCodeValues)

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

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

Avoid excessively long variable names like $expectedDemonKindCodeValue. Keep variable name length under 20.
Open

    public function I_can_get_demon_kind(string $demonCodeValue, string $expectedDemonKindCodeValue)

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

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

Avoid excessively long variable names like $expectedDemonBodyCodeValue. Keep variable name length under 20.
Open

    public function I_can_get_demon_body_code(string $demonCodeValue, string $expectedDemonBodyCodeValue)

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

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

The method I_can_get_demon_will is not named in camelCase.
Open

    public function I_can_get_demon_will(string $demonCodeValue, int $expectedDemonWillValue)
    {
        $demonsTable = new DemonsTable(Tables::getIt());
        self::assertEquals(
            new DemonWill([$expectedDemonWillValue, 0], Tables::getIt()),

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method I_can_get_demon_traits is not named in camelCase.
Open

    public function I_can_get_demon_traits(string $demonCodeValue, array $expectedDemonTraitCodeValues)
    {
        $demonsTable = new DemonsTable(Tables::getIt());
        $demonTraits = $demonsTable->getDemonTraits(DemonCode::getIt($demonCodeValue));
        $expectedDemonTraits = array_map(

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method I_can_get_demon_area is not named in camelCase.
Open

    public function I_can_get_demon_area(string $demonCodeValue, ?int $expectedDemonAreaValue)
    {
        $demonsTable = new DemonsTable(Tables::getIt());
        if ($expectedDemonAreaValue === null) {
            self::assertNull($demonsTable->getDemonArea(DemonCode::getIt($demonCodeValue)));

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method I_can_get_demon_kind is not named in camelCase.
Open

    public function I_can_get_demon_kind(string $demonCodeValue, string $expectedDemonKindCodeValue)
    {
        $demonsTable = new DemonsTable(Tables::getIt());
        self::assertEquals(
            DemonKindCode::getIt($expectedDemonKindCodeValue),

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method I_can_get_demon_body_code is not named in camelCase.
Open

    public function I_can_get_demon_body_code(string $demonCodeValue, string $expectedDemonBodyCodeValue)
    {
        $demonsTable = new DemonsTable(Tables::getIt());
        self::assertEquals(
            DemonBodyCode::getIt($expectedDemonBodyCodeValue),

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status