colonizers/colonizers-core

View on GitHub

Showing 18 of 48 total issues

Function getScenario has 112 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  getScenario() {
    var circumradius = hexInfo.circumradius;
    var apothem = hexInfo.apothem;
    var layout = this.getLayout();
    var numberTokens = layout.numberTokens;
Severity: Major
Found in lib/scenario-builder.js - About 4 hrs to fix

    File index.js has 277 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    var _ = require('underscore');
    var BaseController = require('./base');
    
    
    Severity: Minor
    Found in lib/controller/index.js - About 2 hrs to fix

      Function initRoad has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        initRoad: function(req, next) {
          var board = this.game.board;
          var ownedEdges = board.edges.query({ owner: req.player });
          var distributeResources = ownedEdges.length === 1;
          var data = {};
      Severity: Minor
      Found in lib/controller/index.js - About 1 hr to fix

        Function getTileLayout has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          getTileLayout(layout) {
            var circumradius = hexInfo.circumradius;
            var apothem = hexInfo.apothem;
        
            var tiles = layout.tiles.map(function(row) {
        Severity: Minor
        Found in lib/scenario-builder.js - About 1 hr to fix

          Function serializeBoard has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            serializeBoard(board) {
              var tiles = board.tiles.map(function(tile) {
                return {
                  id: tile.id,
                  center: tile.center,
          Severity: Minor
          Found in lib/game-serializer.js - About 1 hr to fix

            Function getBuildableEdgesForPlayer has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              getBuildableEdgesForPlayer(player, cornerId) {
                if (this.phase === 'setup') {
                  var corner;
            
                  if (cornerId != null) {
            Severity: Minor
            Found in lib/game-objects/game.js - About 1 hr to fix

              Function deserializeBoard has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                deserializeBoard(data) {
                  var board = this.factory.createBoard({
                    height: data.height,
                    width: data.width,
                    hexInfo: data.hex
              Severity: Minor
              Found in lib/game-serializer.js - About 1 hr to fix

                Function deserializePlayer has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  deserializePlayer(data, index) {
                    var player = this.factory.createPlayer({
                      id: data.id,
                      index: index
                    });
                Severity: Minor
                Found in lib/game-serializer.js - About 1 hr 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 hasAllowance has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  hasAllowance: function(object) {
                    return function(req, next) {
                      var objects = [];
                      var yes = false;
                
                
                Severity: Minor
                Found in lib/controller/index.js - About 1 hr to fix

                  Function constructor has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    constructor(options, done) {
                      var factory = options.factory || new Factory();
                  
                      this.gameSerializer = new GameSerializer(factory);
                      this.game = this.gameSerializer.deserialize(options.game);
                  Severity: Minor
                  Found in lib/game-context.js - About 1 hr 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 processEdges has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    processEdges(board, edges) {
                      var edges1 = _.chain(edges)
                        .map(function(edge) {
                          return {
                            center: edge.center,
                  Severity: Minor
                  Found in lib/scenario-builder.js - About 1 hr to fix

                    Function deserializePlayer has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      deserializePlayer(data, index) {
                        var player = this.factory.createPlayer({
                          id: data.id,
                          index: index
                        });
                    Severity: Minor
                    Found in lib/game-serializer.js - About 1 hr to fix

                      Function getTasks has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        getTasks(event, data) {
                          var listeners = this.callbacks[event] || [];
                      
                          var pres = this._pre.slice(0).map(function(pre) {
                            return function(next) {
                      Severity: Minor
                      Found in lib/emitter-queue.js - About 1 hr to fix

                        Function constructor has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          constructor(options, done) {
                            var factory = options.factory || new Factory();
                        
                            this.gameSerializer = new GameSerializer(factory);
                            this.game = this.gameSerializer.deserialize(options.game);
                        Severity: Minor
                        Found in lib/game-context.js - About 1 hr to fix

                          Function getDataForTurn has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                            getDataForTurn(turn) {
                              var phase = 'waiting';
                              var playerIndex = null;
                              var prevTurn;
                          
                          
                          Severity: Minor
                          Found in lib/game-objects/game.js - About 55 mins 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 initRoad has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                            initRoad: function(req, next) {
                              var board = this.game.board;
                              var ownedEdges = board.edges.query({ owner: req.player });
                              var distributeResources = ownedEdges.length === 1;
                              var data = {};
                          Severity: Minor
                          Found in lib/controller/index.js - About 45 mins 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 hasAllowance has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                            hasAllowance: function(object) {
                              return function(req, next) {
                                var objects = [];
                                var yes = false;
                          
                          
                          Severity: Minor
                          Found in lib/controller/index.js - About 45 mins 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 getBuildableEdgesForPlayer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            getBuildableEdgesForPlayer(player, cornerId) {
                              if (this.phase === 'setup') {
                                var corner;
                          
                                if (cornerId != null) {
                          Severity: Minor
                          Found in lib/game-objects/game.js - About 35 mins 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

                          Severity
                          Category
                          Status
                          Source
                          Language