colonizers/colonizers

View on GitHub

Showing 126 of 126 total issues

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

    var posts = this._post.slice(0).map(function(post) {
      return function(next) {
        post(event, data, function() {
          setTimeout(next, 0);
        });
Severity: Major
Found in packages/colonizers-core/lib/emitter-queue.js and 1 other location - About 1 hr to fix
packages/colonizers-core/lib/emitter-queue.js on lines 18..24

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

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

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

                            gulp.task('styles', function() {
                              return gulp
                                .src(['./server/assets/less/site.less'])
                                .pipe(less())
                                .pipe(gulp.dest('./server/assets/css'));
                            Severity: Major
                            Found in packages/colonizers/gulpfile.js and 1 other location - About 1 hr to fix
                            packages/colonizers-client/gulpfile.js on lines 49..54

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

                            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

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

                                handler: function(request, reply) {
                                  var result = request.pre.session.toSession();
                                  request.cookieAuth.set(result);
                                  reply(result);
                                }
                            Severity: Major
                            Found in packages/colonizers/server/web/login/index.js and 1 other location - About 1 hr to fix
                            packages/colonizers/server/web/login/index.js on lines 286..290

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

                            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

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

                                handler: function(request, reply) {
                                  var result = request.pre.session.toSession();
                                  request.cookieAuth.set(result);
                                  reply(result);
                                }
                            Severity: Major
                            Found in packages/colonizers/server/web/login/index.js and 1 other location - About 1 hr to fix
                            packages/colonizers/server/web/login/index.js on lines 166..170

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

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language