jaroslavtyc/drd-plus-stamina

View on GitHub

Showing 9 of 88 total issues

File StaminaTest.php has 437 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

namespace DrdPlus\Tests\Stamina;

use DrdPlus\Properties\Derived\Endurance;
Severity: Minor
Found in tests/Stamina/StaminaTest.php - About 6 hrs to fix

    StaminaTest has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class StaminaTest extends TestWithMockery
    {
        /**
         * @test
         */
    Severity: Minor
    Found in tests/Stamina/StaminaTest.php - About 3 hrs to fix

      Stamina has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Stamina extends StrictObject
      {
          /**
           * @var Fatigue
           */
      Severity: Minor
      Found in Stamina/Stamina.php - About 2 hrs to fix

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

            public function calculateFilledHalfRowsFor($fatigueValue, FatigueBoundary $fatigueBoundary): int
            {
                $fatiguePerRowMaximum = $this->getFatiguePerRowMaximum($fatigueBoundary);
                if ($fatiguePerRowMaximum % 2 === 0) { // odd
                    $filledHalfRows = SumAndRound::floor($fatigueValue / ($fatiguePerRowMaximum / 2));
        Severity: Minor
        Found in Stamina/GridOfFatigue.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 createActivity has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function createActivity(string $usedProperty)
            {
                $activity = $this->mockery(PropertyBasedActivity::class);
                $activity->shouldReceive('usesStrength')
                    ->zeroOrMoreTimes()
        Severity: Minor
        Found in tests/Stamina/MalusFromFatigueTest.php - About 1 hr to fix

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

              public function I_can_rest(): void
              {
                  $fatigueBoundary = $this->createFatigueBoundary(7);
                  $stamina = $this->createStaminaToTest($fatigueBoundary);
                  self::assertSame(21, $stamina->getRemainingStaminaAmount($fatigueBoundary));
          Severity: Minor
          Found in tests/Stamina/StaminaTest.php - About 1 hr to fix

            Avoid too many return statements within this method.
            Open

                    return $activity;
            Severity: Major
            Found in tests/Stamina/MalusFromFatigueTest.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return PropertyCode::CHARISMA === $usedProperty;
              Severity: Major
              Found in tests/Stamina/MalusFromFatigueTest.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return PropertyCode::INTELLIGENCE === $usedProperty;
                Severity: Major
                Found in tests/Stamina/MalusFromFatigueTest.php - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language