Showing 347 of 1,158 total issues
Function play_card
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
play_card(announce, free_play) {
let play_result
this.token_effects()
if (_.includes(_.words(this.card.types), 'action') && this.game.turn.player._id === this.player_cards.player_id) {
this.game.turn.played_actions.push(this.card)
Function play
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
play(game, player_cards, card_player) {
let buy_gainer = new BuyGainer(game, player_cards)
buy_gainer.gain(1)
_.each(['cards', 'coins'], (discard_type) => {
Function dark_ages
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static dark_ages() {
return [
'PoorHouse',
'Beggar',
'Squire',
Function kingdom_cards
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
kingdom_cards() {
let kingdom_cards = _.map(this.cards, (card) => {
return this.game_card(card, 'kingdom')
})
Function undo_action
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
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()
Function buy_event
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
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) {
Function play
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
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 buy_event
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
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) {
- 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 end_turn
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
end_turn() {
this.game.previous_state = false
if (this.game.turn.phase === 'action') {
this.start_buy_events()
}
- 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 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
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)
Function play
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
play(game, player_cards) {
let gained_coin = 2
if (game.turn.envious) {
gained_coin = 1
}
Function nocturne
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static nocturne() {
return [
'Druid',
'FaithfulHound',
'Guardian',
Function gain_event
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
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) => {
Function play
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
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)
Function play
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
play(game, player_cards, card_player) {
let card_drawer = new CardDrawer(game, player_cards, card_player)
card_drawer.draw(3)
let buy_gainer = new BuyGainer(game, player_cards)
Function update_player_rankings
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
update_player_rankings() {
if (_.size(this.game.players) === 2) {
let usernames = _.map(this.game.players, 'username')
let player_rankings = PlayerRankings.find({username: {$in: usernames}}).fetch()
_.each(player_rankings, (player_ranking) => {
Function play
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
play(game, player_cards, card_player) {
let action_gainer = new ActionGainer(game, player_cards)
action_gainer.gain(1)
let trashable_cards = _.map(player_cards.hand, function(card) {
Function overpay
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static overpay(game, player_cards, amount) {
amount = Number(amount)
if (amount > 0) {
game.log.push(` <strong>${player_cards.username}</strong> overpays by $${amount}`)
game.turn.coins -= amount
Function between_turn_event
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
between_turn_event(game, player_cards, mountain_pass) {
game.log.push(`Bidding on ${CardView.render(mountain_pass)}`)
GameModel.update(game._id, game)
game.mountain_pass = {
Function play
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
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,