jcbantuelle/dominion-meteor

View on GitHub

Showing 347 of 1,158 total issues

Function play_card has 37 lines of code (exceeds 25 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

    Function play has 37 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)
    
        _.each(['cards', 'coins'], (discard_type) => {
    Severity: Minor
    Found in app/cards/dark_ages/storeroom.js - About 1 hr to fix

      Function dark_ages has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static dark_ages() {
          return [
            'PoorHouse',
            'Beggar',
            'Squire',
      Severity: Minor
      Found in app/cards/lib/card_list.js - About 1 hr to fix

        Function kingdom_cards has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          kingdom_cards() {
            let kingdom_cards = _.map(this.cards, (card) => {
              return this.game_card(card, 'kingdom')
            })
        
        
        Severity: Minor
        Found in app/lobby/server/game_creator.js - About 1 hr to fix

          Function undo_action has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static undo_action(game, player_cards) {
              game.log.push(`<strong>${player_cards.username}</strong> requests to undo their last action`)
              GameModel.update(game._id, game)
              let ordered_player_cards = TurnOrderedPlayerCardsQuery.turn_ordered_player_cards(game, player_cards)
              ordered_player_cards.shift()
          Severity: Minor
          Found in app/game/server/services/player_action_undoer.js - About 1 hr to fix

            Function buy_event has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              static buy_event(game, player_cards, selected_cards, buy_event_processor) {
                if (!_.isEmpty(selected_cards)) {
                  let card = selected_cards[0]
                  if (card.name === 'Trash Token') {
                    if (_.size(player_cards.hand) > 0) {
            Severity: Minor
            Found in app/game/server/services/buy_event_processor.js - About 1 hr to fix

              Function play has 36 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/dark_ages/ironmonger.js - About 1 hr to fix

                Function buy_event has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  static buy_event(game, player_cards, selected_cards, buy_event_processor) {
                    if (!_.isEmpty(selected_cards)) {
                      let card = selected_cards[0]
                      if (card.name === 'Trash Token') {
                        if (_.size(player_cards.hand) > 0) {
                Severity: Minor
                Found in app/game/server/services/buy_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 end_turn has a Cognitive Complexity of 12 (exceeds 5 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

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

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

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

                    play(game, player_cards) {
                      let gained_coin = 2
                      if (game.turn.envious) {
                        gained_coin = 1
                      }
                  Severity: Minor
                  Found in app/cards/common/silver.js - About 1 hr to fix

                    Function nocturne has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      static nocturne() {
                        return [
                          'Druid',
                          'FaithfulHound',
                          'Guardian',
                    Severity: Minor
                    Found in app/cards/lib/card_list.js - About 1 hr to fix

                      Function gain_event has 34 lines of code (exceeds 25 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

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

                          play(game, player_cards, player) {
                            let gained_card_count = _.size(game.turn.gained_cards)
                            if (gained_card_count > 0) {
                              let trashable_cards = _.map(player_cards.hand, function(card) {
                                let new_card = _.clone(card)
                        Severity: Minor
                        Found in app/cards/nocturne/monastery.js - About 1 hr to fix

                          Function play has 34 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(3)
                          
                              let buy_gainer = new BuyGainer(game, player_cards)
                          Severity: Minor
                          Found in app/cards/nocturne/tragic_hero.js - About 1 hr to fix

                            Function update_player_rankings has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              update_player_rankings() {
                                if (_.size(this.game.players) === 2) {
                                  let usernames = _.map(this.game.players, 'username')
                                  let player_rankings = PlayerRankings.find({username: {$in: usernames}}).fetch()
                                  _.each(player_rankings, (player_ranking) => {
                            Severity: Minor
                            Found in app/game/server/services/game_ender.js - About 1 hr to fix

                              Function play has 34 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 trashable_cards = _.map(player_cards.hand, function(card) {
                              Severity: Minor
                              Found in app/cards/adventures/raze.js - About 1 hr to fix

                                Function overpay has 34 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/doctor.js - About 1 hr to fix

                                  Function between_turn_event has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    between_turn_event(game, player_cards, mountain_pass) {
                                      game.log.push(`Bidding on ${CardView.render(mountain_pass)}`)
                                      GameModel.update(game._id, game)
                                  
                                      game.mountain_pass = {
                                  Severity: Minor
                                  Found in app/cards/empires/landmarks/mountain_pass.js - About 1 hr to fix

                                    Function play has 34 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/dark_ages/count.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language