Showing 26 of 248 total issues
File chessboard-0.3.0.js
has 1067 lines of code (exceeds 275 allowed). Consider refactoring. Open
Open
/*!
* chessboard.js v0.3.0
*
* Copyright 2013 Chris Oakman
* Released under the MIT license
Function queens_under_attack
has a Cognitive Complexity of 25 (exceeds 11 allowed). Consider refactoring. Open
Open
function queens_under_attack($board)
{
global $attacked; // for display outside of this function
if (!is_array($board)) {
return 'ERROR';
- 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 expandConfig
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function expandConfig() {
if (typeof cfg === 'string' || validPositionObject(cfg) === true) {
cfg = {
position: cfg
};
Function calculateAnimations
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function calculateAnimations(pos1, pos2) {
// make copies of both
pos1 = deepCopy(pos1);
pos2 = deepCopy(pos2);
Function buildBoard
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function buildBoard(orientation) {
if (orientation !== 'black') {
orientation = 'white';
}
Function checkDeps
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function checkDeps() {
// if containerId is a string, it must be the ID of a DOM node
if (typeof containerElOrId === 'string') {
// cannot be empty
if (containerElOrId === '') {
Method queens_under_attack
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function queens_under_attack($board)
{
global $attacked; // for display outside of this function
if (!is_array($board)) {
return 'ERROR';
Function stopDraggedPiece
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function stopDraggedPiece(location) {
// determine what the action should be
var action = 'drop';
if (location === 'offboard' && cfg.dropOffBoard === 'snapback') {
action = 'snapback';
Function doAnimations
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function doAnimations(a, oldPos, newPos) {
ANIMATION_HAPPENING = true;
var numFinished = 0;
function onFinish() {
Method findRotation
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function findRotation($row, $board, $solutions)
{
$tmp = rotateBoard($row, $board); // Rotated 90
if (!in_array($tmp, $solutions)) {
$solutions[] = $tmp;
Function position
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
widget.position = function(position, useAnimation) {
// no arguments, return the current position
if (arguments.length === 0) {
return deepCopy(CURRENT_POSITION);
}
Function objToFen
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function objToFen(obj) {
if (validPositionObject(obj) !== true) {
return false;
}
Function animateSquareToSquare
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function animateSquareToSquare(src, dest, piece, completeFn) {
// get information about the source and destination squares
var srcSquareEl = $('#' + SQUARE_ELS_IDS[src]);
var srcSquarePosition = srcSquareEl.offset();
var destSquareEl = $('#' + SQUARE_ELS_IDS[dest]);
Function beginDraggingPiece
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function beginDraggingPiece(source, piece, x, y) {
// run their custom onDragStart function
// their custom onDragStart function can cancel drag start
if (typeof cfg.onDragStart === 'function' &&
cfg.onDragStart(source, piece,
Avoid too many return
statements within this method. Open
Open
return 'd';
Avoid too many return
statements within this function. Open
Open
return true;
Avoid too many return
statements within this method. Open
Open
return 4;
Avoid too many return
statements within this function. Open
Open
return false;
Avoid too many return
statements within this method. Open
Open
return 'f';
Avoid too many return
statements within this method. Open
Open
return 8;