jcbantuelle/dominion-meteor

View on GitHub

Showing 1,158 of 1,158 total issues

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

      if (CardCostComparer.coin_less_than(game, player_cards.revealed[0], 3)) {
        game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> puts ${CardView.render(player_cards.revealed)} in their hand`)
        card_mover.move_all(player_cards.revealed, player_cards.hand)
      } else {
        card_mover.move_all(player_cards.revealed, player_cards.deck)
Severity: Major
Found in app/cards/nocturne/will_o_wisp.js and 2 other locations - About 1 hr to fix
app/cards/adventures/magpie.js on lines 26..31
app/cards/dark_ages/vagrant.js on lines 26..32

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

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

    _.each(this.player_cards.artifacts, (card) => {
      if (_.includes(StartTurnEventProcessor.artifact_events(), card.name)) {
        this.start_turn_events.push(card)
      }
    })
Severity: Major
Found in app/game/server/services/start_turn_event_processor.js and 3 other locations - About 1 hr to fix
app/game/server/services/start_cleanup_event_processor.js on lines 24..28
app/game/server/services/start_turn_event_processor.js on lines 67..71
app/game/server/services/start_turn_event_processor.js on lines 79..83

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

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

    let eligible_cards = _.filter(game.cards, function(card) {
      return card.count > 0 && card.supply && CardCostComparer.card_less_than(game, selected_cards[0], card.top_card, 2)
    })
Severity: Major
Found in app/cards/adventures/transmogrify.js and 3 other locations - About 1 hr to fix
app/cards/intrigue/replace.js on lines 42..44
app/cards/intrigue/upgrade.js on lines 44..46
app/cards/menagerie/events/enhance.js on lines 28..30

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

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

    _.each(this.player_cards.aside, (card) => {
      if (_.includes(StartCleanupEventProcessor.aside_events(), card.name)) {
        this.start_cleanup_events.push(card)
      }
    })
Severity: Major
Found in app/game/server/services/start_cleanup_event_processor.js and 3 other locations - About 1 hr to fix
app/game/server/services/start_turn_event_processor.js on lines 67..71
app/game/server/services/start_turn_event_processor.js on lines 73..77
app/game/server/services/start_turn_event_processor.js on lines 79..83

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

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

    let eligible_cards = _.filter(game.cards, function(card) {
      return card.count > 0 && card.supply && CardCostComparer.card_equal_to(game, selected_cards[0], card.top_card, 1)
    })
Severity: Major
Found in app/cards/intrigue/upgrade.js and 3 other locations - About 1 hr to fix
app/cards/adventures/transmogrify.js on lines 59..61
app/cards/intrigue/replace.js on lines 42..44
app/cards/menagerie/events/enhance.js on lines 28..30

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

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

    _.each(this.player_cards.projects, (card) => {
      if (_.includes(StartTurnEventProcessor.project_events(), card.name)) {
        this.start_turn_events.push(card)
      }
    })
Severity: Major
Found in app/game/server/services/start_turn_event_processor.js and 3 other locations - About 1 hr to fix
app/game/server/services/start_cleanup_event_processor.js on lines 24..28
app/game/server/services/start_turn_event_processor.js on lines 67..71
app/game/server/services/start_turn_event_processor.js on lines 73..77

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

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

    _.each(this.player_cards.states, (card) => {
      if (_.includes(StartTurnEventProcessor.state_events(), card.name)) {
        this.start_turn_events.push(card)
      }
    })
Severity: Major
Found in app/game/server/services/start_turn_event_processor.js and 3 other locations - About 1 hr to fix
app/game/server/services/start_cleanup_event_processor.js on lines 24..28
app/game/server/services/start_turn_event_processor.js on lines 73..77
app/game/server/services/start_turn_event_processor.js on lines 79..83

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

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

    let eligible_cards = _.filter(game.cards, function(card) {
      return card.count > 0 && card.supply && CardCostComparer.card_less_than(game, selected_cards[0], card.top_card, 3)
    })
Severity: Major
Found in app/cards/intrigue/replace.js and 3 other locations - About 1 hr to fix
app/cards/adventures/transmogrify.js on lines 59..61
app/cards/intrigue/upgrade.js on lines 44..46
app/cards/menagerie/events/enhance.js on lines 28..30

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

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

        let eligible_cards = _.filter(game.cards, function(card) {
          return card.count > 0 && card.supply && CardCostComparer.card_less_than(game, trashed_card[0], card.top_card, 3)
        })
Severity: Major
Found in app/cards/menagerie/events/enhance.js and 3 other locations - About 1 hr to fix
app/cards/adventures/transmogrify.js on lines 59..61
app/cards/intrigue/replace.js on lines 42..44
app/cards/intrigue/upgrade.js on lines 44..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 68.

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

    let turn_event_id = TurnEventModel.insert({
      game_id: game._id,
      player_id: player_cards.player_id,
      username: player_cards.username,
      type: 'choose_yes_no',
Severity: Major
Found in app/cards/menagerie/hunting_lodge.js and 1 other location - About 1 hr to fix
app/cards/renaissance/projects/pageant.js on lines 10..18

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

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

      let turn_event_id = TurnEventModel.insert({
        game_id: game._id,
        player_id: player_cards.player_id,
        username: player_cards.username,
        type: 'choose_yes_no',
Severity: Major
Found in app/cards/renaissance/projects/pageant.js and 1 other location - About 1 hr to fix
app/cards/menagerie/hunting_lodge.js on lines 21..29

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

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

  play(game, player_cards, card_player) {
    let card_drawer = new CardDrawer(game, player_cards, card_player)
    card_drawer.draw(2)

    GameModel.update(game._id, game)
Severity: Minor
Found in app/cards/prosperity/vault.js - About 1 hr to fix

    Function play has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      play(game, player_cards) {
        if (_.size(player_cards.hand) > 1) {
          let turn_event_id = TurnEventModel.insert({
            game_id: game._id,
            player_id: player_cards.player_id,
    Severity: Minor
    Found in app/cards/dark_ages/altar.js - About 1 hr to fix

      Function play has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        play(game, player_cards, card_player) {
          let action_gainer = new ActionGainer(game, player_cards)
          action_gainer.gain(1)
      
          let trashed_cards = []
      Severity: Minor
      Found in app/cards/renaissance/research.js - About 1 hr to fix

        Function receive has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          receive(game, player_cards) {
            if (_.size(player_cards.deck) === 0 && _.size(player_cards.discard) === 0) {
              game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> has no cards in deck`)
            } else {
              if (_.size(player_cards.deck) === 0) {
        Severity: Minor
        Found in app/cards/nocturne/hexes/locusts.js - About 1 hr to fix

          Function play has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            play(game, player_cards, card_player) {
              let card_drawer = new CardDrawer(game, player_cards, card_player)
              card_drawer.draw(1)
          
              let action_gainer = new ActionGainer(game, player_cards)
          Severity: Minor
          Found in app/cards/cornucopia/hamlet.js - About 1 hr to fix

            Function play has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              play(game, player_cards) {
                if (_.size(player_cards.deck) === 0 && _.size(player_cards.discard) === 0) {
                  game.log.push(`&nbsp;&nbsp;but there are no cards in their deck`)
                } else {
                  let card_revealer = new CardRevealer(game, player_cards)
            Severity: Minor
            Found in app/cards/alchemy/golem.js - About 1 hr to fix

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

              Guildhall = class Guildhall extends Project {
              
                coin_cost() {
                  return 5
                }
              Severity: Major
              Found in app/cards/renaissance/projects/guildhall.js and 1 other location - About 1 hr to fix
              app/cards/renaissance/projects/academy.js on lines 1..12

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

              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

              Academy = class Academy extends Project {
              
                coin_cost() {
                  return 5
                }
              Severity: Major
              Found in app/cards/renaissance/projects/academy.js and 1 other location - About 1 hr to fix
              app/cards/renaissance/projects/guildhall.js on lines 1..12

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

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

                play_card(announce, free_play) {
                  let play_result
                  this.token_effects()
                  if (_.includes(_.words(this.card.types), 'action') && this.game.turn.player._id === this.player_cards.player_id) {
                    this.game.turn.played_actions.push(this.card)
              Severity: Minor
              Found in app/game/server/services/card_player.js - 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

              Severity
              Category
              Status
              Source
              Language