jcbantuelle/dominion-meteor

View on GitHub

Showing 347 of 1,158 total issues

Function kingdom_cards has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  kingdom_cards() {
    let kingdom_cards = _.map(this.cards, (card) => {
      return this.game_card(card, 'kingdom')
    })

Severity: Minor
Found in app/lobby/server/game_creator.js - About 55 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

Function trash_card has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  static trash_card(game, player_cards, selected_cards) {
    if (!_.isEmpty(selected_cards)) {
      let is_active_player = game.turn.player._id === player_cards.player_id
      let remodel_amount = is_active_player ? 2 : 1

Severity: Minor
Found in app/cards/promo/governor.js - About 55 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

Function reveal_card has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  static reveal_card(game, player_cards, selected_cards) {
    let named_card
    if (!_.isEmpty(selected_cards)) {
      named_card = selected_cards[0].name
      game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> names ${CardView.render(selected_cards)}`)
Severity: Minor
Found in app/cards/dark_ages/rebuild.js - About 55 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

Function play has a Cognitive Complexity of 9 (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/dark_ages/ironmonger.js - About 55 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

Function attack has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  attack(game, player_cards, attacker_player_cards, card_player, attacker_journey_token) {
    if (attacker_journey_token === 'up') {
      if (_.size(player_cards.deck) > 0 || _.size(player_cards.discard) > 0) {
        let card_revealer = new CardRevealer(game, player_cards)
        card_revealer.reveal_from_deck(1)
Severity: Minor
Found in app/cards/adventures/giant.js - About 55 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

Function attack has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  attack(game, player_cards) {
    if (game.turn.pirate_ship_attack) {
      if (_.size(player_cards.deck) === 0 && _.size(player_cards.discard) === 0) {
        game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> has no cards in deck`)
      } else {
Severity: Minor
Found in app/cards/seaside/pirate_ship.js - About 55 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

Function play has a Cognitive Complexity of 9 (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/adventures/magpie.js - About 55 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

Function attack has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  attack(game, player_cards) {
    if (_.size(player_cards.deck) === 0 && _.size(player_cards.discard) === 0) {
      game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> has no cards in deck`)
    } else {
      if (_.size(player_cards.deck) === 0) {
Severity: Minor
Found in app/cards/intrigue/swindler.js - About 55 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

Function attack has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  attack(game, player_cards) {
    if (game.turn.rogue_attack) {
      if (_.size(player_cards.deck) === 0 && _.size(player_cards.discard) === 0) {
        game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> has no cards in deck`)
      } else {
Severity: Minor
Found in app/cards/dark_ages/rogue.js - About 55 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

Function buy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  buy(game, player_cards) {
    let buy_gainer = new BuyGainer(game, player_cards)
    buy_gainer.gain(1)

    if (_.size(player_cards.deck) === 0 && _.size(player_cards.discard) === 0) {
Severity: Minor
Found in app/cards/menagerie/events/gamble.js - About 55 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

Function buy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  buy(game, player_cards) {
    let horse = _.find(game.cards, (card) => {
      return card.count > 0 && card.name === 'Horse'
    })

Severity: Minor
Found in app/cards/menagerie/events/demand.js - About 55 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

        } 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 (has_treasures) {
                    this.discard_events.push(this.card)
                  }
        Severity: Major
        Found in app/game/server/services/discard_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

                    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

                  Severity
                  Category
                  Status
                  Source
                  Language