jcbantuelle/dominion-meteor

View on GitHub
app/game/server/services/gain_event_processor.js

Summary

Maintainability
F
1 wk
Test Coverage

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

    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 gain_event has a Cognitive Complexity of 14 (exceeds 5 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

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

          static event_cards() {
            return [
              'Blessed Village',
              'Border Village',
              'Cache',
        Severity: Minor
        Found in app/game/server/services/gain_event_processor.js - About 1 hr to fix

          Function process has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            process() {
              if (!_.isEmpty(this.gain_events)) {
                let mandatory_gain_events = _.filter(this.gain_events, (event) => {
                  return _.includes(GainEventProcessor.event_cards().concat(GainEventProcessor.in_play_event_cards()).concat(GainEventProcessor.reserve_cards()).concat(GainEventProcessor.landmark_cards()).concat(GainEventProcessor.duration_attack_cards()).concat(['Trade Route', 'Cargo Ship', 'Academy', 'Guildhall', 'Road Network', 'Innovation', 'Livery', 'Invest']), event.name)
                })
          Severity: Minor
          Found in app/game/server/services/gain_event_processor.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                    } else if (card.name === 'Sleigh') {
                      if (this.player_cards._id === this.gainer.player_cards._id && !_.isEmpty(this.player_cards[this.gainer.destination]) && _.head(this.player_cards[this.gainer.destination]).id === this.gainer.gained_card.id) {
                        this.gain_events.push(card)
                      }
                    } else if (card.name === 'Sheepdog') {
            Severity: Major
            Found in app/game/server/services/gain_event_processor.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                      } else if (card.name === 'Defiled Shrine') {
                        if (_.includes(_.words(this.gainer.gained_card.types), 'action')) {
                          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 - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                          if (_.size(this.gainer.game.turn.gained_cards) === 2 && 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

                  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

                          } 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

                      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 (!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

                          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 process has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                              process() {
                                if (!_.isEmpty(this.gain_events)) {
                                  let mandatory_gain_events = _.filter(this.gain_events, (event) => {
                                    return _.includes(GainEventProcessor.event_cards().concat(GainEventProcessor.in_play_event_cards()).concat(GainEventProcessor.reserve_cards()).concat(GainEventProcessor.landmark_cards()).concat(GainEventProcessor.duration_attack_cards()).concat(['Trade Route', 'Cargo Ship', 'Academy', 'Guildhall', 'Road Network', 'Innovation', 'Livery', 'Invest']), event.name)
                                  })
                            Severity: Minor
                            Found in app/game/server/services/gain_event_processor.js - About 35 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

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

                                    if (_.includes(['Royal Seal', 'Tracker'], card.name)) {
                                      if (this.player_cards._id === this.gainer.player_cards._id && !_.isEmpty(this.player_cards[this.gainer.destination]) && _.head(this.player_cards[this.gainer.destination]).id === this.gainer.gained_card.id) {
                                        this.gain_events.push(card)
                                      }
                                    } else if (card.name === 'Groundskeeper') {
                            Severity: Major
                            Found in app/game/server/services/gain_event_processor.js and 2 other locations - About 4 hrs to fix
                            app/game/server/services/gain_event_processor.js on lines 129..149
                            app/game/server/services/gain_event_processor.js on lines 137..149

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

                            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 3 locations. Consider refactoring.
                            Open

                                    } else if (card.name === 'Watchtower') {
                                      if (this.player_cards._id === this.gainer.player_cards._id && !_.isEmpty(this.player_cards[this.gainer.destination]) && _.head(this.player_cards[this.gainer.destination]).id === this.gainer.gained_card.id) {
                                        this.gain_events.push(card)
                                      }
                                    } else if (card.name === 'Black Cat') {
                            Severity: Major
                            Found in app/game/server/services/gain_event_processor.js and 2 other locations - About 4 hrs to fix
                            app/game/server/services/gain_event_processor.js on lines 137..149
                            app/game/server/services/gain_event_processor.js on lines 165..175

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

                            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 3 locations. Consider refactoring.
                            Open

                                    } else if (card.name === 'Sleigh') {
                                      if (this.player_cards._id === this.gainer.player_cards._id && !_.isEmpty(this.player_cards[this.gainer.destination]) && _.head(this.player_cards[this.gainer.destination]).id === this.gainer.gained_card.id) {
                                        this.gain_events.push(card)
                                      }
                                    } else if (card.name === 'Sheepdog') {
                            Severity: Major
                            Found in app/game/server/services/gain_event_processor.js and 2 other locations - About 4 hrs to fix
                            app/game/server/services/gain_event_processor.js on lines 129..149
                            app/game/server/services/gain_event_processor.js on lines 165..175

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

                            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

                                      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
                                        })
                                        if (card_stack && card_stack.victory_tokens > 0) {
                            Severity: Major
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 3 hrs to fix
                            app/game/server/services/gain_event_processor.js on lines 217..224

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

                            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

                                      if (_.includes(_.words(this.gainer.gained_card.types), 'action')) {
                                        let card_stack = _.find(this.gainer.game.cards, (card) => {
                                          return card.stack_name === this.gainer.gained_card.stack_name
                                        })
                                        if (card_stack && card_stack.victory_tokens > 0) {
                            Severity: Major
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 3 hrs to fix
                            app/game/server/services/gain_event_processor.js on lines 196..207

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

                            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

                                  _.times(this.gainer.game.turn.liveries, () => {
                                    let livery = ClassCreator.create('Livery').to_h()
                                    livery.id = this.generate_event_id()
                                    this.gain_events.push(livery)
                                  })
                            Severity: Major
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 2 hrs to fix
                            app/game/server/services/buy_event_processor.js on lines 99..103

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

                            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 (this.gainer.player_cards._id === this.player_cards._id && this.gainer.game.turn.player._id === this.gainer.player_cards.player_id && this.gainer.game.turn.travelling_fair && this.gainer.destination !== 'deck') {
                            Severity: Major
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 2 hrs to fix
                            app/game/server/services/gain_event_processor.js on lines 313..313

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

                            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 (this.gainer.player_cards._id === this.player_cards._id && this.gainer.game.turn.player._id === this.gainer.player_cards.player_id && this.gainer.game.turn.way_of_the_seal) {
                            Severity: Major
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 2 hrs to fix
                            app/game/server/services/gain_event_processor.js on lines 293..293

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

                            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

                                    return _.includes(GainEventProcessor.event_cards().concat(GainEventProcessor.in_play_event_cards()).concat(GainEventProcessor.reserve_cards()).concat(GainEventProcessor.landmark_cards()).concat(GainEventProcessor.duration_attack_cards()).concat(['Trade Route', 'Cargo Ship', 'Academy', 'Guildhall', 'Road Network', 'Innovation', 'Livery', 'Invest']), event.name)
                            Severity: Major
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 1 hr to fix
                            app/game/server/services/buy_event_processor.js on lines 128..128

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

                            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 (investments) {
                                    let invest = ClassCreator.create('Invest').to_h()
                                    invest.id = this.generate_event_id()
                                    this.gain_events.push(invest)
                                  }
                            Severity: Major
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 1 hr to fix
                            app/game/server/services/play_card_event_processor.js on lines 30..34

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

                            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

                                      if (this.gainer.player_cards._id === this.player_cards._id && _.includes(_.words(this.gainer.gained_card.types), 'victory')) {
                            Severity: Major
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 1 hr to fix
                            app/game/server/services/gain_event_processor.js on lines 276..276

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

                            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

                                if (this.gainer.player_cards._id === this.player_cards._id && _.includes(_.words(this.gainer.gained_card.types), 'victory') && this.gainer.supply_pile && this.gainer.supply_pile.has_trade_route_token) {
                            Severity: Major
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 1 hr to fix
                            app/game/server/services/gain_event_processor.js on lines 170..170

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

                            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 6 locations. Consider refactoring.
                            Open

                              constructor(gainer, player_cards) {
                                this.gainer = gainer
                                this.player_cards = player_cards
                                this.event_id = 1000
                                this.find_gain_events()
                            Severity: Major
                            Found in app/game/server/services/gain_event_processor.js and 5 other locations - About 55 mins to fix
                            app/game/server/services/between_turn_event_processor.js on lines 3..8
                            app/game/server/services/discard_event_processor.js on lines 30..35
                            app/game/server/services/end_turn_event_processor.js on lines 7..12
                            app/game/server/services/start_turn_event_processor.js on lines 23..28
                            app/game/server/services/trash_event_processor.js on lines 19..24

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

                            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

                                  let investments = _.find(this.player_cards.investments, (investment) => {
                                    return investment.name === this.gainer.gained_card.name
                                  })
                            Severity: Minor
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 55 mins to fix
                            app/game/server/services/gain_event_processor.js on lines 320..322

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

                            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

                                  let has_exile_cards = _.find(this.player_cards.exile, (card) => {
                                    return card.name === this.gainer.gained_card.name
                                  })
                            Severity: Minor
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 55 mins to fix
                            app/game/server/services/gain_event_processor.js on lines 283..285

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

                            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

                                    let action_count = _.size(_.filter(this.gainer.player_cards.in_play, function(card) {
                                      return _.includes(_.words(card.types), 'action')
                                    }))
                            Severity: Minor
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 50 mins to fix
                            app/game/server/services/discard_event_processor.js on lines 51..53

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

                            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 (has_exile_cards) {
                                    this.gain_events.push({
                                      name: 'Exile',
                                      id: this.generate_event_id(),
                                      wide: true,
                            Severity: Minor
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 50 mins to fix
                            app/game/server/services/buy_event_processor.js on lines 114..122

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

                            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.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 3 locations. Consider refactoring.
                            Open

                                  if (this.gainer.player_cards._id !== this.player_cards._id && _.includes(GainEventProcessor.project_cards(), card.name)) {
                                    if (card.name === 'Road Network') {
                                      if (_.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 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 230..248

                            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

                                    let exiled_copies = _.filter(player_cards.exile, (card) => {
                                      return card.name === gain_event_processor.gainer.gained_card.name
                                    })
                            Severity: Minor
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 40 mins to fix
                            app/cards/guilds/taxman.js on lines 65..67

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

                            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 (this.gainer.player_cards._id !== this.player_cards._id && !_.isEmpty(this.player_cards.investments)) {
                                  let investments = _.find(this.player_cards.investments, (investment) => {
                                    return investment.name === this.gainer.gained_card.name
                                  })
                                  if (investments) {
                            Severity: Minor
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 40 mins to fix
                            app/game/server/services/gain_event_processor.js on lines 319..332

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

                            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 (this.gainer.player_cards._id === this.player_cards._id && !_.isEmpty(this.player_cards.exile)) {
                                  let has_exile_cards = _.find(this.player_cards.exile, (card) => {
                                    return card.name === this.gainer.gained_card.name
                                  })
                                  if (has_exile_cards) {
                            Severity: Minor
                            Found in app/game/server/services/gain_event_processor.js and 1 other location - About 40 mins to fix
                            app/game/server/services/gain_event_processor.js on lines 282..291

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

                            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

                            There are no issues that match your filters.

                            Category
                            Status