jaroslavtyc/drd-plus-codes

View on GitHub

Showing 57 of 591 total issues

File SpellCode.php has 1016 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

namespace DrdPlus\Codes\Wizard;

use DrdPlus\Codes\Partials\TranslatableCode;
Severity: Major
Found in Codes/Wizard/SpellCode.php - About 2 days to fix

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

        protected function fetchTranslations(): array
        {
            return [
                'en' => [
                    // TIME-SPACE
    Severity: Major
    Found in Codes/Wizard/SpellCode.php - About 2 days to fix

      Function I_can_ask_code_if_is_specific_weapon_type has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
      Open

          public function I_can_ask_code_if_is_specific_weapon_type()
          {
              $questions = [
                  'isAxe', 'isKnifeOrDagger', 'isMaceOrClub', 'isMorningstarOrMorgenstern', 'isSaberOrBowieKnife',
                  'isStaffOrSpear', 'isSword', 'isVoulgeOrTrident', 'isUnarmed',
      Severity: Minor
      Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php - About 1 day 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

      File MeleeWeaponCodeTest.php has 442 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php declare(strict_types=1);
      
      namespace DrdPlus\Tests\Codes\Armaments;
      
      use DrdPlus\Codes\Armaments\Exceptions\CanNotBeConvertedToRangeWeaponCode;
      Severity: Minor
      Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php - About 6 hrs to fix

        File MeleeWeaponCode.php has 438 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php declare(strict_types=1);
        
        namespace DrdPlus\Codes\Armaments;
        
        /**
        Severity: Minor
        Found in Codes/Armaments/MeleeWeaponCode.php - About 6 hrs to fix

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

              protected function fetchTranslations(): array
              {
                  return [
                      'en' => [
                          self::LIGHT_AXE => [self::$ONE => 'light axe', self::$FEW => 'light axes', self::$MANY => 'light axes'],
          Severity: Major
          Found in Codes/Armaments/MeleeWeaponCode.php - About 4 hrs to fix

            Method I_can_ask_code_if_is_specific_weapon_type has 107 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function I_can_ask_code_if_is_specific_weapon_type()
                {
                    $questions = [
                        'isAxe', 'isKnifeOrDagger', 'isMaceOrClub', 'isMorningstarOrMorgenstern', 'isSaberOrBowieKnife',
                        'isStaffOrSpear', 'isSword', 'isVoulgeOrTrident', 'isUnarmed',
            Severity: Major
            Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php - About 4 hrs to fix

              MeleeWeaponCode has 29 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class MeleeWeaponCode extends WeaponCode implements MeleeWeaponlikeCode
              {
              
                  private static $customMeleeWeaponCodePerCategory = [];
              
              
              Severity: Minor
              Found in Codes/Armaments/MeleeWeaponCode.php - About 3 hrs to fix

                Function I_can_ask_code_if_is_specific_weapon_type has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function I_can_ask_code_if_is_specific_weapon_type()
                    {
                        $questions = [
                            'isBow', 'isCrossbow', 'isThrowingWeapon',
                        ];
                Severity: Minor
                Found in tests/Codes/Armaments/RangedWeaponCodeTest.php - About 3 hrs 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

                MeleeWeaponCodeTest has 26 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class MeleeWeaponCodeTest extends WeaponCodeTest
                {
                    use MeleeWeaponlikeCodeTrait;
                
                    /**
                Severity: Minor
                Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php - About 3 hrs to fix

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

                      protected function fetchTranslations(): array
                      {
                          return [
                              'en' => [
                                  self::STRENGTH => [self::$ONE => 'strength', self::$FEW => 'strengths', self::$MANY => 'strengths'],
                  Severity: Major
                  Found in Codes/Properties/PropertyCode.php - About 2 hrs to fix

                    Method I_can_get_all_codes_at_once_or_by_same_named_constant has 67 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 = [
                                    // unarmed
                    Severity: Major
                    Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php - About 2 hrs to fix

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

                          protected function fetchTranslations(): array
                          {
                              return [
                                  'en' => [
                                      self::ARMOR_WEARING => [self::$ONE => 'armor wearing'],
                      Severity: Major
                      Found in Codes/Skills/PhysicalSkillCode.php - About 2 hrs to fix

                        Function scanForCodeClasses has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function scanForCodeClasses(string $rootDir, string $rootNamespace): array
                            {
                                $codeClasses = [];
                                foreach (\scandir($rootDir, SCANDIR_SORT_NONE) as $folder) {
                                    $folderFullPath = $rootDir . DIRECTORY_SEPARATOR . $folder;
                        Severity: Minor
                        Found in tests/Codes/GetCodeClassesTrait.php - About 2 hrs 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_czech_translation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function I_can_get_its_czech_translation()
                            {
                                foreach ($this->getTranslatableCodeClasses() as $codeClass) {
                                    $hasSinglesOnly = $this->hasSinglesOnly($codeClass);
                                    $hasMultiplesOnly = $this->hasMultiplesOnly($codeClass);
                        Severity: Minor
                        Found in tests/Codes/AllTranslatableCodesTest.php - About 2 hrs 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 fetchTranslations has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function fetchTranslations(): array
                            {
                                return [
                                    'en' => [
                                        self::BIG_HANDWORK => [self::$ONE => 'big handwork'],
                        Severity: Minor
                        Found in Codes/Skills/CombinedSkillCode.php - About 1 hr to fix

                          Method I_can_get_its_czech_translation has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function I_can_get_its_czech_translation()
                              {
                                  foreach ($this->getTranslatableCodeClasses() as $codeClass) {
                                      $hasSinglesOnly = $this->hasSinglesOnly($codeClass);
                                      $hasMultiplesOnly = $this->hasMultiplesOnly($codeClass);
                          Severity: Minor
                          Found in tests/Codes/AllTranslatableCodesTest.php - About 1 hr to fix

                            Function translateTo has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function translateTo(string $languageCode, $amount = 1): string
                                {
                                    $code = $this->getValue();
                                    $translations = $this->getTranslations($languageCode);
                                    /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
                            Severity: Minor
                            Found in Codes/Partials/TranslatableCode.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 fetchTranslations has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                protected function fetchTranslations(): array
                                {
                                    return [
                                        'en' => [
                                            self::SHORT_BOW => [self::$ONE => 'short bow', self::$FEW => 'short bows', self::$MANY => 'short bows'],
                            Severity: Minor
                            Found in Codes/Armaments/RangedWeaponCode.php - About 1 hr to fix

                              Function checkTranslationsFormat has a Cognitive Complexity of 14 (exceeds 5 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

                              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