jaroslavtyc/drd-plus-codes

View on GitHub

Showing 591 of 591 total issues

Function guardSameCategory has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function guardSameCategory(string $meleeWeaponValue, WeaponCategoryCode $weaponCategoryCode)
    {
        if (!\in_array($meleeWeaponValue, self::$customRangedWeaponCodePerCategory[$weaponCategoryCode->getValue()] ?? [], true)) {
            $alreadyUsedCategory = null;
            foreach (WeaponCategoryCode::getPossibleValues() as $anotherCategory) {
Severity: Minor
Found in Codes/Armaments/RangedWeaponCode.php - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

            'cs' => [
                self::ELEMENTAL => [self::$ONE => 'elementální'],
                self::PSYCHICAL => [self::$ONE => 'psychické'],
                self::MECHANICAL_CRUSH => [self::$ONE => 'fyzické drtivé'],
                self::MECHANICAL_CUT => [self::$ONE => 'fyzické řezné'],
Severity: Minor
Found in Codes/Body/SeriousWoundOriginCode.php and 1 other location - About 30 mins to fix
Codes/Body/SeriousWoundOriginCode.php on lines 158..164

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

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

            'en' => [
                self::ELEMENTAL => [self::$ONE => 'elemental'],
                self::PSYCHICAL => [self::$ONE => 'psychical'],
                self::MECHANICAL_CRUSH => [self::$ONE => 'mechanical crush'],
                self::MECHANICAL_CUT => [self::$ONE => 'mechanical cut'],
Severity: Minor
Found in Codes/Body/SeriousWoundOriginCode.php and 1 other location - About 30 mins to fix
Codes/Body/SeriousWoundOriginCode.php on lines 151..157

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

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

Missing class import via use statement (line '19', column '18').
Open

        if ((new \ReflectionClass(self::getSutClass()))->isAbstract()) {

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 '18').
Open

        if ((new \ReflectionClass(self::getSutClass()))->isAbstract()) {

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 '47', column '18').
Open

        if ((new \ReflectionClass(self::getSutClass()))->isAbstract()) {

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 '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 '94', column '46').
Open

        $remarkableSenseCodeReflection = new \ReflectionClass(RemarkableSenseCode::class);

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 too many return statements within this method.
Open

                return $translations[$code][$plural];
Severity: Major
Found in Codes/Partials/TranslatableCode.php - About 30 mins to fix

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

        public static function getStaffsAndSpearsValues(bool $withCustomValues = true): array
    Severity: Minor
    Found in Codes/Armaments/MeleeWeaponCode.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

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

        public static function getBowsValues(bool $withCustomValues = true): array
    Severity: Minor
    Found in Codes/Armaments/RangedWeaponCode.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

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

            $this->sutReflection = new \ReflectionClass($sutClass);

    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 '123', column '32').
    Open

            $reflectionClass = new \ReflectionClass(TranslatableExtendableCode::class);

    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 '58', column '36').
    Open

                $constantValues = (new \ReflectionClass($codeClass))->getConstants();
    Severity: Minor
    Found in tests/Codes/AllCodesTest.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

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

        public static function getMacesAndClubsValues(bool $withCustomValues = true): array
    Severity: Minor
    Found in Codes/Armaments/MeleeWeaponCode.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

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

                foreach ((new \ReflectionClass($codeClass))->getConstants() as $constant) {
    Severity: Minor
    Found in tests/Codes/AllCodesTest.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 '221', column '40').
    Open

                $codeClassReflection = new \ReflectionClass($codeClass);
    Severity: Minor
    Found in tests/Codes/AllCodesTest.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

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

        public static function getMorningstarsAndMorgensternsValues(bool $withCustomValues = true): array
    Severity: Minor
    Found in Codes/Armaments/MeleeWeaponCode.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

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

        public static function getSwordsValues(bool $withCustomValues = true): array
    Severity: Minor
    Found in Codes/Armaments/MeleeWeaponCode.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

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

        public static function getAxesValues(bool $withCustomValues = true): array
    Severity: Minor
    Found in Codes/Armaments/MeleeWeaponCode.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

    Severity
    Category
    Status
    Source
    Language