jaroslavtyc/drd-plus-codes

View on GitHub
tests/Codes/AbstractCodeTest.php

Summary

Maintainability
A
1 hr
Test Coverage

The class AbstractCodeTest has 12 public methods. Consider refactoring AbstractCodeTest to keep number of public methods under 10.
Open

abstract class AbstractCodeTest extends TestWithMockery
{

    protected function setUp(): void
    {
Severity: Minor
Found in tests/Codes/AbstractCodeTest.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

Missing class import via use statement (line '154', column '36').
Open

                \array_values((new \ReflectionClass($sutClass))->getConstants()),
Severity: Minor
Found in tests/Codes/AbstractCodeTest.php by phpmd

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 '93', column '30').
Open

        $sutClass::getIt(new \DateTime());
Severity: Minor
Found in tests/Codes/AbstractCodeTest.php by phpmd

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 '103', column '27').
Open

        $constants = (new \ReflectionClass($sutClass))->getConstants();
Severity: Minor
Found in tests/Codes/AbstractCodeTest.php by phpmd

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 '63', column '23').
Open

        foreach ((new \ReflectionClass($sutClass))->getConstants() as $constant) {
Severity: Minor
Found in tests/Codes/AbstractCodeTest.php by phpmd

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

Avoid using static access to class '\DrdPlus\Codes\Partials\AbstractCode' in method 'I_will_get_constant_values_from_reflection_as_fallback'.
Open

        self::assertSame([], AbstractCode::getPossibleValues());
Severity: Minor
Found in tests/Codes/AbstractCodeTest.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

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

        foreach ((new \ReflectionClass($sutClass))->getConstants() as $constant) {
            self::assertTrue($sutClass::hasIt($constant));
            $code = $sutClass::getIt($constant);
            self::assertInstanceOf($sutClass, $code);
            self::assertSame($constant, $code->getValue());
Severity: Minor
Found in tests/Codes/AbstractCodeTest.php and 1 other location - About 1 hr to fix
tests/Codes/AllCodesTest.php on lines 88..95

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

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

    public function I_can_call_its_possible_values_even_if_they_are_empty()
    {
        $sutClass = self::getSutClass();
        /** @noinspection PhpUnhandledExceptionInspection */
        self::assertEmpty(
Severity: Minor
Found in tests/Codes/AbstractCodeTest.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_get_it_with_default_value_if_finding_it_with_null is not named in camelCase.
Open

    public function I_get_it_with_default_value_if_finding_it_with_null()
    {
        $sutClass = self::getSutClass();
        self::assertSame($this->getSutDefaultValue(), $sutClass::findIt(null)->getValue());
    }
Severity: Minor
Found in tests/Codes/AbstractCodeTest.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_code_instance_from_every_constant is not named in camelCase.
Open

    public function I_can_create_code_instance_from_every_constant()
    {
        $sutClass = self::getSutClass();
        /** @noinspection PhpUnhandledExceptionInspection */
        foreach ((new \ReflectionClass($sutClass))->getConstants() as $constant) {
Severity: Minor
Found in tests/Codes/AbstractCodeTest.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_code_from_unknown_value is not named in camelCase.
Open

    public function I_can_not_create_code_from_unknown_value()
    {
        $this->expectException(\DrdPlus\Codes\Partials\Exceptions\UnknownValueForCode::class);
        $this->expectExceptionMessageMatches('~da Vinci~');
        $sutClass = self::getSutClass();
Severity: Minor
Found in tests/Codes/AbstractCodeTest.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_will_get_constant_values_from_reflection_as_fallback is not named in camelCase.
Open

    public function I_will_get_constant_values_from_reflection_as_fallback()
    {
        self::assertSame([], AbstractCode::getPossibleValues());
        $sutClass = static::getSutClass();
        self::assertGreaterThan(0, \count($sutClass::getPossibleValues()));
Severity: Minor
Found in tests/Codes/AbstractCodeTest.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_get_it_with_default_value is not named in camelCase.
Open

    public function I_can_get_it_with_default_value()
    {
        $sut = $this->findSut();
        self::assertSame($this->getSutDefaultValue(), $sut->getValue(), 'Expected different default value');
    }
Severity: Minor
Found in tests/Codes/AbstractCodeTest.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_code_object_as_its_string_value is not named in camelCase.
Open

    public function I_can_use_code_object_as_its_string_value()
    {
        $sutClass = self::getSutClass();
        /** @var string[] $givenValues */
        /** @noinspection PhpUnhandledExceptionInspection */
Severity: Minor
Found in tests/Codes/AbstractCodeTest.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 It_is_code is not named in camelCase.
Open

    public function It_is_code()
    {
        self::assertTrue(
            class_exists(self::getSutClass()),
            self::getSutClass() . ' has not been found, check namespace of its test ' . static::class
Severity: Minor
Found in tests/Codes/AbstractCodeTest.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_get_false_when_asking_if_has_null is not named in camelCase.
Open

    public function I_get_false_when_asking_if_has_null()
    {
        $sutClass = self::getSutClass();
        self::assertFalse($sutClass::hasIt(null));
    }
Severity: Minor
Found in tests/Codes/AbstractCodeTest.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 All_public_constants_can_be_given_by_getter is not named in camelCase.
Open

    public function All_public_constants_can_be_given_by_getter()
    {
        $sutClass = self::getSutClass();
        /** @noinspection PhpUnhandledExceptionInspection */
        $constants = (new \ReflectionClass($sutClass))->getConstants();
Severity: Minor
Found in tests/Codes/AbstractCodeTest.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_get_it_with_default_value_when_requested_unknown_value is not named in camelCase.
Open

    public function I_can_get_it_with_default_value_when_requested_unknown_value()
    {
        $sut = $this->findSut('Particle from outer word');
        $sutClass = static::getSutClass();
        self::assertSame(
Severity: Minor
Found in tests/Codes/AbstractCodeTest.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_code_from_invalid_value_format is not named in camelCase.
Open

    public function I_can_not_create_code_from_invalid_value_format()
    {
        $this->expectException(\Granam\ScalarEnum\Exceptions\WrongValueForScalarEnum::class);
        $this->expectExceptionMessageMatches('~\DateTime~');
        $sutClass = self::getSutClass();
Severity: Minor
Found in tests/Codes/AbstractCodeTest.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