jcbantuelle/dominion-meteor

View on GitHub

Showing 1,158 of 1,158 total issues

Function undo_action has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static undo_action(game, player_cards) {
    game.log.push(`<strong>${player_cards.username}</strong> requests to undo their last action`)
    GameModel.update(game._id, game)
    let ordered_player_cards = TurnOrderedPlayerCardsQuery.turn_ordered_player_cards(game, player_cards)
    ordered_player_cards.shift()
Severity: Minor
Found in app/game/server/services/player_action_undoer.js - About 1 hr to fix

    Function buy_event has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static buy_event(game, player_cards, selected_cards, buy_event_processor) {
        if (!_.isEmpty(selected_cards)) {
          let card = selected_cards[0]
          if (card.name === 'Trash Token') {
            if (_.size(player_cards.hand) > 0) {
    Severity: Minor
    Found in app/game/server/services/buy_event_processor.js - About 1 hr to fix

      Function play has 36 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/ironmonger.js - About 1 hr to fix

        Function buy_event has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          static buy_event(game, player_cards, selected_cards, buy_event_processor) {
            if (!_.isEmpty(selected_cards)) {
              let card = selected_cards[0]
              if (card.name === 'Trash Token') {
                if (_.size(player_cards.hand) > 0) {
        Severity: Minor
        Found in app/game/server/services/buy_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 end_turn has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          end_turn() {
            this.game.previous_state = false
            if (this.game.turn.phase === 'action') {
              this.start_buy_events()
            }
        Severity: Minor
        Found in app/game/server/services/turn_ender.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 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          play(game, player_cards) {
            let coin_gainer = new CoinGainer(game, player_cards)
            coin_gainer.gain(1)
        
            let card_revealer = new CardRevealer(game, player_cards)
        Severity: Minor
        Found in app/cards/prosperity/loan.js - About 1 hr to fix

          Function play has 35 lines of code (exceeds 25 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

            Function nocturne has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              static nocturne() {
                return [
                  'Druid',
                  'FaithfulHound',
                  'Guardian',
            Severity: Minor
            Found in app/cards/lib/card_list.js - About 1 hr to fix

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

                  let eligible_cards = _.filter(game.cards, (card) => {
                    return card.count > 0 && card.supply && CardCostComparer.coin_less_than(game, card.top_card, 5)
                  })
              Severity: Major
              Found in app/cards/renaissance/inventor.js and 4 other locations - About 1 hr to fix
              app/cards/base/artisan.js on lines 12..14
              app/cards/base/feast.js on lines 15..17
              app/cards/base/workshop.js on lines 12..14
              app/cards/menagerie/events/demand.js on lines 12..14

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

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

                  let eligible_cards = _.filter(game.cards, (card) => {
                    return card.count > 0 && card.supply && CardCostComparer.coin_less_than(game, card.top_card, 6)
                  })
              Severity: Major
              Found in app/cards/base/feast.js and 4 other locations - About 1 hr to fix
              app/cards/base/artisan.js on lines 12..14
              app/cards/base/workshop.js on lines 12..14
              app/cards/menagerie/events/demand.js on lines 12..14
              app/cards/renaissance/inventor.js on lines 12..14

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

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

                  let eligible_cards = _.filter(game.cards, (card) => {
                    return card.count > 0 && card.supply && CardCostComparer.coin_less_than(game, card.top_card, 6)
                  })
              Severity: Major
              Found in app/cards/base/artisan.js and 4 other locations - About 1 hr to fix
              app/cards/base/feast.js on lines 15..17
              app/cards/base/workshop.js on lines 12..14
              app/cards/menagerie/events/demand.js on lines 12..14
              app/cards/renaissance/inventor.js on lines 12..14

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

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

                  let eligible_cards = _.filter(game.cards, (card) => {
                    return card.count > 0 && card.supply && CardCostComparer.coin_less_than(game, card.top_card, 5)
                  })
              Severity: Major
              Found in app/cards/menagerie/events/demand.js and 4 other locations - About 1 hr to fix
              app/cards/base/artisan.js on lines 12..14
              app/cards/base/feast.js on lines 15..17
              app/cards/base/workshop.js on lines 12..14
              app/cards/renaissance/inventor.js on lines 12..14

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

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

                  let eligible_cards = _.filter(game.cards, (card) => {
                    return card.count > 0 && card.supply && CardCostComparer.coin_less_than(game, card.top_card, 5)
                  })
              Severity: Major
              Found in app/cards/base/workshop.js and 4 other locations - About 1 hr to fix
              app/cards/base/artisan.js on lines 12..14
              app/cards/base/feast.js on lines 15..17
              app/cards/menagerie/events/demand.js on lines 12..14
              app/cards/renaissance/inventor.js on lines 12..14

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

              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

                    let eligible_cards = _.filter(game.cards, function(card) {
                      return card.count > 0 && card.supply && CardCostComparer.card_less_than(game, selected_card, card.top_card)
                    })
              Severity: Major
              Found in app/cards/promo/dismantle.js and 2 other locations - About 1 hr to fix
              app/cards/guilds/stonemason.js on lines 40..42
              app/cards/intrigue/swindler.js on lines 37..39

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

              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

                    let eligible_cards = _.filter(game.cards, function(card) {
                      return card.count > 0 && card.supply && CardCostComparer.card_equal_to(game, trashed_card, card.top_card)
                    })
              Severity: Major
              Found in app/cards/intrigue/swindler.js and 2 other locations - About 1 hr to fix
              app/cards/guilds/stonemason.js on lines 40..42
              app/cards/promo/dismantle.js on lines 40..42

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

              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

              Potion = class Potion extends Card {
              
                types() {
                  return ['treasure']
                }
              Severity: Major
              Found in app/cards/alchemy/potion.js and 1 other location - About 1 hr to fix
              app/cards/intrigue/coppersmith.js on lines 1..15

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

              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

                    let eligible_cards = _.filter(game.cards, function(card) {
                      return card.count > 0 && card.supply && CardCostComparer.card_less_than(game, selected_card, card.top_card)
                    })
              Severity: Major
              Found in app/cards/guilds/stonemason.js and 2 other locations - About 1 hr to fix
              app/cards/intrigue/swindler.js on lines 37..39
              app/cards/promo/dismantle.js on lines 40..42

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

              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

              Coppersmith = class Coppersmith extends Card {
              
                types() {
                  return ['action']
                }
              Severity: Major
              Found in app/cards/intrigue/coppersmith.js and 1 other location - About 1 hr to fix
              app/cards/alchemy/potion.js on lines 1..15

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

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

                  play(game, player_cards, player) {
                    let gained_card_count = _.size(game.turn.gained_cards)
                    if (gained_card_count > 0) {
                      let trashable_cards = _.map(player_cards.hand, function(card) {
                        let new_card = _.clone(card)
                Severity: Minor
                Found in app/cards/nocturne/monastery.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language