attogram/8queens

View on GitHub
inc/cjs030/js/chessboard-0.3.0.js

Summary

Maintainability
F
6 days
Test Coverage

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 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

            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

                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 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 function.
                          Open

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

                            TODO found
                            Open

                            // TODO: write this, GitHub Issue #1
                            Severity: Minor
                            Found in inc/cjs030/js/chessboard-0.3.0.js by fixme

                            TODO found
                            Open

                            // TODO: write this, GitHub Issue #5
                            Severity: Minor
                            Found in inc/cjs030/js/chessboard-0.3.0.js by fixme

                            TODO found
                            Open

                            // TODO: this whole function could probably be replaced with a single regex
                            Severity: Minor
                            Found in inc/cjs030/js/chessboard-0.3.0.js by fixme

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                            function mouseleaveSquare(e) {
                              // do not fire this event if we are dragging a piece
                              // NOTE: this should never happen, but it's a safeguard
                              if (DRAGGING_A_PIECE !== false) return;
                            
                            
                            Severity: Major
                            Found in inc/cjs030/js/chessboard-0.3.0.js and 1 other location - About 5 hrs to fix
                            inc/cjs030/js/chessboard-0.3.0.js on lines 1578..1601

                            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 154.

                            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

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                            function mouseenterSquare(e) {
                              // do not fire this event if we are dragging a piece
                              // NOTE: this should never happen, but it's a safeguard
                              if (DRAGGING_A_PIECE !== false) return;
                            
                            
                            Severity: Major
                            Found in inc/cjs030/js/chessboard-0.3.0.js and 1 other location - About 5 hrs to fix
                            inc/cjs030/js/chessboard-0.3.0.js on lines 1603..1626

                            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 154.

                            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

                            Further Reading

                            Similar blocks of code found in 3 locations. Consider refactoring.
                            Open

                              if (cfg.hasOwnProperty('snapSpeed') !== true ||
                                  validAnimationSpeed(cfg.snapSpeed) !== true) {
                                cfg.snapSpeed = 25;
                              }
                            Severity: Minor
                            Found in inc/cjs030/js/chessboard-0.3.0.js and 2 other locations - About 35 mins to fix
                            inc/cjs030/js/chessboard-0.3.0.js on lines 453..456
                            inc/cjs030/js/chessboard-0.3.0.js on lines 457..460

                            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 46.

                            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

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                              if (cfg.sparePieces === true) {
                                html += '<div class="' + CSS.sparePieces + ' ' +
                                  CSS.sparePiecesTop + '"></div>';
                              }
                            Severity: Minor
                            Found in inc/cjs030/js/chessboard-0.3.0.js and 1 other location - About 35 mins to fix
                            inc/cjs030/js/chessboard-0.3.0.js on lines 553..556

                            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 46.

                            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

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                              if (validSquare(location) === true) {
                                $('#' + SQUARE_ELS_IDS[location]).addClass(CSS.highlight2);
                              }
                            Severity: Minor
                            Found in inc/cjs030/js/chessboard-0.3.0.js and 1 other location - About 35 mins to fix
                            inc/cjs030/js/chessboard-0.3.0.js on lines 1207..1210

                            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 46.

                            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

                            Further Reading

                            Similar blocks of code found in 3 locations. Consider refactoring.
                            Open

                              if (cfg.hasOwnProperty('snapbackSpeed') !== true ||
                                  validAnimationSpeed(cfg.snapbackSpeed) !== true) {
                                cfg.snapbackSpeed = 50;
                              }
                            Severity: Minor
                            Found in inc/cjs030/js/chessboard-0.3.0.js and 2 other locations - About 35 mins to fix
                            inc/cjs030/js/chessboard-0.3.0.js on lines 453..456
                            inc/cjs030/js/chessboard-0.3.0.js on lines 461..464

                            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 46.

                            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

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                              if (validSquare(DRAGGED_PIECE_LOCATION) === true) {
                                $('#' + SQUARE_ELS_IDS[DRAGGED_PIECE_LOCATION])
                                  .removeClass(CSS.highlight2);
                              }
                            Severity: Minor
                            Found in inc/cjs030/js/chessboard-0.3.0.js and 1 other location - About 35 mins to fix
                            inc/cjs030/js/chessboard-0.3.0.js on lines 1213..1215

                            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 46.

                            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

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                              if (cfg.sparePieces === true) {
                                html += '<div class="' + CSS.sparePieces + ' ' +
                                  CSS.sparePiecesBottom + '"></div>';
                              }
                            Severity: Minor
                            Found in inc/cjs030/js/chessboard-0.3.0.js and 1 other location - About 35 mins to fix
                            inc/cjs030/js/chessboard-0.3.0.js on lines 546..549

                            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 46.

                            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

                            Further Reading

                            Similar blocks of code found in 3 locations. Consider refactoring.
                            Open

                              if (cfg.hasOwnProperty('moveSpeed') !== true ||
                                  validAnimationSpeed(cfg.moveSpeed) !== true) {
                                cfg.moveSpeed = 200;
                              }
                            Severity: Minor
                            Found in inc/cjs030/js/chessboard-0.3.0.js and 2 other locations - About 35 mins to fix
                            inc/cjs030/js/chessboard-0.3.0.js on lines 457..460
                            inc/cjs030/js/chessboard-0.3.0.js on lines 461..464

                            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 46.

                            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

                            Further Reading

                            There are no issues that match your filters.

                            Category
                            Status