jcbantuelle/dominion-meteor

View on GitHub

Showing 1,158 of 1,158 total issues

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

        if (this.game.turn.phase === 'action') {
          this.game.turn.phase = 'treasure'
          let start_buy_event_processor = new StartBuyEventProcessor(this.game, this.player_cards)
          start_buy_event_processor.process()
        }
Severity: Major
Found in app/game/server/services/card_player.js and 2 other locations - About 1 hr to fix
app/game/server/services/coffer_player.js on lines 21..25
app/game/server/services/lib/card_buyer.js on lines 31..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 72.

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

    _.each(this.trasher.player_cards.hand, (card) => {
      if (_.includes(TrashEventProcessor.reaction_cards(), card.name)) {
        this.trash_events.push(card)
      }
    })
Severity: Major
Found in app/game/server/services/trash_event_processor.js and 2 other locations - About 1 hr to fix
app/game/server/services/buy_event_processor.js on lines 87..91
app/game/server/services/trash_event_processor.js on lines 32..36

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

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

Platinum = class Platinum extends Card {

  types() {
    return ['treasure']
  }
Severity: Major
Found in app/cards/prosperity/platinum.js and 2 other locations - About 1 hr to fix
app/cards/promo/stash.js on lines 1..16
app/cards/prosperity/quarry.js on lines 1..16

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

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

Necropolis = class Necropolis extends Card {

  types() {
    return ['action', 'shelter']
  }
Severity: Major
Found in app/cards/dark_ages/necropolis.js and 1 other location - About 1 hr to fix
app/cards/cornucopia/princess.js on lines 1..16

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

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

WayOfTheMonkey = class WayOfTheMonkey extends Way {

  play(game, player_cards, card_player) {
    let buy_gainer = new BuyGainer(game, player_cards)
    buy_gainer.gain(1)
Severity: Major
Found in app/cards/menagerie/ways/way_of_the_monkey.js and 1 other location - About 1 hr to fix
app/cards/menagerie/ways/way_of_the_mule.js on lines 1..11

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

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

      if (this.game.turn.phase === 'action') {
        this.game.turn.phase = 'treasure'
        let start_buy_event_processor = new StartBuyEventProcessor(this.game, this.player_cards)
        start_buy_event_processor.process()
      }
Severity: Major
Found in app/game/server/services/lib/card_buyer.js and 2 other locations - About 1 hr to fix
app/game/server/services/card_player.js on lines 134..138
app/game/server/services/coffer_player.js on lines 21..25

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

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

  find_start_turn_events() {
    this.start_turn_events = []

    _.each(this.player_cards.aside, (card) => {
      if (_.includes(StartTurnEventProcessor.aside_events(), card.name)) {
Severity: Minor
Found in app/game/server/services/start_turn_event_processor.js - About 1 hr to fix

    Function end_turn has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      end_turn() {
        this.game.previous_state = false
        if (this.game.turn.phase === 'action') {
          this.start_buy_events()
        }
    Severity: Minor
    Found in app/game/server/services/turn_ender.js - About 1 hr to fix

      Function process_choice has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static process_choice(game, player_cards, choice) {
          if (choice[0] === 'gain') {
            let eligible_cards = _.filter(game.trash, (card) => {
              return _.includes(_.words(card.types), 'action')
            })
      Severity: Minor
      Found in app/cards/intrigue/lurker.js - About 1 hr to fix

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

          play(game, player_cards, card_player) {
            let turn_event_id = TurnEventModel.insert({
              game_id: game._id,
              player_id: player_cards.player_id,
              username: player_cards.username,
        Severity: Minor
        Found in app/cards/menagerie/ways/way_of_the_butterfly.js - About 1 hr to fix

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

            play(game, player_cards, card_player) {
              let coin_gainer = new CoinGainer(game, player_cards, card_player)
              coin_gainer.gain(1)
          
              let victory_token_gainer = new VictoryTokenGainer(game, player_cards)
          Severity: Minor
          Found in app/cards/prosperity/bishop.js - About 1 hr to fix

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

              play(game, player_cards, card_player) {
                let coin_gainer = new CoinGainer(game, player_cards, card_player)
                coin_gainer.gain(2)
            
                let black_market_card_buyer = new BlackMarketCardBuyer(game, player_cards)
            Severity: Minor
            Found in app/cards/promo/black_market.js - About 1 hr to fix

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

                play(game, player_cards) {
                  let eligible_cards = _.filter(player_cards.hand, function(card) {
                    return _.includes(_.words(card.types), 'treasure')
                  })
                  if (_.size(eligible_cards) > 0) {
              Severity: Minor
              Found in app/cards/guilds/taxman.js - About 1 hr to fix

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

                    let eligible_cards = _.filter(trasher.game.cards, function(card) {
                      return card.count > 0 && card.supply && CardCostComparer.card_less_than(trasher.game, catacombs, card.top_card)
                    })
                Severity: Major
                Found in app/cards/dark_ages/catacombs.js and 1 other location - About 1 hr to fix
                app/cards/hinterlands/border_village.js on lines 20..22

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

                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 eligible_cards = _.filter(gainer.game.cards, function(card) {
                      return card.count > 0 && card.supply && CardCostComparer.card_less_than(gainer.game, border_village, card.top_card)
                    })
                Severity: Major
                Found in app/cards/hinterlands/border_village.js and 1 other location - About 1 hr to fix
                app/cards/dark_ages/catacombs.js on lines 51..53

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

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

                  static gain_event(game, player_cards, selected_cards, gain_event_processor) {
                    if (!_.isEmpty(selected_cards)) {
                      let card = selected_cards[0]
                      if (card.name === 'Exile') {
                        let exiled_copies = _.filter(player_cards.exile, (card) => {
                Severity: Minor
                Found in app/game/server/services/gain_event_processor.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

                Function playCard has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                  playCard: function(card_id, game_id) {
                    Future.task(Meteor.bindEnvironment(function() {
                      if (!ActionLock[game_id]) {
                        ActionLock[game_id] = true
                        let current_game = game(game_id)
                Severity: Minor
                Found in app/game/server/game.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

                Function receive has a Cognitive Complexity of 14 (exceeds 5 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

                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 14 (exceeds 5 allowed). Consider refactoring.
                Open

                  static process_response(game, player_cards, response) {
                    response = response[0]
                    if (response === 'attack') {
                      let attacks = _.filter(player_cards.hand, function(card) {
                        return _.includes(_.words(card.types), 'attack')
                Severity: Minor
                Found in app/cards/adventures/events/quest.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

                Function process_response has a Cognitive Complexity of 14 (exceeds 5 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: Minor
                Found in app/cards/dark_ages/count.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