jaroslavtyc/drd-plus-health

View on GitHub
tests/Health/Afflictions/AfflictionByWoundTest.php

Summary

Maintainability
A
1 hr
Test Coverage

Method It_is_linked_with_health_immediately has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function It_is_linked_with_health_immediately()
    {
        $woundBoundary = $this->mockery(WoundBoundary::class);
        $woundBoundary->shouldReceive('getValue')
            ->andReturn(5);
Severity: Minor
Found in tests/Health/Afflictions/AfflictionByWoundTest.php - About 1 hr to fix

    The class AfflictionByWoundTest has a coupling between objects value of 23. Consider to reduce the number of dependencies under 13.
    Open

    abstract class AfflictionByWoundTest extends AfflictionTest
    {
    
        /**
         * @test

    CouplingBetweenObjects

    Since: 1.1.0

    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

    Example

    class Foo {
        /**
         * @var \foo\bar\X
         */
        private $x = null;
    
        /**
         * @var \foo\bar\Y
         */
        private $y = null;
    
        /**
         * @var \foo\bar\Z
         */
        private $z = null;
    
        public function setFoo(\Foo $foo) {}
        public function setBar(\Bar $bar) {}
        public function setBaz(\Baz $baz) {}
    
        /**
         * @return \SplObjectStorage
         * @throws \OutOfRangeException
         * @throws \InvalidArgumentException
         * @throws \ErrorException
         */
        public function process(\Iterator $it) {}
    
        // ...
    }

    Source https://phpmd.org/rules/design.html#couplingbetweenobjects

    Missing class import via use statement (line '47', column '37').
    Open

            $afflictionReflection = new \ReflectionClass(self::getSutClass());

    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

    Missing class import via use statement (line '33', column '37').
    Open

            $afflictionReflection = new \ReflectionClass(self::getSutClass());

    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

    Missing class import via use statement (line '61', column '37').
    Open

            $afflictionReflection = new \ReflectionClass(self::getSutClass());

    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

    Missing class import via use statement (line '76', column '27').
    Open

            $reflection = new \ReflectionClass(self::getSutClass());

    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

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

        protected function createWound($isSerious = true, $isOld = false, $value = 0, WoundOriginCode $woundOriginCode = null)

    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

    Missing class import via use statement (line '117', column '37').
    Open

            $afflictionReflection = new \ReflectionClass(self::getSutClass());

    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

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

        protected function createWound($isSerious = true, $isOld = false, $value = 0, WoundOriginCode $woundOriginCode = null)

    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\SeriousWoundOriginCode' in method 'It_is_linked_with_health_immediately'.
    Open

                SeriousWoundOriginCode::getMechanicalCutWoundOrigin(),

    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 'createWound'.
    Open

                ->andReturn($woundOriginCode ?: SeriousWoundOriginCode::getElementalWoundOrigin());

    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 '\Mockery' in method 'createWound'.
    Open

                ->with(\Mockery::type(self::getSutClass()));

    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 excessively long variable names like $afflictionConstructor. Keep variable name length under 20.
    Open

            $afflictionConstructor = $afflictionReflection->getConstructor();

    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 $afflictionConstructor. Keep variable name length under 20.
    Open

            $afflictionConstructor = $afflictionReflection->getConstructor();

    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 $afflictionConstructor. Keep variable name length under 20.
    Open

            $afflictionConstructor = $afflictionReflection->getConstructor();

    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 $afflictionConstructor. Keep variable name length under 20.
    Open

            $afflictionConstructor = $afflictionReflection->getConstructor();

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

        public function It_is_linked_with_health_immediately()
        {
            $woundBoundary = $this->mockery(WoundBoundary::class);
            $woundBoundary->shouldReceive('getValue')
                ->andReturn(5);

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

        public function I_can_get_charisma_malus()
        {
            $afflictionReflection = new \ReflectionClass(self::getSutClass());
            $afflictionConstructor = $afflictionReflection->getConstructor();
            $afflictionConstructor->setAccessible(true);

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

        public function I_can_not_create_it_with_old_wound()
        {
            $this->expectException(\DrdPlus\Health\Afflictions\Exceptions\WoundHasToBeFreshForAffliction::class);
            $reflection = new \ReflectionClass(self::getSutClass());
            $constructor = $reflection->getConstructor();

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

        public function I_can_get_will_malus()
        {
            $afflictionReflection = new \ReflectionClass(self::getSutClass());
            $afflictionConstructor = $afflictionReflection->getConstructor();
            $afflictionConstructor->setAccessible(true);

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

        public function I_can_get_intelligence_malus()
        {
            $afflictionReflection = new \ReflectionClass(self::getSutClass());
            $afflictionConstructor = $afflictionReflection->getConstructor();
            $afflictionConstructor->setAccessible(true);

    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