jcbantuelle/dominion-meteor

View on GitHub

Showing 1,158 of 1,158 total issues

Avoid deeply nested control flow statements.
Open

        if (this.gainer.game.turn.player._id === this.gainer.player_cards.player_id) {
          this.gain_events.push(this.gainer.gained_card)
        }
Severity: Major
Found in app/game/server/services/gain_event_processor.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    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 - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if (card_mover.return_to_supply(player_cards.in_play, 'Bat', [card_player.card])) {
                    card_mover.take_from_supply(player_cards.discard, vampire_stack.top_card)
                    game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> exchanges ${CardView.render(card_player.card)} for ${CardView.render(vampire_stack.top_card)}`)
                  }
      Severity: Major
      Found in app/cards/nocturne/bat.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

              } else if (this.gainer.gained_card.name === 'Experiment') {
                if (!this.gainer.gained_by || this.gainer.gained_by.name !== 'Experiment') {
                  this.gain_events.push(this.gainer.gained_card)
                }
              } else {
        Severity: Major
        Found in app/game/server/services/gain_event_processor.js - About 45 mins to fix

          Function process has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            process() {
              if (!_.isEmpty(this.trash_events)) {
                let mandatory_trash_events = _.filter(this.trash_events, function(event) {
                  return _.includes(TrashEventProcessor.event_cards().concat(TrashEventProcessor.landmark_cards().concat(['Priest'])), event.name)
                })
          Severity: Minor
          Found in app/game/server/services/trash_event_processor.js - About 45 mins 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

          Avoid deeply nested control flow statements.
          Open

                    if (this.player_cards._id !== this.gainer.player_cards._id && _.includes(_.words(this.gainer.gained_card.types), 'victory')) {
                      this.gain_events.push(card)
                    }
          Severity: Major
          Found in app/game/server/services/gain_event_processor.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                    if (_.includes(['treasure', 'buy'], this.game.turn.phase)) {
                      this.game.turn.phase = 'buy'
                      let end_buy_event_processor = new EndBuyEventProcessor(this.game, this.player_cards)
                      end_buy_event_processor.process()
                    }
            Severity: Major
            Found in app/game/server/services/card_player.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                      } else if (this.card.name === 'Alchemist') {
                        let has_potions = _.some(this.discarder.player_cards.in_play, function(card) {
                          return card.name === 'Potion'
                        })
                        if (has_potions) {
              Severity: Major
              Found in app/game/server/services/discard_event_processor.js - About 45 mins to fix

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

                  play(game, player_cards) {
                    if (_.size(game.turn.gained_cards) > 1) {
                      let card_gainer = new CardGainer(game, player_cards, 'discard', 'Imp')
                      card_gainer.gain()
                    } else if (_.size(game.turn.gained_cards) == 1) {
                Severity: Minor
                Found in app/cards/nocturne/devils_workshop.js - About 45 mins 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

                Avoid deeply nested control flow statements.
                Open

                          if (!this.gainer.game.turn.innovation && _.size(gained_actions) === 1 && gained_actions[0].id === this.gainer.gained_card.id) {
                            this.gainer.game.turn.innovation = true
                            this.gain_events.push(card)
                          }
                Severity: Major
                Found in app/game/server/services/gain_event_processor.js - About 45 mins to fix

                  Function process has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    process() {
                      if (!_.isEmpty(this.play_card_events)) {
                        let mandatory_play_card_events = _.filter(this.play_card_events, (event) => {
                          return event.name === 'Kiln'
                        })
                  Severity: Minor
                  Found in app/game/server/services/play_card_event_processor.js - About 45 mins 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

                  Avoid deeply nested control flow statements.
                  Open

                              if (card.victory_tokens > 0) {
                                this.gain_events.push(card)
                              }
                  Severity: Major
                  Found in app/game/server/services/gain_event_processor.js - About 45 mins to fix

                    Function play_twice has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                      static play_twice(game, player_cards, selected_cards, disciple) {
                        if (!_.isEmpty(selected_cards)) {
                          let card_player = new CardPlayer(game, player_cards, selected_cards[0], disciple)
                          card_player.play(true, true, 'hand', 2)
                    
                    
                    Severity: Minor
                    Found in app/cards/adventures/disciple.js - About 45 mins 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

                    Avoid deeply nested control flow statements.
                    Open

                              if (victory_tokens > 0) {
                                game.cards[wild_hunt_index].victory_tokens = 0
                                let victory_token_gainer = new VictoryTokenGainer(game, player_cards)
                                victory_token_gainer.gain(victory_tokens)
                              }
                    Severity: Major
                    Found in app/cards/empires/wild_hunt.js - About 45 mins to fix

                      Function play has a Cognitive Complexity of 8 (exceeds 5 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/base/poacher.js - About 45 mins 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

                      Avoid deeply nested control flow statements.
                      Open

                                  if (lantern || horn) {
                                    artifact_name = lantern ? 'Horn' : 'Lantern'
                                  } else {
                                    GameModel.update(game._id, game)
                                    PlayerCardsModel.update(game._id, player_cards)
                      Severity: Major
                      Found in app/cards/renaissance/border_guard.js - About 45 mins to fix

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

                              if (this.gainer.player_cards._id === this.player_cards._id && _.includes(GainEventProcessor.landmark_cards(), card.name)) {
                                if (card.name === 'Aqueduct') {
                                  if (_.includes(_.words(this.gainer.gained_card.types), 'treasure')) {
                                    let card_stack = _.find(this.gainer.game.cards, (card) => {
                                      return card.stack_name === this.gainer.gained_card.stack_name
                        Severity: Major
                        Found in app/game/server/services/gain_event_processor.js and 2 other locations - About 45 mins to fix
                        app/game/server/services/gain_event_processor.js on lines 230..248
                        app/game/server/services/gain_event_processor.js on lines 252..258

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

                        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.gainer.player_cards._id === this.player_cards._id && _.includes(GainEventProcessor.project_cards(), card.name)) {
                                if (card.name === 'Academy') {
                                  if (_.includes(_.words(this.gainer.gained_card.types), 'action')) {
                                    this.gain_events.push(card)
                                  }
                        Severity: Major
                        Found in app/game/server/services/gain_event_processor.js and 2 other locations - About 45 mins to fix
                        app/game/server/services/gain_event_processor.js on lines 194..226
                        app/game/server/services/gain_event_processor.js on lines 252..258

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

                        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

                          play(game, player_cards, card_player) {
                            let coin_gainer = new CoinGainer(game, player_cards, card_player)
                            coin_gainer.gain(2)
                        
                            game.turn.improves += 1
                        Severity: Minor
                        Found in app/cards/renaissance/improve.js and 1 other location - About 45 mins to fix
                        app/cards/menagerie/livery.js on lines 15..20

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

                        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

                            if (_.includes(RevealEventProcessor.event_cards(), this.card.name)) {
                              this.reveal_events.push(this.card)
                            }
                        Severity: Minor
                        Found in app/game/server/services/reveal_event_processor.js and 1 other location - About 45 mins to fix
                        app/game/server/services/trash_event_processor.js on lines 28..30

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

                        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