jcbantuelle/dominion-meteor

View on GitHub

Showing 1,158 of 1,158 total issues

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

    if (PlayerCards[game_id]) {
      _.forIn(PlayerCards[game_id].all(), (player_cards) => {
        this.changed('player_cards', player_cards._id, player_cards)
      })
    }
Severity: Major
Found in lib/server/published_data.js and 1 other location - About 1 hr to fix
lib/server/published_data.js on lines 43..47

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

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

  play(game, player_cards) {
    let coin_gainer = new CoinGainer(game, player_cards)
    coin_gainer.gain(2, false)

    let buy_gainer = new BuyGainer(game, player_cards)
Severity: Major
Found in app/cards/renaissance/spices.js and 2 other locations - About 1 hr to fix
app/cards/empires/plunder.js on lines 19..25
app/cards/nocturne/pouch.js on lines 11..17

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

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

  play(game, player_cards) {
    let card_gainer = new CardGainer(game, player_cards, 'deck', 'Silver')
    card_gainer.gain()

    let player_attacker = new PlayerAttacker(game, this)
Severity: Major
Found in app/cards/base/bureaucrat.js and 3 other locations - About 1 hr to fix
app/cards/base/bandit.js on lines 11..17
app/cards/dark_ages/marauder.js on lines 11..17
app/cards/guilds/soothsayer.js on lines 11..17

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

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

  play(game, player_cards) {
    let card_gainer = new CardGainer(game, player_cards, 'discard', 'Gold')
    card_gainer.gain()

    let player_attacker = new PlayerAttacker(game, this)
Severity: Major
Found in app/cards/guilds/soothsayer.js and 3 other locations - About 1 hr to fix
app/cards/base/bandit.js on lines 11..17
app/cards/base/bureaucrat.js on lines 11..17
app/cards/dark_ages/marauder.js on lines 11..17

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

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 (PlayerCards[game_id]) {
    _.forIn(PlayerCards[game_id].all(), (player_cards) => {
      this.added('player_cards', player_cards._id, player_cards)
    })
  }
Severity: Major
Found in lib/server/published_data.js and 1 other location - About 1 hr to fix
lib/server/published_data.js on lines 49..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 57.

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

Function player has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  player() {
    let player = PlayerRankings.findOne({username: FlowRouter.getParam('id')}, {
      transform: function(player) {
        let total_games = player.wins + player.losses
        player.win_ratio = total_games === 0 ? 0 : ((player.wins / total_games) * 100).toFixed(2)
Severity: Minor
Found in app/players/client/players_show.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 valid_selection has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  valid_selection() {
    if (this.turn_event.type === 'overpay') {
      if (this.selection < this.turn_event.minimum) {
        this.error = `You can't overpay less than ${this.turn_event.minimum}`
      } else if (this.selection > this.turn_event.maximum) {
Severity: Minor
Found in app/game/client/value_objects/turn_event_submission.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 set_aside_prince has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  static set_aside_prince(game, player_cards, response, prince) {
    if (response === 'yes') {
      let card_mover = new CardMover(game, player_cards)
      if (card_mover.move(player_cards.in_play, player_cards.aside, prince)) {
        game.log.push(`&nbsp;&nbsp;<strong>${player_cards.username}</strong> sets aside ${CardView.render(prince)}`)
Severity: Minor
Found in app/cards/promo/prince.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 play has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  play(game, player_cards, card_player) {
    let card_gainer = new CardGainer(game, player_cards, 'discard', 'Silver')
    card_gainer.gain()

    GameModel.update(game._id, game)
Severity: Minor
Found in app/cards/hinterlands/jack_of_all_trades.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 play has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  play(game, player_cards) {
    if (_.size(player_cards.deck) === 0 && _.size(player_cards.discard) === 0) {
      game.log.push(`&nbsp;&nbsp;but there are no cards in their deck`)
    } else {
      let card_revealer = new CardRevealer(game, player_cards)
Severity: Minor
Found in app/cards/alchemy/golem.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 process_response has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  static process_response(game, player_cards, response) {
    if (response[0] === 'gain') {
      let eligible_cards = _.filter(game.trash, (card) => {
        return CardCostComparer.coin_between(game, card, 3, 6)
      })
Severity: Minor
Found in app/cards/dark_ages/graverobber.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 play has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  play(game, player_cards, card_player) {
    let coin_gainer = new CoinGainer(game, player_cards, card_player)
    coin_gainer.gain(3)

    GameModel.update(game._id, game)
Severity: Minor
Found in app/cards/renaissance/treasurer.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 buy has a Cognitive Complexity of 10 (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/pursue.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 play has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  play(game, player_cards) {
    let gained_coin = 2
    if (game.turn.envious) {
      gained_coin = 1
    }
Severity: Minor
Found in app/cards/common/silver.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 receive has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  receive(game, player_cards) {
    if (_.size(player_cards.hand) > 4) {
      let eligible_cards = _.filter(player_cards.hand, function(card) {
        return _.includes(_.words(card.types), 'treasure') || _.includes(_.words(card.types), 'action')
      })
Severity: Minor
Found in app/cards/nocturne/hexes/fear.js - About 1 hr to fix

    Function play has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      play(game, player_cards, card_player) {
        let coin_gainer = new CoinGainer(game, player_cards, card_player)
        coin_gainer.gain(2)
    
        if (_.size(player_cards.deck) === 0 && _.size(player_cards.discard) === 0) {
    Severity: Minor
    Found in app/cards/base/vassal.js - About 1 hr to fix

      Function duration has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        duration(game, player_cards, mastermind) {
          game.log.push(`<strong>${player_cards.username}</strong> resolves ${CardView.render(mastermind)}`)
          let eligible_cards = _.filter(player_cards.hand, (card) => {
            return _.includes(_.words(card.types), 'action')
          })
      Severity: Minor
      Found in app/cards/menagerie/mastermind.js - About 1 hr to fix

        Function play has 27 lines of code (exceeds 25 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/junk_dealer.js - About 1 hr to fix

          Function trash_card has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static trash_card(game, player_cards, selected_cards) {
              let selected_card = selected_cards[0]
          
              let card_trasher = new CardTrasher(game, player_cards, 'hand', selected_card)
              card_trasher.trash()
          Severity: Minor
          Found in app/cards/hinterlands/farmland.js - About 1 hr to fix

            Function trash_cards has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              static trash_cards(game, player_cards, selected_cards) {
                let cost = _.reduce(selected_cards, (total_cost, card) => {
                  return total_cost + CostCalculator.calculate(game, card)
                }, 0)
            
            
            Severity: Minor
            Found in app/cards/prosperity/forge.js - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language