jaroslavtyc/drd-plus-health

View on GitHub
tests/Health/WoundTest.php

Summary

Maintainability
A
1 hr
Test Coverage

Method I_can_use_it has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function I_can_use_it(): Wound
    {
        $wound = $this->createWound(
            $health = $this->createHealth(),
            new WoundSize($woundSizeValue = 3),
Severity: Minor
Found in tests/Health/WoundTest.php - About 1 hr to fix

    The method createHealth has a boolean flag argument $openForNewWounds, which is a certain sign of a Single Responsibility Principle violation.
    Open

        private function createHealth($openForNewWounds = true)
    Severity: Minor
    Found in tests/Health/WoundTest.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    Avoid using static access to class '\DrdPlus\Codes\Body\OrdinaryWoundOriginCode' in method 'I_can_use_it'.
    Open

                self::assertSame(OrdinaryWoundOriginCode::getIt(), $wound->getWoundOriginCode());
    Severity: Minor
    Found in tests/Health/WoundTest.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 '\DrdPlus\Codes\Body\SeriousWoundOriginCode' in method 'I_can_not_create_wound_directly'.
    Open

                SeriousWoundOriginCode::getMechanicalCrushWoundOrigin()
    Severity: Minor
    Found in tests/Health/WoundTest.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 '\DrdPlus\Codes\Body\SeriousWoundOriginCode' in method 'I_can_use_it'.
    Open

                $woundOrigin = SeriousWoundOriginCode::getMechanicalCutWoundOrigin()
    Severity: Minor
    Found in tests/Health/WoundTest.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 '\DrdPlus\Codes\Body\SeriousWoundOriginCode' in method 'I_can_create_wound_with_zero_value'.
    Open

                SeriousWoundOriginCode::getMechanicalCrushWoundOrigin()
    Severity: Minor
    Found in tests/Health/WoundTest.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 '\DrdPlus\Codes\Body\SeriousWoundOriginCode' in method 'I_can_heal_it_both_partially_and_fully'.
    Open

                $elementalWoundOrigin = SeriousWoundOriginCode::getElementalWoundOrigin()
    Severity: Minor
    Found in tests/Health/WoundTest.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

    The method I_can_use_it uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                self::assertSame(OrdinaryWoundOriginCode::getIt(), $wound->getWoundOriginCode());
            }
    Severity: Minor
    Found in tests/Health/WoundTest.php by phpmd

    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

    Avoid unused local variables such as '$health'.
    Open

                $health = $this->createHealth(),
    Severity: Minor
    Found in tests/Health/WoundTest.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    Avoid unused local variables such as '$elementalWoundOrigin'.
    Open

                $elementalWoundOrigin = SeriousWoundOriginCode::getElementalWoundOrigin()
    Severity: Minor
    Found in tests/Health/WoundTest.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

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

        abstract protected function createWound(Health $health, WoundSize $woundSize, SeriousWoundOriginCode $seriousWoundOriginCode): Wound;
    Severity: Minor
    Found in tests/Health/WoundTest.php by phpmd

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

        public function I_can_heal_it_both_partially_and_fully(): void
        {
            $wound = $this->createWound(
                $health = $this->createHealth(),
                new WoundSize($woundSizeValue = 3),
    Severity: Minor
    Found in tests/Health/WoundTest.php by phpmd

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

        public function I_can_use_it(): Wound
        {
            $wound = $this->createWound(
                $health = $this->createHealth(),
                new WoundSize($woundSizeValue = 3),
    Severity: Minor
    Found in tests/Health/WoundTest.php by phpmd

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

        public function I_can_not_create_wound_directly(): void
        {
            $this->expectException(\DrdPlus\Health\Exceptions\WoundHasToBeCreatedByHealthItself::class);
            $this->createWound(
                $this->createHealth(false /* not open for new wounds */),
    Severity: Minor
    Found in tests/Health/WoundTest.php by phpmd

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

        public function I_can_create_wound_with_zero_value(): void
        {
            $wound = $this->createWound(
                $this->createHealth(),
                new WoundSize(0),
    Severity: Minor
    Found in tests/Health/WoundTest.php by phpmd

    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