jcbantuelle/dominion-meteor

View on GitHub

Showing 347 of 1,158 total issues

Function calculate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  static calculate(game, card, buy_phase = false, player_cards = undefined) {
    let cost = _.isPlainObject(card) ? card.coin_cost : card.coin_cost()
    let type = _.isPlainObject(card) ? card.types : card.type_class()
    let name = _.isPlainObject(card) ? card.name : card.name()
    let stack_name = _.isPlainObject(card) ? card.stack_name : card.stack_name()
Severity: Minor
Found in app/game/lib/services/cost_calculator.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 play has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  play(game, player_cards, card_player) {
    if (_.size(player_cards.hand) > 0) {
      let turn_event_id = TurnEventModel.insert({
        game_id: game._id,
        player_id: player_cards.player_id,
Severity: Minor
Found in app/cards/nocturne/bat.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 update_phase has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  update_phase(free_play) {
    if (!free_play) {
      let phase
      if (this.game.turn.phase === 'action' && _.includes(_.words(this.card.types), 'treasure')) {
        phase = 'treasure'
Severity: Major
Found in app/game/server/services/card_player.js - About 2 hrs to fix

    Function play has 68 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(3)
    
        GameModel.update(game._id, game)
    Severity: Major
    Found in app/cards/renaissance/treasurer.js - About 2 hrs to fix

      Function calculate has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static calculate(game, card, buy_phase = false, player_cards = undefined) {
          let cost = _.isPlainObject(card) ? card.coin_cost : card.coin_cost()
          let type = _.isPlainObject(card) ? card.types : card.type_class()
          let name = _.isPlainObject(card) ? card.name : card.name()
          let stack_name = _.isPlainObject(card) ? card.stack_name : card.stack_name()
      Severity: Major
      Found in app/game/lib/services/cost_calculator.js - About 2 hrs to fix

        Function buy has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          buy(game, player_cards) {
            let turn_event_id = TurnEventModel.insert({
              game_id: game._id,
              player_id: player_cards.player_id,
              username: player_cards.username,
        Severity: Major
        Found in app/cards/menagerie/events/transport.js - About 2 hrs to fix

          Function play has 61 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)
          
              game.turn.self_revealed_province = false
          Severity: Major
          Found in app/cards/cornucopia/tournament.js - About 2 hrs to fix

            `` has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

            CardPlayer = class CardPlayer {
            
              constructor(game, player_cards, card, originating_card) {
                this.game = game
                this.player_cards = player_cards
            Severity: Minor
            Found in app/game/server/services/card_player.js - About 2 hrs to fix

              Function transform has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                        transform: function(player_cards) {
                          let player_score_calculator = new PlayerScoreCalculator(player_cards)
                          let public_info = {
                            username: player_cards.username,
                            color: player_cards.color,
              Severity: Major
              Found in app/game/client/game.js - About 2 hrs to fix

                File card_player.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                CardPlayer = class CardPlayer {
                
                  constructor(game, player_cards, card, originating_card) {
                    this.game = game
                    this.player_cards = player_cards
                Severity: Minor
                Found in app/game/server/services/card_player.js - About 2 hrs to fix

                  Function process_response has 54 lines of code (exceeds 25 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: Major
                  Found in app/cards/adventures/events/quest.js - About 2 hrs to fix

                    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

                      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

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

                        play(game, player_cards, card_player) {
                          let card_gainer = new CardGainer(game, player_cards, 'discard', 'Silver')
                          card_gainer.gain()
                      
                          GameModel.update(game._id, game)
                      Severity: Major
                      Found in app/cards/hinterlands/jack_of_all_trades.js - About 2 hrs to fix

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

                          play(game, player_cards, card_player) {
                            if (_.size(game.hexes_deck) === 0) {
                              game.hexes_deck = _.shuffle(game.hexes_discard)
                              game.hexes_discard = []
                            }
                        Severity: Minor
                        Found in app/cards/nocturne/vampire.js - About 2 hrs to fix

                          Function play has 50 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)
                          
                              PlayerCardsModel.update(game._id, player_cards)
                          Severity: Minor
                          Found in app/cards/intrigue/masquerade.js - About 2 hrs to fix

                            Function buy has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              buy(game, player_cards) {
                                let eligible_cards = _.filter(player_cards.hand, (card) => {
                                  return !_.includes(_.words(card.types), 'victory')
                                })
                            
                            
                            Severity: Minor
                            Found in app/cards/menagerie/events/enhance.js - About 2 hrs to fix

                              Function buy has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                buy(game, player_cards) {
                                  let horse = _.find(game.cards, (card) => {
                                    return card.count > 0 && card.name === 'Horse'
                                  })
                              
                              
                              Severity: Minor
                              Found in app/cards/menagerie/events/demand.js - About 2 hrs to fix

                                Function reveal_card has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  static reveal_card(game, player_cards, selected_cards) {
                                    let named_card
                                    if (!_.isEmpty(selected_cards)) {
                                      named_card = selected_cards[0].name
                                      game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> names ${CardView.render(selected_cards)}`)
                                Severity: Minor
                                Found in app/cards/dark_ages/rebuild.js - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language