Showing 1,158 of 1,158 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
this.game.log.push(`<strong>${this.player_cards.username}</strong> puts ${CardView.render(this.player_cards.possession_trash)} in their discard`)
- Read upRead up
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 56.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function play
has 26 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 play
has 26 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)
GameModel.update(game._id, game)
Function play
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
play(game, player_cards, card_player) {
let buy_gainer = new BuyGainer(game, player_cards)
buy_gainer.gain(1)
let coin_gainer = new CoinGainer(game, player_cards, card_player)
Function star_chart
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
star_chart() {
this.star_chart_card = _.find(this.player_cards.projects, (project) => {
return project.name === 'Star Chart'
})
if (this.star_chart_card) {
Function discard
has 26 lines of code (exceeds 25 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({
Function play
has 26 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)
let action_gainer = new ActionGainer(game, player_cards)
Function trash_card
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
static trash_card(game, player_cards, selected_cards) {
let eligible_cards = _.filter(game.cards, (card) => {
return card.count > 0 && card.supply && CardCostComparer.card_less_than(game, selected_cards[0], card.top_card, 4)
})
Function pay_tokens
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
static pay_tokens(game, player_cards, amount, trashed_card) {
amount = Number(amount)
let coffer_text = amount === 1 ? 'Coffer' : 'Coffers'
game.log.push(` <strong>${player_cards.username}</strong> removes ${amount} ${coffer_text}`)
player_cards.coffers -= amount
Function play
has 26 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)
let action_gainer = new ActionGainer(game, player_cards)
Function play
has 26 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 card_trasher = new CardTrasher(game, player_cards, 'in_play', card_player.card)
Function discard_cards
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
static discard_cards(game, player_cards, selected_cards) {
if (_.size(selected_cards) === 0) {
game.log.push(` but does not discard anything`)
} else {
let card_discarder = new CardDiscarder(game, player_cards, 'hand', selected_cards)
Function overpay
has 26 lines of code (exceeds 25 allowed). Consider refactoring. 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 play
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
play(game, player_cards) {
let previous_player_query = new PreviousPlayerQuery(game, player_cards.player_id)
let previous_player_cards = PlayerCardsModel.findOne(game._id, previous_player_query.previous_player()._id)
let eligible_cards = _.filter(previous_player_cards.last_turn_gained_cards, function(gained_card) {
Function trash_card
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
static trash_card(game, player_cards, selected_cards) {
if (!_.isEmpty(selected_cards)) {
let card_trasher = new CardTrasher(game, player_cards, 'hand', selected_cards[0])
card_trasher.trash()
Function play
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
play(game, player_cards, card_player) {
let copper = _.find(player_cards.hand, (card) => {
return card.name === 'Copper'
})
Function empires
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
static empires() {
return [
'Engineer',
'CityQuarter',
'Overlord',
Function start_turn_event
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
start_turn_event(game, player_cards, sinister_plot) {
game.log.push(`<strong>${player_cards.username}</strong> resolves ${CardView.render(sinister_plot)}`)
let turn_event_id = TurnEventModel.insert({
game_id: game._id,
Identical blocks of code found in 2 locations. Consider refactoring. Open
let trashable_cards = _.map(player_cards.hand, function(card) {
let new_card = _.clone(card)
new_card.source = 'H'
return new_card
})
- Read upRead up
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 55.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
let trashable_cards = _.map(player_cards.hand, function(card) {
let new_card = _.clone(card)
new_card.source = 'H'
return new_card
})
- Read upRead up
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 55.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76