jcbantuelle/dominion-meteor

View on GitHub

Showing 347 of 1,158 total issues

File game_creator.js has 840 lines of code (exceeds 250 allowed). Consider refactoring.
Open

GameCreator = class GameCreator {

  constructor(players, cards, exclusions, edition) {
    this.card_id = 1
    this.players = players
Severity: Major
Found in app/lobby/server/game_creator.js - About 2 days to fix

    File card_list.js has 803 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    CardList = class CardList {
    
      constructor(exclusions, edition) {
        this.edition = edition
        this.exclusions = exclusions
    Severity: Major
    Found in app/cards/lib/card_list.js - About 1 day to fix

      Function current_game has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
      Open

        current_game() {
          let game = Games.findOne({}, {
            transform: function(game) {
              game.kingdom_cards = []
              game.common_cards = []
      Severity: Minor
      Found in app/game/client/game.js - About 1 day 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 find_gain_events has 221 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        find_gain_events() {
          this.gain_events = []
      
          if (this.gainer.player_cards._id === this.player_cards._id && _.includes(GainEventProcessor.event_cards(), this.gainer.gained_card.name)) {
            if (this.gainer.gained_card.name === 'Duchy') {
      Severity: Major
      Found in app/game/server/services/gain_event_processor.js - About 1 day to fix

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

        GameCreator = class GameCreator {
        
          constructor(players, cards, exclusions, edition) {
            this.card_id = 1
            this.players = players
        Severity: Major
        Found in app/lobby/server/game_creator.js - About 1 day to fix

          Function find_discard_events has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
          Open

            find_discard_events() {
              this.discard_events = []
              if (_.includes(DiscardEventProcessor.event_cards(), this.card.name)) {
                if (_.includes(['Tunnel', 'Faithful Hound', 'Village Green'], this.card.name) && this.discarder.game.turn.phase !== 'cleanup') {
                  this.discard_events.push(this.card)
          Severity: Minor
          Found in app/game/server/services/discard_event_processor.js - About 7 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

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

          CardList = class CardList {
          
            constructor(exclusions, edition) {
              this.edition = edition
              this.exclusions = exclusions
          Severity: Minor
          Found in app/cards/lib/card_list.js - About 6 hrs to fix

            File gain_event_processor.js has 380 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            GainEventProcessor = class GainEventProcessor {
            
              static reaction_cards() {
                return [
                  'Black Cat',
            Severity: Minor
            Found in app/game/server/services/gain_event_processor.js - About 5 hrs to fix

              Function find_gain_events has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
              Open

                find_gain_events() {
                  this.gain_events = []
              
                  if (this.gainer.player_cards._id === this.player_cards._id && _.includes(GainEventProcessor.event_cards(), this.gainer.gained_card.name)) {
                    if (this.gainer.gained_card.name === 'Duchy') {
              Severity: Minor
              Found in app/game/server/services/gain_event_processor.js - About 4 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 current_game has 121 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                current_game() {
                  let game = Games.findOne({}, {
                    transform: function(game) {
                      game.kingdom_cards = []
                      game.common_cards = []
              Severity: Major
              Found in app/game/client/game.js - About 4 hrs to fix

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

                TurnEnder = class TurnEnder {
                
                  constructor(game, player_cards) {
                    this.game = game
                    this.player_cards = player_cards
                Severity: Minor
                Found in app/game/server/services/turn_ender.js - About 4 hrs to fix

                  Function play has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                  Open

                    play(game, player_cards) {
                      let lantern = _.find(player_cards.artifacts, (artifact) => {
                        return artifact.name === 'Lantern'
                      })
                  
                  
                  Severity: Minor
                  Found in app/cards/renaissance/border_guard.js - About 4 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

                  File turn_ender.js has 328 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  TurnEnder = class TurnEnder {
                  
                    constructor(game, player_cards) {
                      this.game = game
                      this.player_cards = player_cards
                  Severity: Minor
                  Found in app/game/server/services/turn_ender.js - About 3 hrs to fix

                    Function update_phase has a Cognitive Complexity of 23 (exceeds 5 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: Minor
                    Found in app/game/server/services/card_player.js - About 3 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 find_buy_events has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      find_buy_events() {
                        this.buy_events = []
                        if (_.includes(BuyEventProcessor.event_cards(), this.buyer.card.name)) {
                          if (this.buyer.card.name === 'Messenger') {
                            if (_.size(this.buyer.game.turn.bought_things) === 1) {
                    Severity: Major
                    Found in app/game/server/services/buy_event_processor.js - About 3 hrs to fix

                      Function create_player_cards has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        create_player_cards(player, index) {
                          let starting_treasures = []
                          if (this.game_has_card(this.selected_kingdom_cards, 'Pixie')) {
                            starting_treasures.push(new Goat())
                          }
                      Severity: Major
                      Found in app/lobby/server/game_creator.js - About 3 hrs to fix

                        Function find_discard_events has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          find_discard_events() {
                            this.discard_events = []
                            if (_.includes(DiscardEventProcessor.event_cards(), this.card.name)) {
                              if (_.includes(['Tunnel', 'Faithful Hound', 'Village Green'], this.card.name) && this.discarder.game.turn.phase !== 'cleanup') {
                                this.discard_events.push(this.card)
                        Severity: Major
                        Found in app/game/server/services/discard_event_processor.js - About 3 hrs to fix

                          Function not_supply_cards has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            not_supply_cards() {
                              let not_supply_cards = []
                              let conditional_cards = [
                                {
                                  card_name: 'Madman',
                          Severity: Major
                          Found in app/lobby/server/game_creator.js - About 2 hrs to fix

                            Function stack_size has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                            Open

                              stack_size(card) {
                                if (_.includes(_.words(card.types), 'victory')) {
                                  return _.size(this.players) < 3 ? 8 : 12
                                } else if (_.includes(['Curse', 'Ruins'], card.name)) {
                                  return _.size(this.players) === 1 ? 10 : _.size(this.players) * 10 - 10
                            Severity: Minor
                            Found in app/lobby/server/game_creator.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 72 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              play(game, player_cards) {
                                let lantern = _.find(player_cards.artifacts, (artifact) => {
                                  return artifact.name === 'Lantern'
                                })
                            
                            
                            Severity: Major
                            Found in app/cards/renaissance/border_guard.js - About 2 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language