jcbantuelle/dominion-meteor

View on GitHub

Showing 1,158 of 1,158 total issues

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

      this.game.log.push(`<strong>${this.player_cards.username}</strong> puts ${CardView.render(this.player_cards.possession_trash)} in their discard`)
Severity: Major
Found in app/game/server/services/turn_ender.js and 1 other location - About 1 hr to fix
app/game/server/services/supply_card_exiler.js on lines 25..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 56.

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 26 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/nocturne/secret_cave.js - About 1 hr to fix

    Function play has 26 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/cornucopia/young_witch.js - About 1 hr to fix

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

        play(game, player_cards, card_player) {
          let buy_gainer = new BuyGainer(game, player_cards)
          buy_gainer.gain(1)
      
          let coin_gainer = new CoinGainer(game, player_cards, card_player)
      Severity: Minor
      Found in app/cards/cornucopia/horse_traders.js - About 1 hr to fix

        Function star_chart has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          star_chart() {
            this.star_chart_card = _.find(this.player_cards.projects, (project) => {
              return project.name === 'Star Chart'
            })
            if (this.star_chart_card) {
        Severity: Minor
        Found in app/game/server/services/deck_shuffler.js - About 1 hr to fix

          Function discard has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            discard(announce = true) {
              if (!_.isEmpty(this.cards)) {
                let ordered_discard = this.has_events() || this.has_schemes()
                if (_.size(this.cards) > 1 && ordered_discard) {
                  let turn_event_id = TurnEventModel.insert({
          Severity: Minor
          Found in app/game/server/services/card_discarder.js - About 1 hr to fix

            Function play has 26 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)
            
                let action_gainer = new ActionGainer(game, player_cards)
            Severity: Minor
            Found in app/cards/empires/encampment.js - About 1 hr to fix

              Function trash_card has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                static trash_card(game, player_cards, selected_cards) {
                  let eligible_cards = _.filter(game.cards, (card) => {
                    return card.count > 0 && card.supply && CardCostComparer.card_less_than(game, selected_cards[0], card.top_card, 4)
                  })
              
              
              Severity: Minor
              Found in app/cards/dark_ages/graverobber.js - About 1 hr to fix

                Function pay_tokens has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  static pay_tokens(game, player_cards, amount, trashed_card) {
                    amount = Number(amount)
                    let coffer_text = amount === 1 ? 'Coffer' : 'Coffers'
                    game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> removes ${amount} ${coffer_text}`)
                    player_cards.coffers -= amount
                Severity: Minor
                Found in app/cards/guilds/butcher.js - About 1 hr to fix

                  Function play has 26 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)
                  
                      let action_gainer = new ActionGainer(game, player_cards)
                  Severity: Minor
                  Found in app/cards/hinterlands/inn.js - About 1 hr to fix

                    Function play has 26 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 card_trasher = new CardTrasher(game, player_cards, 'in_play', card_player.card)
                    Severity: Minor
                    Found in app/cards/seaside/embargo.js - About 1 hr to fix

                      Function discard_cards has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        static discard_cards(game, player_cards, selected_cards) {
                          if (_.size(selected_cards) === 0) {
                            game.log.push(`&nbsp;&nbsp;but does not discard anything`)
                          } else {
                            let card_discarder = new CardDiscarder(game, player_cards, 'hand', selected_cards)
                      Severity: Minor
                      Found in app/cards/adventures/artificer.js - About 1 hr to fix

                        Function overpay has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          static overpay(game, player_cards, amount) {
                            amount = Number(amount)
                            if (amount > 0) {
                              game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> overpays by $${amount}`)
                              game.turn.coins -= amount
                        Severity: Minor
                        Found in app/cards/guilds/herald.js - About 1 hr to fix

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

                            play(game, player_cards) {
                              let previous_player_query = new PreviousPlayerQuery(game, player_cards.player_id)
                              let previous_player_cards = PlayerCardsModel.findOne(game._id, previous_player_query.previous_player()._id)
                          
                              let eligible_cards = _.filter(previous_player_cards.last_turn_gained_cards, function(gained_card) {
                          Severity: Minor
                          Found in app/cards/seaside/smugglers.js - About 1 hr to fix

                            Function trash_card has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              static trash_card(game, player_cards, selected_cards) {
                                if (!_.isEmpty(selected_cards)) {
                                  let card_trasher = new CardTrasher(game, player_cards, 'hand', selected_cards[0])
                                  card_trasher.trash()
                            
                            
                            Severity: Minor
                            Found in app/cards/base/mine.js - About 1 hr to fix

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

                                play(game, player_cards, card_player) {
                                  let copper = _.find(player_cards.hand, (card) => {
                                    return card.name === 'Copper'
                                  })
                              
                              
                              Severity: Minor
                              Found in app/cards/base/moneylender.js - About 1 hr to fix

                                Function empires has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  static empires() {
                                    return [
                                      'Engineer',
                                      'CityQuarter',
                                      'Overlord',
                                Severity: Minor
                                Found in app/cards/lib/card_list.js - About 1 hr to fix

                                  Function start_turn_event has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    start_turn_event(game, player_cards, sinister_plot) {
                                      game.log.push(`<strong>${player_cards.username}</strong> resolves ${CardView.render(sinister_plot)}`)
                                  
                                      let turn_event_id = TurnEventModel.insert({
                                        game_id: game._id,
                                  Severity: Minor
                                  Found in app/cards/renaissance/projects/sinister_plot.js - About 1 hr to fix

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

                                        let trashable_cards = _.map(player_cards.hand, function(card) {
                                          let new_card = _.clone(card)
                                          new_card.source = 'H'
                                          return new_card
                                        })
                                    Severity: Major
                                    Found in app/cards/adventures/raze.js and 1 other location - About 1 hr to fix
                                    app/cards/nocturne/monastery.js on lines 14..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 55.

                                    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

                                          let trashable_cards = _.map(player_cards.hand, function(card) {
                                            let new_card = _.clone(card)
                                            new_card.source = 'H'
                                            return new_card
                                          })
                                    Severity: Major
                                    Found in app/cards/nocturne/monastery.js and 1 other location - About 1 hr to fix
                                    app/cards/adventures/raze.js on lines 15..19

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

                                    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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language