jaroslavtyc/drd-plus-codes

View on GitHub

Showing 591 of 591 total issues

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

    public static function addNewRangedWeaponCode(
        string $newRangedWeaponCodeValue,
        WeaponCategoryCode $rangedWeaponCategoryCode,
        array $translations
    ): bool
Severity: Major
Found in Codes/Armaments/RangedWeaponCode.php and 1 other location - About 1 hr to fix
Codes/Armaments/MeleeWeaponCode.php on lines 314..334

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

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

    public static function addNewMeleeWeaponCode(
        string $newMeleeWeaponCodeValue,
        WeaponCategoryCode $meleeWeaponCategoryCode,
        array $translations
    ): bool
Severity: Major
Found in Codes/Armaments/MeleeWeaponCode.php and 1 other location - About 1 hr to fix
Codes/Armaments/RangedWeaponCode.php on lines 127..148

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

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

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

    protected function fetchTranslations(): array
    {
        return [
            'en' => [
                self::HORSE => [self::$ONE => 'horse', self::$FEW => 'horses', self::$MANY => 'horses'],
Severity: Minor
Found in Codes/Transport/RidingAnimalCode.php - About 1 hr to fix

    Method I_get_whispered_current_code_as_return_value_of_factory_method has 34 lines of code (exceeds 25 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 1 hr to fix

      Method getPossibleValues has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function getPossibleValues(): array
          {
              return [
                  self::BARRIER_VENUS,
                  self::BARRIER_MARS,
      Severity: Minor
      Found in Codes/Theurgist/ProfileCode.php - About 1 hr to fix

        Method All_public_constants_can_be_given_by_getter has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function All_public_constants_can_be_given_by_getter()
            {
                $constants = $this->sutReflection->getConstants();
                self::assertEquals($constants, array_unique($constants));
                asort($constants);
        Severity: Minor
        Found in tests/Codes/Partials/TranslatableExtendableCodeTest.php - About 1 hr to fix

          Function getTranslations has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function getTranslations(string $requiredLanguageCode): array
              {
                  if ((self::$translations[static::class] ?? null) === null) {
                      $translations = self::$customCodeTranslations[static::class] ?? [];
                      if (count($translations) === 0) {
          Severity: Minor
          Found in Codes/Partials/TranslatableExtendableCode.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

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

                      'cs' => [
                          self::STAB => [self::$ONE => 'bodné', self::$FEW => 'bodná', self::$MANY => 'bodných'],
                          self::CRUSH => [self::$ONE => 'drtivé', self::$FEW => 'drtivá', self::$MANY => 'drtivých'],
                          self::CUT => [self::$ONE => 'sečné', self::$FEW => 'sečná', self::$MANY => 'sečných'],
                      ],
          Severity: Major
          Found in Codes/Body/PhysicalWoundTypeCode.php and 1 other location - About 1 hr to fix
          Codes/Body/PhysicalWoundTypeCode.php on lines 61..65

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

          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::STAB => [self::$ONE => 'stab', self::$FEW => 'stabs', self::$MANY => 'stabs'],
                          self::CRUSH => [self::$ONE => 'crush', self::$FEW => 'crushes', self::$MANY => 'crushes'],
                          self::CUT => [self::$ONE => 'cut', self::$FEW => 'cuts', self::$MANY => 'cuts'],
                      ],
          Severity: Major
          Found in Codes/Body/PhysicalWoundTypeCode.php and 1 other location - About 1 hr to fix
          Codes/Body/PhysicalWoundTypeCode.php on lines 56..60

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

          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

          Method I_can_get_all_codes_at_once_or_by_same_named_constant has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function I_can_get_all_codes_at_once_or_by_same_named_constant()
              {
                  self::assertSame(
                      $expectedValues = [
                          // throwing weapons
          Severity: Minor
          Found in tests/Codes/Armaments/RangedWeaponCodeTest.php - About 1 hr to fix

            Method getPossibleValues has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function getPossibleValues(): array
                {
                    return [
                        self::ARMOR_WEARING,
                        self::ATHLETICS,
            Severity: Minor
            Found in Codes/Skills/PhysicalSkillCode.php - About 1 hr to fix

              Method getRaceToSubRaceValues has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function getRaceToSubRaceValues(): array
                  {
                      return [
                          RaceCode::HUMAN => [
                              self::COMMON,
              Severity: Minor
              Found in Codes/SubRaceCode.php - About 1 hr to fix

                Method getExpectedRacesToSubRaces has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function getExpectedRacesToSubRaces(): array
                    {
                        return [
                            'human' => [
                                'common',
                Severity: Minor
                Found in tests/Codes/SubRaceCodeTest.php - About 1 hr to fix

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

                      public function I_can_extended_it_by_custom_translatable_code()
                      {
                          /** @var WeaponCode $sutClass */
                          $sutClass = self::getSutClass();
                          $reflectionClass = new \ReflectionClass($sutClass);
                  Severity: Minor
                  Found in tests/Codes/Armaments/WeaponCodeTest.php - About 1 hr to fix

                    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

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

                              public static function getMorningstarsAndMorgensternsValues(bool $withCustomValues = true): array
                              {
                                  $defaultValues = [
                                      self::LIGHT_MORGENSTERN,
                                      self::MORGENSTERN,
                          Severity: Major
                          Found in Codes/Armaments/MeleeWeaponCode.php and 2 other locations - About 1 hr to fix
                          Codes/Armaments/MeleeWeaponCode.php on lines 208..224
                          Codes/Armaments/MeleeWeaponCode.php on lines 239..258

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

                          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

                          <?php declare(strict_types=1);
                          
                          namespace DrdPlus\Tests\Codes\Armaments;
                          
                          use DrdPlus\Codes\Armaments\HelmCode;
                          Severity: Major
                          Found in tests/Codes/Armaments/HelmCodeTest.php and 1 other location - About 1 hr to fix
                          tests/Codes/Armaments/BodyArmorCodeTest.php on lines 1..28

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

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language