garak/pokerino

View on GitHub

Showing 16 of 23 total issues

Function isPoint has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    public static function isPoint(array $cards): RankResult
    {
        $high = null;
        $kicker = null;
        // check if there's a three: in this case, we remove one card
Severity: Minor
Found in src/Rank/StraightRank.php - About 5 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 isPoint has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function isPoint(array $cards): RankResult
    {
        $high = null;
        $kicker = null;
        // check if there's a three: in this case, we remove one card
Severity: Major
Found in src/Rank/StraightRank.php - About 2 hrs to fix

    Function isPoint has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function isPoint(array $cards): RankResult
        {
            $counts = \array_count_values(self::getCardsSuits($cards));
            if (!\in_array(5, $counts, true)) {
                return new RankResult(false);
    Severity: Minor
    Found in src/Rank/RoyalFlushRank.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 isPoint has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function isPoint(array $cards): RankResult
        {
            $counts = \array_count_values(self::getCardsSuits($cards));
            if (!\in_array(5, $counts, true)) {
                return new RankResult(false);
    Severity: Minor
    Found in src/Rank/StraightFlushRank.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 straight has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        protected static function straight(array $cards): array
        {
            // check if there's a three: in this case, we remove one card
            $three = ThreeOfAKindRank::isPoint($cards);
            if ($three->isPoint()) {
    Severity: Minor
    Found in src/Rank/AbstractRank.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 isPoint has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function isPoint(array $cards): RankResult
        {
            $high = null;
            $kicker = null;
            $counts = \array_count_values(self::getCardsValues($cards));
    Severity: Minor
    Found in src/Rank/FullHouseRank.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 deal has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function deal(int $startingHandCount = 2, int $commonCount = 5): void
        {
            $cards = Card::getDeck(true);
            for ($i = 0; $i < $this->players->count(); ++$i) {
                $handCards = [];
    Severity: Minor
    Found in src/Game.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 isPoint has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function isPoint(array $cards): RankResult
        {
            $counts = \array_count_values(self::getCardsSuits($cards));
            if (!\in_array(5, $counts, true)) {
                return new RankResult(false);
    Severity: Minor
    Found in src/Rank/RoyalFlushRank.php - About 1 hr to fix

      Method straight has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected static function straight(array $cards): array
          {
              // check if there's a three: in this case, we remove one card
              $three = ThreeOfAKindRank::isPoint($cards);
              if ($three->isPoint()) {
      Severity: Minor
      Found in src/Rank/AbstractRank.php - About 1 hr to fix

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

            public static function isPoint(array $cards): RankResult
            {
                $counts = \array_count_values(self::getCardsSuits($cards));
                if (!\in_array(5, $counts, true)) {
                    return new RankResult(false);
        Severity: Minor
        Found in src/Rank/StraightFlushRank.php - About 1 hr to fix

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

              public static function isPoint(array $cards): RankResult
              {
                  $high = null;
                  $kicker = null;
                  $counts = \array_count_values(self::getCardsValues($cards));
          Severity: Minor
          Found in src/Rank/TwoPairRank.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

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

              public static function isPoint(array $cards): RankResult
              {
                  $high = null;
                  $kicker = null;
                  $counts = \array_count_values(self::getCardsSuits($cards));
          Severity: Minor
          Found in src/Rank/FlushRank.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

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

              public static function isPoint(array $cards): RankResult
              {
                  $high = null;
                  $kicker = null;
                  $counts = \array_count_values(self::getCardsValues($cards));
          Severity: Minor
          Found in src/Rank/ThreeOfAKindRank.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

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

              public static function isPoint(array $cards): RankResult
              {
                  $high = null;
                  $kicker = null;
                  $counts = \array_count_values(self::getCardsValues($cards));
          Severity: Minor
          Found in src/Rank/PairRank.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

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

              public static function isPoint(array $cards): RankResult
              {
                  $count = \array_count_values(self::getCardsValues($cards));
                  $high = null;
                  $kicker = null;
          Severity: Minor
          Found in src/Rank/FourOfAKindRank.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

          Consider simplifying this complex logical expression.
          Open

                  if (14 === $value && 2 === $first && 3 === \max($sequence, $maxSequence) && \in_array(5, $values, true) && \in_array(4, $values, true) && \in_array(3, $values, true)) {
                      foreach ($cards as $card) {
                          if (5 === $card->getRank()->getInt()) { // A, 2, 3, 4, 5
                              $high = $card;
                              break;
          Severity: Major
          Found in src/Rank/StraightRank.php - About 40 mins to fix
            Severity
            Category
            Status
            Source
            Language