jaroslavtyc/drd-plus-health

View on GitHub

Showing 24 of 669 total issues

File HealthTest.php has 1250 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

namespace DrdPlus\Tests\Health;

use DrdPlus\Codes\Body\OrdinaryWoundOriginCode;
Severity: Major
Found in tests/Health/HealthTest.php - About 3 days to fix

    File Health.php has 560 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php declare(strict_types=1);
    
    namespace DrdPlus\Health;
    
    use DrdPlus\BaseProperties\Will;
    Severity: Major
    Found in Health/Health.php - About 1 day to fix

      HealthTest has 64 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class HealthTest extends TestWithMockery
      {
          /**
           * @test
           */
      Severity: Major
      Found in tests/Health/HealthTest.php - About 1 day to fix

        Health has 61 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Health extends StrictObject
        {
            /**
             * @var array|Wound[]
             */
        Severity: Major
        Found in Health/Health.php - About 1 day to fix

          Method I_can_be_wounded_both_ordinary_and_seriously has 74 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function I_can_be_wounded_both_ordinary_and_seriously(): void
              {
                  $ordinaryWoundsSize = 0;
                  $seriousWoundsSize = 0;
                  $health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(10));
          Severity: Major
          Found in tests/Health/HealthTest.php - About 2 hrs to fix

            Method I_can_get_calculated_filled_half_rows_for_given_wound_value has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function I_can_get_calculated_filled_half_rows_for_given_wound_value(): void
                {
                    // limit of wounds divisible by two (odd)
                    $gridOfWounds = new GridOfWounds($this->createHealth([] /* no wounds*/));
                    self::assertSame(
            Severity: Major
            Found in tests/Health/GridOfWoundsTest.php - About 2 hrs to fix

              Method I_can_be_seriously_wounded has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function I_can_be_seriously_wounded(): void
                  {
                      $health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(6));
              
                      $seriousWoundByStab = $health->addWound(
              Severity: Major
              Found in tests/Health/HealthTest.php - About 2 hrs to fix

                Method I_can_get_healed_serious_wounds has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function I_can_get_healed_serious_wounds(): void
                    {
                        $health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(6));
                
                        $seriousWoundByStab = $health->addWound(
                Severity: Major
                Found in tests/Health/HealthTest.php - About 2 hrs to fix

                  Method I_can_be_ordinary_wounded has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function I_can_be_ordinary_wounded(): void
                      {
                          $health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(5));
                          $ordinaryWound = $health->addWound(
                              $this->createWoundSize(2),
                  Severity: Minor
                  Found in tests/Health/HealthTest.php - About 1 hr to fix

                    Method I_can_ask_it_if_may_suffer_from_wounds has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function I_can_ask_it_if_may_suffer_from_wounds(): void
                        {
                            $woundBoundary = $this->createWoundBoundary(5);
                            $health = $this->createHealthToTest($woundBoundary);
                            self::assertFalse($health->maySufferFromWounds($woundBoundary));
                    Severity: Minor
                    Found in tests/Health/HealthTest.php - About 1 hr to fix

                      Method I_can_ask_it_if_I_am_suffering_from_wounds has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function I_can_ask_it_if_I_am_suffering_from_wounds(): void
                          {
                              $woundBoundary = $this->createWoundBoundary(5);
                              $health = $this->createHealthToTest($woundBoundary);
                              self::assertFalse($health->mayHaveMalusFromWounds($woundBoundary));
                      Severity: Minor
                      Found in tests/Health/HealthTest.php - About 1 hr to fix

                        Method Malus_can_increase_on_fresh_wound has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function Malus_can_increase_on_fresh_wound(int $willValue, int $rollValue, int $expectedMalus): void
                            {
                                $health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(5));
                        
                                $health->addWound(
                        Severity: Minor
                        Found in tests/Health/HealthTest.php - About 1 hr to fix

                          Method Malus_can_not_decrease_on_fresh_wound has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function Malus_can_not_decrease_on_fresh_wound(int $willValue, int $rollValue, int $expectedMalus): void
                              {
                                  $health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(5));
                          
                                  $health->addWound($this->createWoundSize(5),
                          Severity: Minor
                          Found in tests/Health/HealthTest.php - About 1 hr to fix

                            Function setGettingUsedToForTime has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function setGettingUsedToForTime(Time $gettingUsedToFor)
                                {
                                    $inRounds = $gettingUsedToFor->findRounds();
                                    if ($inRounds === null) {
                                        // it can not be expressed by rounds, so definitely get used to it - malus zeroed
                            Severity: Minor
                            Found in Health/Inflictions/Glared.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

                            Function calculateFilledHalfRowsFor has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function calculateFilledHalfRowsFor(WoundSize $woundSize, WoundBoundary $woundBoundary): int
                                {
                                    if ($this->getWoundsPerRowMaximum($woundBoundary) % 2 === 0) { // odd
                                        $filledHalfRows = SumAndRound::floor($woundSize->getValue() / ($this->getWoundsPerRowMaximum($woundBoundary) / 2));
                                    } else {
                            Severity: Minor
                            Found in Health/GridOfWounds.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 I_can_be_ordinary_healed has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function I_can_be_ordinary_healed(): void
                                {
                                    $health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(7));
                            
                                    $health->addWound($this->createWoundSize(1),
                            Severity: Minor
                            Found in tests/Health/HealthTest.php - About 1 hr to fix

                              Method __construct has 11 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                      SeriousWound $seriousWound, // wound can be healed, but never disappears - just stays healed
                                      AfflictionProperty $property,
                                      AfflictionDangerousness $dangerousness,
                                      AfflictionDomain $domain,
                                      AfflictionVirulence $virulence,
                              Severity: Major
                              Found in Health/Afflictions/AfflictionByWound.php - About 1 hr to fix

                                Method __construct has 11 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                        Health $health,
                                        AfflictionProperty $property,
                                        AfflictionDangerousness $dangerousness,
                                        AfflictionDomain $domain,
                                        AfflictionVirulence $virulence,
                                Severity: Major
                                Found in Health/Afflictions/Affliction.php - About 1 hr to fix

                                  Method It_is_linked_with_health_immediately has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function It_is_linked_with_health_immediately()
                                      {
                                          $woundBoundary = $this->mockery(WoundBoundary::class);
                                          $woundBoundary->shouldReceive('getValue')
                                              ->andReturn(5);
                                  Severity: Minor
                                  Found in tests/Health/Afflictions/AfflictionByWoundTest.php - About 1 hr to fix

                                    Method I_should_roll_against_malus_from_wounds_because_of_heal_of_ordinary_wound has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function I_should_roll_against_malus_from_wounds_because_of_heal_of_ordinary_wound($willValue, $rollValue, $expectedMalus): void
                                        {
                                            $health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(10));
                                            $health->addWound($this->createWoundSize(4),
                                                SeriousWoundOriginCode::getElementalWoundOrigin(),
                                    Severity: Minor
                                    Found in tests/Health/HealthTest.php - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language