Showing 347 of 1,158 total issues
Function calculate
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
static calculate(game, card, buy_phase = false, player_cards = undefined) {
let cost = _.isPlainObject(card) ? card.coin_cost : card.coin_cost()
let type = _.isPlainObject(card) ? card.types : card.type_class()
let name = _.isPlainObject(card) ? card.name : card.name()
let stack_name = _.isPlainObject(card) ? card.stack_name : card.stack_name()
- Read upRead up
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 20 (exceeds 5 allowed). Consider refactoring. Open
play(game, player_cards, card_player) {
if (_.size(player_cards.hand) > 0) {
let turn_event_id = TurnEventModel.insert({
game_id: game._id,
player_id: player_cards.player_id,
- Read upRead up
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 update_phase
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
update_phase(free_play) {
if (!free_play) {
let phase
if (this.game.turn.phase === 'action' && _.includes(_.words(this.card.types), 'treasure')) {
phase = 'treasure'
Function play
has 68 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(3)
GameModel.update(game._id, game)
Function calculate
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
static calculate(game, card, buy_phase = false, player_cards = undefined) {
let cost = _.isPlainObject(card) ? card.coin_cost : card.coin_cost()
let type = _.isPlainObject(card) ? card.types : card.type_class()
let name = _.isPlainObject(card) ? card.name : card.name()
let stack_name = _.isPlainObject(card) ? card.stack_name : card.stack_name()
Function buy
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
buy(game, player_cards) {
let turn_event_id = TurnEventModel.insert({
game_id: game._id,
player_id: player_cards.player_id,
username: player_cards.username,
Function play
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
play(game, player_cards, card_player) {
let action_gainer = new ActionGainer(game, player_cards)
action_gainer.gain(1)
game.turn.self_revealed_province = false
`` has 22 functions (exceeds 20 allowed). Consider refactoring. Open
CardPlayer = class CardPlayer {
constructor(game, player_cards, card, originating_card) {
this.game = game
this.player_cards = player_cards
Function transform
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
transform: function(player_cards) {
let player_score_calculator = new PlayerScoreCalculator(player_cards)
let public_info = {
username: player_cards.username,
color: player_cards.color,
File card_player.js
has 258 lines of code (exceeds 250 allowed). Consider refactoring. Open
CardPlayer = class CardPlayer {
constructor(game, player_cards, card, originating_card) {
this.game = game
this.player_cards = player_cards
Function process_response
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
static process_response(game, player_cards, response) {
response = response[0]
if (response === 'attack') {
let attacks = _.filter(player_cards.hand, function(card) {
return _.includes(_.words(card.types), 'attack')
Function process_response
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
static process_response(game, player_cards, response, card_player) {
if (response[0] === 'discard') {
if (_.size(player_cards.hand) > 2) {
let turn_event_id = TurnEventModel.insert({
game_id: game._id,
Function gain
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
gain(amount, announce = true) {
if (this.card_player && this.card_player.chameleon) {
let card_drawer = new CardDrawer(this.game, this.player_cards)
card_drawer.draw(amount)
} else {
- Read upRead up
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 16 (exceeds 5 allowed). Consider refactoring. Open
static process_response(game, player_cards, response, card_player) {
let wild_hunt_index = _.findIndex(game.cards, (card) => {
return card.name === 'Wild Hunt'
})
- Read upRead up
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 52 lines of code (exceeds 25 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)
Function play
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
play(game, player_cards, card_player) {
if (_.size(game.hexes_deck) === 0) {
game.hexes_deck = _.shuffle(game.hexes_discard)
game.hexes_discard = []
}
Function play
has 50 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(2)
PlayerCardsModel.update(game._id, player_cards)
Function buy
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
buy(game, player_cards) {
let eligible_cards = _.filter(player_cards.hand, (card) => {
return !_.includes(_.words(card.types), 'victory')
})
Function buy
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
buy(game, player_cards) {
let horse = _.find(game.cards, (card) => {
return card.count > 0 && card.name === 'Horse'
})
Function reveal_card
has 49 lines of code (exceeds 25 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(` <strong>${player_cards.username}</strong> names ${CardView.render(selected_cards)}`)