Showing 347 of 1,158 total issues
Function buy
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
buy(game, player_cards) {
let unique_cards = _.uniqBy(player_cards.hand, 'name')
var chosen_card
if (_.size(unique_cards) > 1) {
Function play
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
play(game, player_cards) {
let card_mover = new CardMover(game, player_cards)
let took_lost_in_the_woods = card_mover.take_unique_card('states', 'Lost In The Woods')
if (took_lost_in_the_woods) {
Function play
has 48 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)
Function process_response
has 47 lines of code (exceeds 25 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)
})
Function find_start_turn_events
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
find_start_turn_events() {
this.start_turn_events = []
_.each(this.player_cards.aside, (card) => {
if (_.includes(StartTurnEventProcessor.aside_events(), card.name)) {
Function end_turn
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
end_turn() {
this.game.previous_state = false
if (this.game.turn.phase === 'action') {
this.start_buy_events()
}
Function process_choice
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
static process_choice(game, player_cards, choice) {
if (choice[0] === 'gain') {
let eligible_cards = _.filter(game.trash, (card) => {
return _.includes(_.words(card.types), 'action')
})
Function play
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
play(game, player_cards, card_player) {
let turn_event_id = TurnEventModel.insert({
game_id: game._id,
player_id: player_cards.player_id,
username: player_cards.username,
Function play
has 46 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(1)
let victory_token_gainer = new VictoryTokenGainer(game, player_cards)
Function play
has 45 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)
let black_market_card_buyer = new BlackMarketCardBuyer(game, player_cards)
Function play
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
play(game, player_cards) {
let eligible_cards = _.filter(player_cards.hand, function(card) {
return _.includes(_.words(card.types), 'treasure')
})
if (_.size(eligible_cards) > 0) {
Function gain_event
has a Cognitive Complexity of 14 (exceeds 5 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) => {
- 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 playCard
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
playCard: function(card_id, game_id) {
Future.task(Meteor.bindEnvironment(function() {
if (!ActionLock[game_id]) {
ActionLock[game_id] = true
let current_game = game(game_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 receive
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
receive(game, player_cards) {
if (_.size(player_cards.deck) === 0 && _.size(player_cards.discard) === 0) {
game.log.push(` <strong>${player_cards.username}</strong> has no cards in deck`)
} else {
if (_.size(player_cards.deck) === 0) {
- 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 14 (exceeds 5 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')
- 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 14 (exceeds 5 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,
- 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 14 (exceeds 5 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 = []
}
- 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 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
play(game, player_cards, card_player) {
let turn_event_id = TurnEventModel.insert({
game_id: game._id,
player_id: player_cards.player_id,
username: player_cards.username,
Function play
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
play(game, player_cards) {
let eligible_trash_cards = this.trashable_cards(player_cards.hand, 'H').concat(this.trashable_cards(player_cards.discard, 'D'))
if (_.size(eligible_trash_cards) > 0) {
let turn_event_id = TurnEventModel.insert({
Function play
has 42 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)