colonizers/colonizers

View on GitHub

Showing 51 of 126 total issues

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

  getTileLayout(layout) {
    var circumradius = hexInfo.circumradius;
    var apothem = hexInfo.apothem;

    var tiles = layout.tiles.map(row => row.split(','));
Severity: Minor
Found in packages/colonizers-core/lib/scenario-builder.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 packages/colonizers-core/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 packages/colonizers-core/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 UserInterface has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function UserInterface(options) {
        this.emit = this.emit.bind(this);
        this.onBoardClick = this.onBoardClick.bind(this);
        this.onBuildSettlement = this.onBuildSettlement.bind(this);
        this.onBuildCity = this.onBuildCity.bind(this);
      Severity: Minor
      Found in packages/colonizers-client/lib/user-interface.js - About 1 hr to fix

        Function start has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        RoomSchema.methods.start = function(callback) {
          if (this.status !== 'open') {
            return;
          }
        
        
        Severity: Minor
        Found in packages/colonizers/server/schema/room.js - About 1 hr to fix

          Function getBuildableEdgesForPlayer has 30 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 packages/colonizers-core/lib/game-objects/game.js - About 1 hr to fix

            Function show has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              Tab.prototype.show = function () {
                var $this    = this.element
                var $ul      = $this.closest('ul:not(.dropdown-menu)')
                var selector = $this.data('target')
            
            
            Severity: Minor
            Found in packages/colonizers/server/assets/js/jquery-plugins.js - About 1 hr to fix

              Function defineObservableProperties has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function defineObservableProperties(obj, properties) {
                obj._observables = obj._observables || {};
              
                if (!obj.getObservable) {
                  obj.getObservable = function getObservable(observableName) {
              Severity: Minor
              Found in packages/colonizers-client/lib/game/observable-properties.js - About 1 hr to fix

                Function handler has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    handler: function(request, reply) {
                      var Room = mongoose.model('Room');
                
                      Room.findById(request.params.roomId, function(err, room) {
                        if (err) {
                Severity: Minor
                Found in packages/colonizers/server/web/room/index.js - About 1 hr to fix

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

                    buildCity(player) {
                      super.buildCity(player);
                  
                      if (this.drawing) {
                        this.drawing.destroy();
                  Severity: Minor
                  Found in packages/colonizers-client/lib/game/hex-corner.js - About 1 hr to fix

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

                      hasAllowance(object) {
                        return function(req, next) {
                          var objects = [];
                          var yes = false;
                    
                    
                    Severity: Minor
                    Found in packages/colonizers-core/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 packages/colonizers-core/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 onWiiuInput has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                      StageNavigator.prototype.onWiiuInput = function() {
                        var state = window.wiiu.gamepad.update();
                        var dragX = 0;
                        var dragY = 0;
                        var rotate = 0;
                      Severity: Minor
                      Found in packages/colonizers-client/lib/stage-navigator.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 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 packages/colonizers-core/lib/game-serializer.js - About 1 hr to fix

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

                          buildSettlement(player) {
                            super.buildSettlement(player);
                        
                            if (this.drawing) {
                              this.drawing.destroy();
                        Severity: Minor
                        Found in packages/colonizers-client/lib/game/hex-corner.js - About 1 hr to fix

                          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 packages/colonizers-core/lib/scenario-builder.js - About 1 hr to fix

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

                              onStageTransform(transform) {
                                var offset;
                            
                                if (this.transforming) {
                                  return;
                            Severity: Minor
                            Found in packages/colonizers-client/lib/game/board.js - About 1 hr to fix

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

                                  function next() {
                                    $active
                                      .removeClass('active')
                                      .find('> .dropdown-menu > .active')
                                        .removeClass('active')
                              Severity: Minor
                              Found in packages/colonizers/server/assets/js/jquery-plugins.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 packages/colonizers-core/lib/emitter-queue.js - About 1 hr to fix

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

                                    distributeResources(req, diceTotal, next) {
                                      var data = {};
                                      var tiles = this.game.board.tiles.query({ value: diceTotal });
                                  
                                      this.game.players.forEach(function(player) {
                                  Severity: Minor
                                  Found in packages/colonizers-core/lib/controller/index.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language