Cysha/casino-holdem

View on GitHub

Showing 20 of 29 total issues

File Round.php has 428 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Cysha\Casino\Holdem\Game;

use Cysha\Casino\Cards\Contracts\CardResults;
Severity: Minor
Found in src/Game/Round.php - About 6 hrs to fix

    Round has 45 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Round
    {
        /**
         * @var Uuid
         */
    Severity: Minor
    Found in src/Game/Round.php - About 6 hrs to fix

      Method collectChipTotal has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function collectChipTotal(): ChipPotCollection
          {
              $allInActionsThisRound = $this->leftToAct()->filter(function (array $value) {
                  return $value['action'] === LeftToAct::ALLIN;
              });
      Severity: Major
      Found in src/Game/Round.php - About 2 hrs to fix

        Method toString has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function toString()
            {
                $message = null;
                switch ($this->action) {
                    case static::DEALT_RIVER:
        Severity: Minor
        Found in src/Game/Action.php - About 1 hr to fix

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

              public function toString()
              {
                  $message = null;
                  switch ($this->action) {
                      case static::DEALT_RIVER:
          Severity: Minor
          Found in src/Game/Action.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 evaluate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function evaluate(CardCollection $board, Hand $hand): CardResults
              {
                  $cards = $board->merge($hand->cards());
          
                  if (($result = static::royalFlush($cards)) !== false) {
          Severity: Minor
          Found in src/Cards/Evaluators/SevenCard.php - About 1 hr to fix

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

                private function distributeWinnings()
                {
                    $this->chipPots()
                        ->reverse()
                        ->each(function (ChipPot $chipPot) {
            Severity: Minor
            Found in src/Game/Round.php - About 1 hr to fix

              Function evaluate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function evaluate(CardCollection $board, Hand $hand): CardResults
                  {
                      $cards = $board->merge($hand->cards());
              
                      if (($result = static::royalFlush($cards)) !== false) {
              Severity: Minor
              Found in src/Cards/Evaluators/SevenCard.php - About 55 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

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

                  public function __construct(Uuid $gameId, Chips $bigBlind, Chips $smallBlind = null, int $tableSize = 9, Chips $minimumBuyIn, Chips $maximumBuyIn = null)
              Severity: Minor
              Found in src/Game/Parameters/CashGameParameters.php - About 45 mins to fix

                Avoid too many return statements within this method.
                Open

                        return $winningResults;
                Severity: Major
                Found in src/Cards/Evaluators/SevenCard.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                      return false;
                  Severity: Major
                  Found in src/Game/Round.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return SevenCardResult::createTwoPair($result, $hand);
                    Severity: Major
                    Found in src/Cards/Evaluators/SevenCard.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return SevenCardResult::createOnePair($result, $hand);
                      Severity: Major
                      Found in src/Cards/Evaluators/SevenCard.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return $chipPot->total()->amount() !== 0;
                        Severity: Major
                        Found in src/Game/Round.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return SevenCardResult::createFlush($result, $hand);
                          Severity: Major
                          Found in src/Cards/Evaluators/SevenCard.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    return $this->chipPots();
                            Severity: Major
                            Found in src/Game/Round.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return SevenCardResult::createStraight($result, $hand);
                              Severity: Major
                              Found in src/Cards/Evaluators/SevenCard.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                        return true;
                                Severity: Major
                                Found in src/Game/Round.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return SevenCardResult::createThreeOfAKind($result, $hand);
                                  Severity: Major
                                  Found in src/Cards/Evaluators/SevenCard.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return SevenCardResult::createHighCard(static::highCard($cards), $hand);
                                    Severity: Major
                                    Found in src/Cards/Evaluators/SevenCard.php - About 30 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language