Showing 347 of 1,158 total issues
Avoid deeply nested control flow statements. Open
if (this.player_cards._id !== this.gainer.player_cards._id && _.includes(_.words(this.gainer.gained_card.types), 'victory')) {
this.gain_events.push(card)
}
Avoid deeply nested control flow statements. Open
if (_.includes(['treasure', 'buy'], this.game.turn.phase)) {
this.game.turn.phase = 'buy'
let end_buy_event_processor = new EndBuyEventProcessor(this.game, this.player_cards)
end_buy_event_processor.process()
}
Avoid deeply nested control flow statements. Open
} else if (this.card.name === 'Alchemist') {
let has_potions = _.some(this.discarder.player_cards.in_play, function(card) {
return card.name === 'Potion'
})
if (has_potions) {
Function play
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
play(game, player_cards) {
if (_.size(game.turn.gained_cards) > 1) {
let card_gainer = new CardGainer(game, player_cards, 'discard', 'Imp')
card_gainer.gain()
} else if (_.size(game.turn.gained_cards) == 1) {
- 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
Avoid deeply nested control flow statements. Open
if (!this.gainer.game.turn.innovation && _.size(gained_actions) === 1 && gained_actions[0].id === this.gainer.gained_card.id) {
this.gainer.game.turn.innovation = true
this.gain_events.push(card)
}
Function process
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
process() {
if (!_.isEmpty(this.play_card_events)) {
let mandatory_play_card_events = _.filter(this.play_card_events, (event) => {
return event.name === 'Kiln'
})
- 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
Avoid deeply nested control flow statements. Open
if (card.victory_tokens > 0) {
this.gain_events.push(card)
}
Function play_twice
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static play_twice(game, player_cards, selected_cards, disciple) {
if (!_.isEmpty(selected_cards)) {
let card_player = new CardPlayer(game, player_cards, selected_cards[0], disciple)
card_player.play(true, true, 'hand', 2)
- 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
Avoid deeply nested control flow statements. Open
if (victory_tokens > 0) {
game.cards[wild_hunt_index].victory_tokens = 0
let victory_token_gainer = new VictoryTokenGainer(game, player_cards)
victory_token_gainer.gain(victory_tokens)
}
Function play
has a Cognitive Complexity of 8 (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)
- 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
Avoid deeply nested control flow statements. Open
if (lantern || horn) {
artifact_name = lantern ? 'Horn' : 'Lantern'
} else {
GameModel.update(game._id, game)
PlayerCardsModel.update(game._id, player_cards)
Consider simplifying this complex logical expression. Open
if ((selection === 'attack' && discard_count > 0) || (selection === 'curses' && discard_count === 2) || (selection === 'cards' && discard_count === 6)) {
let card_gainer = new CardGainer(game, player_cards, 'discard', 'Gold')
card_gainer.gain()
}
Function track_gained_card
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
track_gained_card() {
if (this.game.turn.player._id === this.player_cards.player_id && !this.game.turn.possessed) {
this.game.turn.gained_cards.push(this.gained_card)
}
if (this.gained_card.name === 'Province' && !this.game.first_province) {
- 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
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
process() {
if (!_.isEmpty(this.gain_events)) {
let mandatory_gain_events = _.filter(this.gain_events, (event) => {
return _.includes(GainEventProcessor.event_cards().concat(GainEventProcessor.in_play_event_cards()).concat(GainEventProcessor.reserve_cards()).concat(GainEventProcessor.landmark_cards()).concat(GainEventProcessor.duration_attack_cards()).concat(['Trade Route', 'Cargo Ship', 'Academy', 'Guildhall', 'Road Network', 'Innovation', 'Livery', 'Invest']), event.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 discard_treasure
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static discard_treasure(game, player_cards, selected_cards) {
if (!_.isEmpty(selected_cards)) {
let card_discarder = new CardDiscarder(game, player_cards, 'hand', selected_cards)
card_discarder.discard()
- 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 create_game
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
create_game() {
let cards = this.game_cards()
let game_attributes = {
players: _.shuffle(this.players),
cards: cards,
- 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 7 (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)
- 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 trash
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
trash(announce = true) {
if (!_.isEmpty(this.cards)) {
let events = this.has_events()
if (_.size(this.cards) > 1 && events) {
let turn_event_id = TurnEventModel.insert({
- 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_turn
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
update_turn() {
if (!this.black_market) {
this.game.turn.buys -= 1
}
- 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 discard
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
discard(announce = true) {
if (!_.isEmpty(this.cards)) {
let ordered_discard = this.has_events() || this.has_schemes()
if (_.size(this.cards) > 1 && ordered_discard) {
let turn_event_id = TurnEventModel.insert({
- 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"