attogram/8queens

View on GitHub

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

    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

    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

                  Avoid using undefined variables such as '$result' which will lead to PHP notices.
                  Open

                          $result[$name] = $value + $arrayB[$name];
                  Severity: Minor
                  Found in src/solve8queens.php by phpmd

                  UndefinedVariable

                  Since: 2.8.0

                  Detects when a variable is used that has not been defined before.

                  Example

                  class Foo
                  {
                      private function bar()
                      {
                          // $message is undefined
                          echo $message;
                      }
                  }

                  Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                  Avoid using undefined variables such as '$result' which will lead to PHP notices.
                  Open

                      return $result;
                  Severity: Minor
                  Found in src/solve8queens.php by phpmd

                  UndefinedVariable

                  Since: 2.8.0

                  Detects when a variable is used that has not been defined before.

                  Example

                  class Foo
                  {
                      private function bar()
                      {
                          // $message is undefined
                          echo $message;
                      }
                  }

                  Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                  Avoid using undefined variables such as '$tmp' which will lead to PHP notices.
                  Open

                          $tmp[strlen(decbin($row[$checkRow])) - 1] = 1 << ($board - $checkRow - 1);
                  Severity: Minor
                  Found in src/solve8queens_2.php by phpmd

                  UndefinedVariable

                  Since: 2.8.0

                  Detects when a variable is used that has not been defined before.

                  Example

                  class Foo
                  {
                      private function bar()
                      {
                          // $message is undefined
                          echo $message;
                      }
                  }

                  Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                  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

                            A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 33 and the first side effect is on line 3.
                            Open

                            <?php
                            Severity: Minor
                            Found in src/status.php by phpcodesniffer
                            Severity
                            Category
                            Status
                            Source
                            Language