attogram/8queens

View on GitHub

Showing 26 of 248 total issues

File chessboard-0.3.0.js has 1067 lines of code (exceeds 275 allowed). Consider refactoring.
Open

/*!
 * chessboard.js v0.3.0
 *
 * Copyright 2013 Chris Oakman
 * Released under the MIT license
Severity: Major
Found in inc/cjs030/js/chessboard-0.3.0.js - About 2 days to fix

    Function queens_under_attack has a Cognitive Complexity of 25 (exceeds 11 allowed). Consider refactoring.
    Open

    function queens_under_attack($board)
    {
        global $attacked; // for display outside of this function
        if (!is_array($board)) {
            return 'ERROR';
    Severity: Minor
    Found in src/status.php - About 2 hrs to fix

    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

    function expandConfig() {
      if (typeof cfg === 'string' || validPositionObject(cfg) === true) {
        cfg = {
          position: cfg
        };
    Severity: Major
    Found in inc/cjs030/js/chessboard-0.3.0.js - About 2 hrs to fix

      Function calculateAnimations has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function calculateAnimations(pos1, pos2) {
        // make copies of both
        pos1 = deepCopy(pos1);
        pos2 = deepCopy(pos2);
      
      
      Severity: Minor
      Found in inc/cjs030/js/chessboard-0.3.0.js - About 1 hr to fix

        Function buildBoard has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function buildBoard(orientation) {
          if (orientation !== 'black') {
            orientation = 'white';
          }
        
        
        Severity: Minor
        Found in inc/cjs030/js/chessboard-0.3.0.js - About 1 hr to fix

          Function checkDeps has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          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 === '') {
          Severity: Minor
          Found in inc/cjs030/js/chessboard-0.3.0.js - About 1 hr to fix

            Method queens_under_attack has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function queens_under_attack($board)
            {
                global $attacked; // for display outside of this function
                if (!is_array($board)) {
                    return 'ERROR';
            Severity: Minor
            Found in src/status.php - About 1 hr to fix

              Function stopDraggedPiece has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function stopDraggedPiece(location) {
                // determine what the action should be
                var action = 'drop';
                if (location === 'offboard' && cfg.dropOffBoard === 'snapback') {
                  action = 'snapback';
              Severity: Minor
              Found in inc/cjs030/js/chessboard-0.3.0.js - About 1 hr to fix

                Function doAnimations has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function doAnimations(a, oldPos, newPos) {
                  ANIMATION_HAPPENING = true;
                
                  var numFinished = 0;
                  function onFinish() {
                Severity: Minor
                Found in inc/cjs030/js/chessboard-0.3.0.js - About 1 hr to fix

                  Method findRotation has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function findRotation($row, $board, $solutions)
                  {
                      $tmp = rotateBoard($row, $board);  // Rotated 90
                      if (!in_array($tmp, $solutions)) {
                          $solutions[] = $tmp;
                  Severity: Minor
                  Found in src/solve8queens_2.php - About 1 hr to fix

                    Function position has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    widget.position = function(position, useAnimation) {
                      // no arguments, return the current position
                      if (arguments.length === 0) {
                        return deepCopy(CURRENT_POSITION);
                      }
                    Severity: Minor
                    Found in inc/cjs030/js/chessboard-0.3.0.js - About 1 hr to fix

                      Function objToFen has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function objToFen(obj) {
                        if (validPositionObject(obj) !== true) {
                          return false;
                        }
                      
                      
                      Severity: Minor
                      Found in inc/cjs030/js/chessboard-0.3.0.js - About 1 hr to fix

                        Function animateSquareToSquare has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        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]);
                        Severity: Minor
                        Found in inc/cjs030/js/chessboard-0.3.0.js - About 1 hr to fix

                          Function beginDraggingPiece has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          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,
                          Severity: Minor
                          Found in inc/cjs030/js/chessboard-0.3.0.js - About 1 hr to fix

                            Avoid too many return statements within this method.
                            Open

                                        return 'd';
                            Severity: Major
                            Found in src/solve8queens_2.php - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                return true;
                              Severity: Major
                              Found in inc/cjs030/js/chessboard-0.3.0.js - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return 4;
                                Severity: Major
                                Found in src/status.php - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                      return false;
                                  Severity: Major
                                  Found in inc/cjs030/js/chessboard-0.3.0.js - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return 'f';
                                    Severity: Major
                                    Found in src/solve8queens_2.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                  return 8;
                                      Severity: Major
                                      Found in src/status.php - About 30 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language