jaroslavtyc/drd-plus-health

View on GitHub
tests/Health/Inflictions/GlaredTest.php

Summary

Maintainability
C
7 hrs
Test Coverage

Avoid using static access to class 'DrdPlus\Health\Inflictions\Glared' in method 'I_can_create_it_from_glare'.
Open

        $glared = Glared::createFromGlare($this->createGlare($malus, $isShined), $health = new Health());

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\Health\Inflictions\Glared' in method 'I_can_lower_malus_by_getting_used_to_darkness'.
Open

        $glared = Glared::createFromGlare($this->createGlare(-36, false), new Health());

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\Health\Inflictions\Glared' in method 'I_can_get_used_to_darkness_by_very_long_waiting_when_blinded'.
Open

        $blinded = Glared::createFromGlare($this->createGlare($malus = -21, false /* not shined = blinded */), new Health());

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\Health\Inflictions\Glared' in method 'I_can_get_used_to_darkness_by_very_long_waiting_when_shined'.
Open

        $shined = Glared::createFromGlare($this->createGlare($malus = -1, true /* shined = not blinded */), new Health());

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\Health\Inflictions\Glared' in method 'I_can_create_it_without_glare_at_all'.
Open

        $glared = Glared::createWithoutGlare($health = new Health());

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\Health\Inflictions\Glared' in method 'I_can_get_used_to_shine_by_long_waiting'.
Open

        $glared = Glared::createFromGlare($this->createGlare(-50, true), new Health());

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\Health\Inflictions\Glared' in method 'I_can_get_used_to_darkness_by_long_waiting'.
Open

        $glared = Glared::createFromGlare($this->createGlare(-21 /* malus */, false), new Health());

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\Health\Inflictions\Glared' in method 'I_can_lower_malus_by_getting_used_to_shine'.
Open

        $glared = Glared::createFromGlare($this->createGlare(-15, true), new Health());

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

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

    public function I_can_get_used_to_shine_by_long_waiting(): void
    {
        $glared = Glared::createFromGlare($this->createGlare(-50, true), new Health());

        self::assertSame(-50, $glared->getCurrentMalus());
Severity: Major
Found in tests/Health/Inflictions/GlaredTest.php and 1 other location - About 3 hrs to fix
tests/Health/Inflictions/GlaredTest.php on lines 144..156

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

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 I_can_get_used_to_darkness_by_long_waiting(): void
    {
        $glared = Glared::createFromGlare($this->createGlare(-21 /* malus */, false), new Health());

        self::assertSame(-21, $glared->getCurrentMalus());
Severity: Major
Found in tests/Health/Inflictions/GlaredTest.php and 1 other location - About 3 hrs to fix
tests/Health/Inflictions/GlaredTest.php on lines 94..106

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

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

The method I_can_create_it_from_glare is not named in camelCase.
Open

    public function I_can_create_it_from_glare(int $malus, bool $isShined): void
    {
        $glared = Glared::createFromGlare($this->createGlare($malus, $isShined), $health = new Health());
        self::assertSame($malus, $glared->getCurrentMalus());
        self::assertSame($isShined, $glared->isShined());

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_lower_malus_by_getting_used_to_darkness is not named in camelCase.
Open

    public function I_can_lower_malus_by_getting_used_to_darkness(): void
    {
        $glared = Glared::createFromGlare($this->createGlare(-36, false), new Health());

        self::assertSame(-36, $glared->getCurrentMalus());

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_used_to_darkness_by_long_waiting is not named in camelCase.
Open

    public function I_can_get_used_to_darkness_by_long_waiting(): void
    {
        $glared = Glared::createFromGlare($this->createGlare(-21 /* malus */, false), new Health());

        self::assertSame(-21, $glared->getCurrentMalus());

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_lower_malus_by_getting_used_to_shine is not named in camelCase.
Open

    public function I_can_lower_malus_by_getting_used_to_shine(): void
    {
        $glared = Glared::createFromGlare($this->createGlare(-15, true), new Health());

        self::assertSame(-15, $glared->getCurrentMalus());

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_used_to_darkness_by_very_long_waiting_when_blinded is not named in camelCase.
Open

    public function I_can_get_used_to_darkness_by_very_long_waiting_when_blinded(): void
    {
        $blinded = Glared::createFromGlare($this->createGlare($malus = -21, false /* not shined = blinded */), new Health());

        self::assertSame($malus, $blinded->getCurrentMalus());

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_create_it_without_glare_at_all is not named in camelCase.
Open

    public function I_can_create_it_without_glare_at_all(): void
    {
        $glared = Glared::createWithoutGlare($health = new Health());
        self::assertSame(0, $glared->getCurrentMalus());
        self::assertSame($health, $glared->getHealth());

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_used_to_darkness_by_very_long_waiting_when_shined is not named in camelCase.
Open

    public function I_can_get_used_to_darkness_by_very_long_waiting_when_shined(): void
    {
        $shined = Glared::createFromGlare($this->createGlare($malus = -1, true /* shined = not blinded */), new Health());

        self::assertSame($malus, $shined->getCurrentMalus());

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_used_to_shine_by_long_waiting is not named in camelCase.
Open

    public function I_can_get_used_to_shine_by_long_waiting(): void
    {
        $glared = Glared::createFromGlare($this->createGlare(-50, true), new Health());

        self::assertSame(-50, $glared->getCurrentMalus());

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