Showing 15 of 31 total issues
Function constructor
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(game) {
super();
let gameStarted = false,
drawsTwo = null;
Function chooseCard
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function chooseCard(player) {
return new Promise((resolve, reject) => {
var playableCards = this.game.rules.pickPlayableCards(player.hand),
otherCards = player.hand
.pickCards(function (card) {
Function suggestCard
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function suggestCard(availableCards, playableCards) {
// Decomposition operation should not increase the statement count,
// moving handling of sevens and aces to a separate method would
// make the code less legible.
/*eslint max-statements: [2, 20]*/
- 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 constructor
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor() {
super();
var cards = [
new Card(Suits.leaves, Ranks.seven),
Function suggestCard
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function suggestCard(availableCards, playableCards) {
// Decomposition operation should not increase the statement count,
// moving handling of sevens and aces to a separate method would
// make the code less legible.
/*eslint max-statements: [2, 20]*/
Function getSevenCoverCount
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getSevenCoverCount(seven, availableCards) {
var otherCards = availableCards.filter(function (card) {
return card !== seven;
}),
// Check if the seven can be covered by a card, which lets
Function getAceCoverCount
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getAceCoverCount(ace, availableCards) {
var otherCards = availableCards.filter(function (card) {
return card !== ace;
}),
// Check if the ace can be covered by a card, which lets
Function suggestSuit
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function suggestSuit(chosenCard, availableCards) {
// Cards remaining in hand after playing the queen
var otherCards = availableCards.filter(function (card) {
return card !== chosenCard.card;
}),
Function getSevenCoverCount
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getSevenCoverCount(seven, availableCards) {
var otherCards = availableCards.filter(function (card) {
return card !== seven;
}),
// Check if the seven can be covered by a card, which lets
- 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 removeListener
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function removeListener(event, listener, listeners, index, once, onceIndex) {
Function getAceCoverCount
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getAceCoverCount(ace, availableCards) {
var otherCards = availableCards.filter(function (card) {
return card !== ace;
}),
// Check if the ace can be covered by a card, which lets
- 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 letTopCardAffectPlayer
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function letTopCardAffectPlayer() {
var topCard = checkNewTopCard.call(this);
// The top card on the playing stack affects the current
// player only once, first when it turns up there
if (topCard) {
- 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 parseHumanIndex
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function parseHumanIndex(human, playerCount) {
if (human === 'random') {
return 1 + Math.trunc(Math.random() * playerCount);
}
if (human != null) {
- 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 setLocaleSafely
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
setLocaleSafely(locale) {
var parsedLocale = /^[a-zA-Z]+/.exec(locale);
if (parsedLocale) {
parsedLocale = parsedLocale[0];
if (parsedLocale !== 'en') {
- 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 suggestCard
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function suggestCard(availableCards, playableCards) {
// No playable card found will mean drawing a new one
if (!playableCards.length) {
return;
}
- 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"