jcbantuelle/dominion-meteor

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

Summary

Maintainability
D
2 days
Test Coverage

Function find_start_turn_events has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  find_start_turn_events() {
    this.start_turn_events = []

    _.each(this.player_cards.aside, (card) => {
      if (_.includes(StartTurnEventProcessor.aside_events(), card.name)) {
Severity: Minor
Found in app/game/server/services/start_turn_event_processor.js - About 1 hr to fix

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

      process() {
        if (!_.isEmpty(this.start_turn_events)) {
          if (_.size(this.start_turn_events) > 1) {
            let turn_event_id = TurnEventModel.insert({
              game_id: this.game._id,
    Severity: Major
    Found in app/game/server/services/start_turn_event_processor.js and 3 other locations - About 7 hrs to fix
    app/game/server/services/between_turn_event_processor.js on lines 27..44
    app/game/server/services/end_turn_event_processor.js on lines 38..55
    app/game/server/services/start_cleanup_event_processor.js on lines 55..72

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

    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

        _.each(this.player_cards.start_turn_event_effects, (event_effect) => {
          event_effect.event_type = 'Event'
          if (!event_effect.id) {
            event_effect.id = this.generate_event_id()
          }
    Severity: Major
    Found in app/game/server/services/start_turn_event_processor.js and 1 other location - About 2 hrs to fix
    app/game/server/services/end_turn_event_processor.js on lines 29..35

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

    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

          } else if (event.event_type === 'Event') {
            let event_effect_index = _.findIndex(player_cards.start_turn_event_effects, function(event_effect) {
              return event_effect.id === event.id
            })
            player_cards.start_turn_event_effects.splice(event_effect_index, 1)
    Severity: Major
    Found in app/game/server/services/start_turn_event_processor.js and 1 other location - About 1 hr to fix
    app/game/server/services/start_turn_event_processor.js on lines 114..130

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

    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 (event.event_type === 'Duration') {
            let duration_effect_index = _.findIndex(player_cards.duration_effects, function(duration_effect) {
              return duration_effect.id === event.id
            })
            player_cards.duration_effects.splice(duration_effect_index, 1)
    Severity: Major
    Found in app/game/server/services/start_turn_event_processor.js and 1 other location - About 1 hr to fix
    app/game/server/services/start_turn_event_processor.js on lines 120..130

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

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

        _.each(this.player_cards.artifacts, (card) => {
          if (_.includes(StartTurnEventProcessor.artifact_events(), card.name)) {
            this.start_turn_events.push(card)
          }
        })
    Severity: Major
    Found in app/game/server/services/start_turn_event_processor.js and 3 other locations - About 1 hr to fix
    app/game/server/services/start_cleanup_event_processor.js on lines 24..28
    app/game/server/services/start_turn_event_processor.js on lines 67..71
    app/game/server/services/start_turn_event_processor.js on lines 79..83

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

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

        _.each(this.player_cards.projects, (card) => {
          if (_.includes(StartTurnEventProcessor.project_events(), card.name)) {
            this.start_turn_events.push(card)
          }
        })
    Severity: Major
    Found in app/game/server/services/start_turn_event_processor.js and 3 other locations - About 1 hr to fix
    app/game/server/services/start_cleanup_event_processor.js on lines 24..28
    app/game/server/services/start_turn_event_processor.js on lines 67..71
    app/game/server/services/start_turn_event_processor.js on lines 73..77

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

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

        _.each(this.player_cards.states, (card) => {
          if (_.includes(StartTurnEventProcessor.state_events(), card.name)) {
            this.start_turn_events.push(card)
          }
        })
    Severity: Major
    Found in app/game/server/services/start_turn_event_processor.js and 3 other locations - About 1 hr to fix
    app/game/server/services/start_cleanup_event_processor.js on lines 24..28
    app/game/server/services/start_turn_event_processor.js on lines 73..77
    app/game/server/services/start_turn_event_processor.js on lines 79..83

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

    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(game, player_cards) {
        this.game = game
        this.player_cards = player_cards
        this.event_id = 4000
        this.find_start_turn_events()
    Severity: Major
    Found in app/game/server/services/start_turn_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/gain_event_processor.js on lines 88..93
    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

    There are no issues that match your filters.

    Category
    Status