jaroslavtyc/drd-plus-codes

View on GitHub

Showing 57 of 591 total issues

Function fetchTranslations has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    protected function fetchTranslations(): array
    {
        $handle = \fopen($this->getTranslationsFileName(), 'rb');
        $rows = [];
        while (($row = \fgetcsv($handle)) !== false && $row !== null) {
Severity: Minor
Found in Codes/Partials/FileBasedTranslatableTrait.php - About 1 hr 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

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

    private static function checkTranslationsFormat(array $translations)
    {
        /**
         * @var string $languageCode
         * @var array|string[] $languageTranslations
Severity: Minor
Found in Codes/Partials/TranslatableExtendableCode.php - About 1 hr to fix

    Method I_can_extended_it_by_custom_translatable_code has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function I_can_extended_it_by_custom_translatable_code()
        {
            /** @var TranslatableExtendableCode $sutClass */
            $sutClass = self::getSutClass();
            $translations = $this->sutReflection->getProperty('translations');
    Severity: Minor
    Found in tests/Codes/Partials/TranslatableExtendableCodeTest.php - About 1 hr to fix

      Method fetchTranslations has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function fetchTranslations(): array
          {
              return [
                  'cs' => [
                      'one' => [
      Severity: Minor
      Found in Codes/Theurgist/SpellTraitCode.php - About 1 hr to fix

        Function getPossibleValues has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function getPossibleValues(): array
            {
                if ((static::$possibleValues[static::class] ?? null) === null) {
                    static::$possibleValues[static::class] = [];
                    try {
        Severity: Minor
        Found in Codes/Partials/AbstractCode.php - About 45 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

        Function I_can_get_its_english_translation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function I_can_get_its_english_translation()
            {
                foreach ($this->getTranslatableCodeClasses() as $codeClass) {
                    $testClass = $this->getTestClass($codeClass);
                    self::assertTrue(
        Severity: Minor
        Found in tests/Codes/AllTranslatableCodesTest.php - About 45 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

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

            public function Has_unique_codes_across_all_weaponlikes()
            {
                $sutClass = self::getSutClass();
                $reflection = new \ReflectionClass($sutClass);
                $sameCodes = [];
        Severity: Minor
        Found in tests/Codes/Armaments/WeaponlikeCodeTest.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

        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::$customMeleeWeaponCodePerCategory[$weaponCategoryCode->getValue()] ?? [], true)) {
                    $alreadyUsedCategory = null;
                    foreach (WeaponCategoryCode::getPossibleValues() as $anotherCategory) {
        Severity: Minor
        Found in Codes/Armaments/MeleeWeaponCode.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

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

            public function I_get_whispered_current_code_as_return_value_of_factory_method()
            {
                foreach ($this->getCodeClasses() as $codeClass) {
                    $reflectionClass = new \ReflectionClass($codeClass);
                    $classBaseName = preg_replace('~^.*[\\\](\w+)$~', '$1', $codeClass);
        Severity: Minor
        Found in tests/Codes/AllCodesTest.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

        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

        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

          Avoid too many return statements within this method.
          Open

                      return str_replace('_', ' ', $code); // just replacing underscores by spaces
          Severity: Major
          Found in Codes/Partials/TranslatableCode.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

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

              Avoid too many return statements within this method.
              Open

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

                Avoid too many return statements within this method.
                Open

                        return str_replace('_', ' ', $code); // just replacing underscores by spaces
                Severity: Major
                Found in Codes/Partials/TranslatableCode.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

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

                    Function I_can_easily_find_out_if_sub_race_belongs_to_race has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function I_can_easily_find_out_if_sub_race_belongs_to_race()
                        {
                            foreach ($this->getExpectedRacesToSubRaces() as $race => $subRaces) {
                                $raceCode = RaceCode::getIt($race);
                                foreach ($subRaces as $subRace) {
                    Severity: Minor
                    Found in tests/Codes/SubRaceCodeTest.php - About 25 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

                    Severity
                    Category
                    Status
                    Source
                    Language