prantlf/mau-mau

View on GitHub

Showing 15 of 31 total issues

Function constructor has 93 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  constructor(game) {
    super();

    let gameStarted = false,
        drawsTwo = null;
Severity: Major
Found in src/engine/misc/Reporter.js - About 3 hrs to fix

    Function chooseCard has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function chooseCard(player) {
      return new Promise((resolve, reject) => {
        var playableCards = this.game.rules.pickPlayableCards(player.hand),
            otherCards = player.hand
                .pickCards(function (card) {
    Severity: Major
    Found in src/node/console/ConsolePrompt.js - About 2 hrs to fix

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

      function suggestCard(availableCards, playableCards) {
        // Decomposition operation should not increase the statement count,
        // moving handling of sevens and aces to a separate method would
        // make the code less legible.
        /*eslint max-statements: [2, 20]*/
      Severity: Minor
      Found in src/engine/players/SmartComputer.js - 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 constructor has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        constructor() {
          super();
      
          var cards = [
            new Card(Suits.leaves, Ranks.seven),
      Severity: Minor
      Found in src/engine/cards/Deck.js - About 1 hr to fix

        Function suggestCard has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function suggestCard(availableCards, playableCards) {
          // Decomposition operation should not increase the statement count,
          // moving handling of sevens and aces to a separate method would
          // make the code less legible.
          /*eslint max-statements: [2, 20]*/
        Severity: Minor
        Found in src/engine/players/SmartComputer.js - About 1 hr to fix

          Function getSevenCoverCount has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function getSevenCoverCount(seven, availableCards) {
            var otherCards = availableCards.filter(function (card) {
                  return card !== seven;
                }),
                // Check if the seven can be covered by a card, which lets
          Severity: Minor
          Found in src/engine/players/SmartComputer.js - About 1 hr to fix

            Function getAceCoverCount has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function getAceCoverCount(ace, availableCards) {
              var otherCards = availableCards.filter(function (card) {
                    return card !== ace;
                  }),
                  // Check if the ace can be covered by a card, which lets
            Severity: Minor
            Found in src/engine/players/SmartComputer.js - About 1 hr to fix

              Function suggestSuit has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function suggestSuit(chosenCard, availableCards) {
                // Cards remaining in hand after playing the queen
                var otherCards = availableCards.filter(function (card) {
                      return card !== chosenCard.card;
                    }),
              Severity: Minor
              Found in src/engine/players/SmartComputer.js - About 1 hr to fix

                Function getSevenCoverCount has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                function getSevenCoverCount(seven, availableCards) {
                  var otherCards = availableCards.filter(function (card) {
                        return card !== seven;
                      }),
                      // Check if the seven can be covered by a card, which lets
                Severity: Minor
                Found in src/engine/players/SmartComputer.js - About 45 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 removeListener has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function removeListener(event, listener, listeners, index, once, onceIndex) {
                Severity: Minor
                Found in src/engine/misc/EventEmitter.js - About 45 mins to fix

                  Function getAceCoverCount has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function getAceCoverCount(ace, availableCards) {
                    var otherCards = availableCards.filter(function (card) {
                          return card !== ace;
                        }),
                        // Check if the ace can be covered by a card, which lets
                  Severity: Minor
                  Found in src/engine/players/SmartComputer.js - About 45 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 letTopCardAffectPlayer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function letTopCardAffectPlayer() {
                    var topCard = checkNewTopCard.call(this);
                    // The top card on the playing stack affects the current
                    // player only once, first when it turns up there
                    if (topCard) {
                  Severity: Minor
                  Found in src/engine/game/Rules.js - About 35 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 parseHumanIndex has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function parseHumanIndex(human, playerCount) {
                    if (human === 'random') {
                      return 1 + Math.trunc(Math.random() * playerCount);
                    }
                    if (human != null) {
                  Severity: Minor
                  Found in src/engine/game/Organizer.js - About 35 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 setLocaleSafely has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    setLocaleSafely(locale) {
                      var parsedLocale = /^[a-zA-Z]+/.exec(locale);
                      if (parsedLocale) {
                        parsedLocale = parsedLocale[0];
                        if (parsedLocale !== 'en') {
                  Severity: Minor
                  Found in src/engine/misc/i18n.js - About 35 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 suggestCard has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function suggestCard(availableCards, playableCards) {
                    // No playable card found will mean drawing a new one
                    if (!playableCards.length) {
                      return;
                    }
                  Severity: Minor
                  Found in src/engine/players/AverageComputer.js - About 35 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

                  Severity
                  Category
                  Status
                  Source
                  Language