prantlf/mau-mau

View on GitHub

Showing 31 of 31 total issues

Similar blocks of code found in 2 locations. 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: Major
Found in src/engine/players/SmartComputer.js and 1 other location - About 2 days to fix
src/engine/players/SmartComputer.js on lines 186..227

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 369.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. 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: Major
Found in src/engine/players/SmartComputer.js and 1 other location - About 2 days to fix
src/engine/players/SmartComputer.js on lines 240..281

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 369.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

function divideCardRanks(playableCards) {
  var queens = [], sevens = [], aces = [],
      otherCards = playableCards.filter(function (card) {
        switch (card.rank) {
        case Ranks.queen:
Severity: Major
Found in src/engine/players/SmartComputer.js and 1 other location - About 5 hrs to fix
src/engine/players/AverageComputer.js on lines 98..115

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 149.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

function divideCardRanks(playableCards) {
  var queens = [], sevens = [], aces = [],
      otherCards = playableCards.filter(function (card) {
        switch (card.rank) {
        case Ranks.queen:
Severity: Major
Found in src/engine/players/AverageComputer.js and 1 other location - About 5 hrs to fix
src/engine/players/SmartComputer.js on lines 148..165

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 149.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

class PoorComputer extends Computer {

  chooseCard() {
    var availableCards = this.hand.pickCards(),
        playableCards = this.game.rules.pickPlayableCards(this.hand),
Severity: Major
Found in src/engine/players/PoorComputer.js and 1 other location - About 5 hrs to fix
src/engine/players/AverageComputer.js on lines 11..31

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 144.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

class AverageComputer extends Computer {

  chooseCard() {
    var availableCards = this.hand.pickCards(),
        playableCards = this.game.rules.pickPlayableCards(this.hand),
Severity: Major
Found in src/engine/players/AverageComputer.js and 1 other location - About 5 hrs to fix
src/engine/players/PoorComputer.js on lines 8..28

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 144.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

          nextChosenCard = nextChosenCards.find(function (card) {
            return card.rank === Ranks.seven;
          }) || nextChosenCards.find(function (card) {
            return card.rank === Ranks.ace;
          }) || nextChosenCards.find(function (card) {
    Severity: Major
    Found in src/engine/players/AverageComputer.js and 1 other location - About 3 hrs to fix
    src/engine/players/SmartComputer.js on lines 135..144

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 108.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

          nextChosenCard = nextChosenCards.find(function (card) {
            return card.rank === Ranks.seven;
          }) || nextChosenCards.find(function (card) {
            return card.rank === Ranks.ace;
          }) || nextChosenCards.find(function (card) {
    Severity: Major
    Found in src/engine/players/SmartComputer.js and 1 other location - About 3 hrs to fix
    src/engine/players/AverageComputer.js on lines 85..94

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 108.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        if (!chosenCard.card && aces.length) {
          chosenCard = getMaximumCoveredAce.call(this, aces, availableCards);
          // If there are just two players, avoid an immediate drawing a single
          // card to let the other player play; do not worry with more players
          if (!chosenCard.card && this.game.activePlayers.length > 2) {
      Severity: Major
      Found in src/engine/players/SmartComputer.js and 1 other location - About 2 hrs to fix
      src/engine/players/SmartComputer.js on lines 59..69

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 75.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        if (sevens.length) {
          chosenCard = getMaximumCoveredSeven.call(this, sevens, availableCards);
          // If there are just two players, avoid "being fed back" two cards
          // by another seven placed on ours; do not worry with more players
          if (!chosenCard.card && this.game.activePlayers.length > 2) {
      Severity: Major
      Found in src/engine/players/SmartComputer.js and 1 other location - About 2 hrs to fix
      src/engine/players/SmartComputer.js on lines 72..82

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 75.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        function getMaximumCoveredAce(aces, availableCards) {
          // Compute which ace can help us shed the maximum card count
          var covers = aces.map(ace => {
            return {
              card: ace,
        Severity: Major
        Found in src/engine/players/SmartComputer.js and 1 other location - About 1 hr to fix
        src/engine/players/SmartComputer.js on lines 175..184

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 64.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        function getMaximumCoveredSeven(sevens, availableCards) {
          // Compute which seven can help us shed the maximum card count
          var covers = sevens.map(seven => {
            return {
              card: seven,
        Severity: Major
        Found in src/engine/players/SmartComputer.js and 1 other location - About 1 hr to fix
        src/engine/players/SmartComputer.js on lines 229..238

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 64.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                nextChosenCards = Object.keys(Suits)
                  .map(suit => {
                    var playableCards = this.game.rules.pickPlayableCardsForSuit(
                          otherCards, suit);
                    return suggestCard.call(this, otherCards, playableCards);
          Severity: Major
          Found in src/engine/players/AverageComputer.js and 1 other location - About 1 hr to fix
          src/engine/players/SmartComputer.js on lines 117..122

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 60.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                nextChosenCardsPerSuit = Object.keys(Suits)
                  .map(suit => {
                    var playableCards = this.game.rules.pickPlayableCardsForSuit(
                          otherCards, suit);
                    return suggestCard.call(this, otherCards, playableCards);
          Severity: Major
          Found in src/engine/players/SmartComputer.js and 1 other location - About 1 hr to fix
          src/engine/players/AverageComputer.js on lines 75..80

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 60.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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
            Severity
            Category
            Status
            Source
            Language