jaroslavtyc/drd-plus-rolls-on

View on GitHub

Showing 105 of 105 total issues

Avoid unused parameters such as '$secondSimpleRollOnSuccess'.
Open

        SimpleRollOnSuccess $secondSimpleRollOnSuccess = null,

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Avoid using static access to class 'DrdPlus\RollsOn\QualityAndSuccess\ComparisonOfRollsOnQuality' in method 'isLesser'.
Open

        return ComparisonOfRollsOnQuality::isLesser($lesserThan->getRollOnQuality(), $thatOne->getRollOnQuality());

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\RollsOn\QualityAndSuccess\ComparisonOfRollsOnSuccess' in method 'I_can_use_it'.
Open

        self::assertSame($firstIsGreater, ComparisonOfRollsOnSuccess::isGreater($compareThat, $withThat));

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 '\Granam\Tools\ValueDescriber' in method 'guardSimpleRollsOnSuccessOnly'.
Open

                    . ValueDescriber::describe($simpleRollOnSuccess)

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 unused local variables such as '$preconditionsSum'.
Open

            $preconditionsSum = 456,
Severity: Minor
Found in tests/RollsOn/RollsOnFactoryTest.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 using static access to class 'DrdPlus\RollsOn\QualityAndSuccess\ComparisonOfRollsOnQuality' in method 'compare'.
Open

        return ComparisonOfRollsOnQuality::compare($compareThat->getRollOnQuality(), $withThat->getRollOnQuality());

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 '\Granam\Scalar\Tools\ToScalar' in method '__construct'.
Open

        $this->successValue = ToScalar::toScalar($successValue);

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\RollsOn\QualityAndSuccess\ComparisonOfRollsOnQuality' in method 'I_can_use_it'.
Open

            ComparisonOfRollsOnQuality::compare($compareThat, $withThat)

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\RollsOn\QualityAndSuccess\ComparisonOfRollsOnSuccess' in method 'I_can_use_it'.
Open

        self::assertSame($firstIsLesser, ComparisonOfRollsOnSuccess::isLesser($compareThat, $withThat));

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\RollsOn\QualityAndSuccess\ComparisonOfRollsOnQuality' in method 'isEqual'.
Open

        return ComparisonOfRollsOnQuality::isEqual($equalTo->getRollOnQuality(), $thatOne->getRollOnQuality());

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

            } else {
                $secondRollOnQuality = $simpleRollOnSuccess->getRollOnQuality();
                if ($rollOnQuality->getValue() !== $secondRollOnQuality->getValue()
                    || $rollOnQuality->getPreconditionsSum() !== $secondRollOnQuality->getPreconditionsSum()
                    || $rollOnQuality->getRoll()->getValue() !== $secondRollOnQuality->getRoll()->getValue()

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

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::assertFalse($basicRollOnSuccess->getValue());
            self::assertFalse($basicRollOnSuccess->isSuccess());
            self::assertTrue($basicRollOnSuccess->isFailure());
            self::assertSame('failure', (string)$basicRollOnSuccess);

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 using static access to class 'DrdPlus\RollsOn\QualityAndSuccess\ComparisonOfRollsOnQuality' in method 'isGreater'.
Open

        return ComparisonOfRollsOnQuality::isGreater($greaterThan->getRollOnQuality(), $thatOne->getRollOnQuality());

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\RollsOn\QualityAndSuccess\ComparisonOfRollsOnSuccess' in method 'I_can_use_it'.
Open

            ComparisonOfRollsOnSuccess::isEqual($compareThat, $withThat)

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 unused local variables such as '$remarkableSenseCode'.
Open

            $remarkableSenseCode = $this->createRemarkableSenseCode('baz'),

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 using static access to class '\Granam\Integer\Tools\ToInteger' in method '__construct'.
Open

        $this->preconditionsSum = ToInteger::toInteger($preconditionsSum);

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\RollsOn\QualityAndSuccess\ComparisonOfRollsOnQuality' in method 'I_can_use_it'.
Open

        self::assertSame($firstIsGreater, ComparisonOfRollsOnQuality::isGreater($compareThat, $withThat));

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 '\Granam\Integer\Tools\ToInteger' in method '__construct'.
Open

        $this->difficulty = ToInteger::toInteger($difficulty);

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

    public function I_can_not_use_different_rolls_on_quality(SimpleRollOnSuccess $firstSimpleRoll, SimpleRollOnSuccess $secondSimpleRoll)
    {
        $this->expectException(\DrdPlus\RollsOn\QualityAndSuccess\Exceptions\RollOnQualityHasToBeTheSame::class);
        new ExtendedRollOnSuccess($firstSimpleRoll, $secondSimpleRoll);
    }

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()
    {
        /** @var RollOnQuality $rollOnProperty */
        $rollOnProperty = $this->createSutInstance(
            $property = $this->getPropertyInstance($propertyValue = 123),

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

Severity
Category
Status
Source
Language