jcbantuelle/dominion-meteor

View on GitHub

Showing 1,158 of 1,158 total issues

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

  static trash_card(game, player_cards, selected_cards) {
    if (_.size(selected_cards) === 0) {
      game.log.push(`  but does not trash a card`)
    } else {
      let card_trasher = new CardTrasher(game, player_cards, 'hand', selected_cards)
Severity: Major
Found in app/cards/nocturne/boons/the_flames_gift.js and 7 other locations - About 2 hrs to fix
app/cards/adventures/events/bonfire.js on lines 27..34
app/cards/base/chapel.js on lines 31..38
app/cards/common/silver.js on lines 51..58
app/cards/intrigue/masquerade.js on lines 75..82
app/cards/menagerie/goatherd.js on lines 41..48
app/cards/nocturne/cemetery.js on lines 35..42
app/cards/nocturne/goat.js on lines 34..41

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 78.

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 8 locations. Consider refactoring.
Open

  static trash_cards(game, player_cards, selected_cards) {
    if (_.size(selected_cards) === 0) {
      game.log.push(`  but does not trash anything`)
    } else {
      let card_trasher = new CardTrasher(game, player_cards, 'hand', selected_cards)
Severity: Major
Found in app/cards/common/silver.js and 7 other locations - About 2 hrs to fix
app/cards/adventures/events/bonfire.js on lines 27..34
app/cards/base/chapel.js on lines 31..38
app/cards/intrigue/masquerade.js on lines 75..82
app/cards/menagerie/goatherd.js on lines 41..48
app/cards/nocturne/boons/the_flames_gift.js on lines 23..30
app/cards/nocturne/cemetery.js on lines 35..42
app/cards/nocturne/goat.js on lines 34..41

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 78.

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 8 locations. Consider refactoring.
Open

  static trash_cards(game, player_cards, selected_cards) {
    if (_.size(selected_cards) === 0) {
      game.log.push(`  but does not trash anything`)
    } else {
      let card_trasher = new CardTrasher(game, player_cards, 'hand', selected_cards)
Severity: Major
Found in app/cards/intrigue/masquerade.js and 7 other locations - About 2 hrs to fix
app/cards/adventures/events/bonfire.js on lines 27..34
app/cards/base/chapel.js on lines 31..38
app/cards/common/silver.js on lines 51..58
app/cards/menagerie/goatherd.js on lines 41..48
app/cards/nocturne/boons/the_flames_gift.js on lines 23..30
app/cards/nocturne/cemetery.js on lines 35..42
app/cards/nocturne/goat.js on lines 34..41

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 78.

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 8 locations. Consider refactoring.
Open

  static trash_card(game, player_cards, selected_cards) {
    if (_.size(selected_cards) === 0) {
      game.log.push(`  but does not trash anything`)
    } else {
      let card_trasher = new CardTrasher(game, player_cards, 'hand', selected_cards)
Severity: Major
Found in app/cards/nocturne/goat.js and 7 other locations - About 2 hrs to fix
app/cards/adventures/events/bonfire.js on lines 27..34
app/cards/base/chapel.js on lines 31..38
app/cards/common/silver.js on lines 51..58
app/cards/intrigue/masquerade.js on lines 75..82
app/cards/menagerie/goatherd.js on lines 41..48
app/cards/nocturne/boons/the_flames_gift.js on lines 23..30
app/cards/nocturne/cemetery.js on lines 35..42

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 78.

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 8 locations. Consider refactoring.
Open

  static trash_cards(game, player_cards, selected_cards) {
    if (_.size(selected_cards) === 0) {
      game.log.push(`  but does not trash anything`)
    } else {
      let card_trasher = new CardTrasher(game, player_cards, 'in_play', selected_cards)
Severity: Major
Found in app/cards/adventures/events/bonfire.js and 7 other locations - About 2 hrs to fix
app/cards/base/chapel.js on lines 31..38
app/cards/common/silver.js on lines 51..58
app/cards/intrigue/masquerade.js on lines 75..82
app/cards/menagerie/goatherd.js on lines 41..48
app/cards/nocturne/boons/the_flames_gift.js on lines 23..30
app/cards/nocturne/cemetery.js on lines 35..42
app/cards/nocturne/goat.js on lines 34..41

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 78.

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

  static trash_card(game, player_cards, selected_cards) {
    let victory_tokens = CostCalculator.calculate(game, selected_cards[0])

    let card_trasher = new CardTrasher(game, player_cards, 'hand', selected_cards)
    card_trasher.trash()
Severity: Major
Found in app/cards/empires/events/ritual.js and 1 other location - About 2 hrs to fix
app/cards/renaissance/recruiter.js on lines 38..46

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 78.

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 (this.buyer.game_card.embargos > 0) {
      let embargo = ClassCreator.create('Embargo').to_h()
      embargo.id = this.generate_event_id()
      this.buy_events.push(embargo)
    }
Severity: Major
Found in app/game/server/services/buy_event_processor.js and 1 other location - About 2 hrs to fix
app/game/server/services/buy_event_processor.js on lines 105..109

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 78.

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

  static trash_card(game, player_cards, selected_cards) {
    let coin_cost = CostCalculator.calculate(game, selected_cards[0])

    let card_trasher = new CardTrasher(game, player_cards, 'hand', selected_cards)
    card_trasher.trash()
Severity: Major
Found in app/cards/renaissance/recruiter.js and 1 other location - About 2 hrs to fix
app/cards/empires/events/ritual.js on lines 36..44

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 78.

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 (this.buyer.game_card.debt_tokens > 0) {
      let tax = ClassCreator.create('Tax').to_h()
      tax.id = this.generate_event_id()
      this.buy_events.push(tax)
    }
Severity: Major
Found in app/game/server/services/buy_event_processor.js and 1 other location - About 2 hrs to fix
app/game/server/services/buy_event_processor.js on lines 93..97

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 78.

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 process_response has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static process_response(game, player_cards, response, card_player) {
    if (response[0] === 'discard') {
      if (_.size(player_cards.hand) > 2) {
        let turn_event_id = TurnEventModel.insert({
          game_id: game._id,
Severity: Major
Found in app/cards/dark_ages/count.js - About 2 hrs to fix

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

        if (_.includes(_.words(last_revealed.types), 'action') || _.includes(_.words(last_revealed.types), 'treasure')) {
          let card_mover = new CardMover(game, player_cards)
          card_mover.move(player_cards.revealed, player_cards.hand, last_revealed)
          game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> puts ${CardView.render(last_revealed)} in their hand`)
        } else {
    Severity: Major
    Found in app/cards/cornucopia/farming_village.js and 5 other locations - About 2 hrs to fix
    app/cards/adventures/miser.js on lines 38..44
    app/cards/cornucopia/fortune_teller.js on lines 34..40
    app/cards/cornucopia/hunting_party.js on lines 30..34
    app/cards/dark_ages/sage.js on lines 25..31
    app/cards/empires/chariot_race.js on lines 22..26

    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 77.

    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 6 locations. Consider refactoring.
    Open

          if (copper) {
            let card_mover = new CardMover(game, player_cards)
            card_mover.move(player_cards.hand, player_cards.tavern, copper)
            game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> puts ${CardView.render(copper)} on their Tavern`)
          } else {
    Severity: Major
    Found in app/cards/adventures/miser.js and 5 other locations - About 2 hrs to fix
    app/cards/cornucopia/farming_village.js on lines 25..31
    app/cards/cornucopia/fortune_teller.js on lines 34..40
    app/cards/cornucopia/hunting_party.js on lines 30..34
    app/cards/dark_ages/sage.js on lines 25..31
    app/cards/empires/chariot_race.js on lines 22..26

    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 77.

    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 6 locations. Consider refactoring.
    Open

        if (CardCostComparer.coin_greater_than(game, last_revealed, 2)) {
          let card_mover = new CardMover(game, player_cards)
          card_mover.move(player_cards.revealed, player_cards.hand, last_revealed)
          game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> puts ${CardView.render(last_revealed)} in their hand`)
        } else {
    Severity: Major
    Found in app/cards/dark_ages/sage.js and 5 other locations - About 2 hrs to fix
    app/cards/adventures/miser.js on lines 38..44
    app/cards/cornucopia/farming_village.js on lines 25..31
    app/cards/cornucopia/fortune_teller.js on lines 34..40
    app/cards/cornucopia/hunting_party.js on lines 30..34
    app/cards/empires/chariot_race.js on lines 22..26

    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 77.

    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 6 locations. Consider refactoring.
    Open

        if (!_.includes(_.map(player_cards.hand, 'name'), last_revealed.name)) {
          let card_mover = new CardMover(game, player_cards)
          card_mover.move(player_cards.revealed, player_cards.hand, last_revealed)
          game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> puts ${CardView.render(last_revealed)} in their hand`)
        }
    Severity: Major
    Found in app/cards/cornucopia/hunting_party.js and 5 other locations - About 2 hrs to fix
    app/cards/adventures/miser.js on lines 38..44
    app/cards/cornucopia/farming_village.js on lines 25..31
    app/cards/cornucopia/fortune_teller.js on lines 34..40
    app/cards/dark_ages/sage.js on lines 25..31
    app/cards/empires/chariot_race.js on lines 22..26

    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 77.

    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 6 locations. Consider refactoring.
    Open

        if (_.includes(_.words(last_revealed.types), 'victory') || last_revealed.name === 'Curse') {
          let card_mover = new CardMover(game, player_cards)
          card_mover.move(player_cards.revealed, player_cards.deck, last_revealed)
          game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> puts ${CardView.render(last_revealed)} on top of their deck`)
        } else {
    Severity: Major
    Found in app/cards/cornucopia/fortune_teller.js and 5 other locations - About 2 hrs to fix
    app/cards/adventures/miser.js on lines 38..44
    app/cards/cornucopia/farming_village.js on lines 25..31
    app/cards/cornucopia/hunting_party.js on lines 30..34
    app/cards/dark_ages/sage.js on lines 25..31
    app/cards/empires/chariot_race.js on lines 22..26

    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 77.

    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 6 locations. Consider refactoring.
    Open

        if (current_player_card) {
          let card_mover = new CardMover(game, player_cards)
          card_mover.move(player_cards.revealed, player_cards.hand, current_player_card)
          game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> puts ${CardView.render(current_player_card)} in hand`)
        }
    Severity: Major
    Found in app/cards/empires/chariot_race.js and 5 other locations - About 2 hrs to fix
    app/cards/adventures/miser.js on lines 38..44
    app/cards/cornucopia/farming_village.js on lines 25..31
    app/cards/cornucopia/fortune_teller.js on lines 34..40
    app/cards/cornucopia/hunting_party.js on lines 30..34
    app/cards/dark_ages/sage.js on lines 25..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 77.

    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

      static remove(game_id, player_id) {
        if (game_id) {
          if (player_id) {
            this.data_source(game_id).delete(player_id)
          } else {
    Severity: Major
    Found in lib/server/models/player_cards_model.js and 1 other location - About 2 hrs to fix
    lib/server/models/turn_event_model.js on lines 32..42

    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 77.

    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

      static remove(game_id, turn_event_id) {
        if (game_id) {
          if (turn_event_id) {
            this.data_source(game_id).delete(turn_event_id)
          } else {
    Severity: Major
    Found in lib/server/models/turn_event_model.js and 1 other location - About 2 hrs to fix
    lib/server/models/player_cards_model.js on lines 25..35

    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 77.

    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 gain has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      gain(amount, announce = true) {
        if (this.card_player && this.card_player.chameleon) {
          let card_drawer = new CardDrawer(this.game, this.player_cards)
          card_drawer.draw(amount)
        } else {
    Severity: Minor
    Found in app/game/server/services/coin_gainer.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 process_response has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      static process_response(game, player_cards, response, card_player) {
        let wild_hunt_index = _.findIndex(game.cards, (card) => {
          return card.name === 'Wild Hunt'
        })
    
    
    Severity: Minor
    Found in app/cards/empires/wild_hunt.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

    Severity
    Category
    Status
    Source
    Language