colonizers/colonizers-core

View on GitHub

Showing 48 of 48 total issues

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

  getAdjacentCorners() {
    return this.spatialQuery((board) => {
      return {
        collection: board.corners,
        radius: board.hexInfo.circumradius * 0.6,
Severity: Major
Found in lib/game-objects/hex-edge.js and 7 other locations - About 1 hr to fix
lib/game-objects/hex-corner.js on lines 31..39
lib/game-objects/hex-corner.js on lines 41..49
lib/game-objects/hex-corner.js on lines 51..59
lib/game-objects/hex-edge.js on lines 31..39
lib/game-objects/hex-edge.js on lines 41..49
lib/game-objects/hex-tile.js on lines 25..33
lib/game-objects/hex-tile.js on lines 35..43

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

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

  getAdjacentTiles() {
    return this.spatialQuery((board) => {
      return {
        collection: board.tiles,
        radius: board.hexInfo.circumradius * 1.1,
Severity: Major
Found in lib/game-objects/hex-corner.js and 7 other locations - About 1 hr to fix
lib/game-objects/hex-corner.js on lines 41..49
lib/game-objects/hex-corner.js on lines 51..59
lib/game-objects/hex-edge.js on lines 21..29
lib/game-objects/hex-edge.js on lines 31..39
lib/game-objects/hex-edge.js on lines 41..49
lib/game-objects/hex-tile.js on lines 25..33
lib/game-objects/hex-tile.js on lines 35..43

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

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

    var pres = this._pre.slice(0).map(function(pre) {
      return function(next) {
        pre(event, data, function() {
          setTimeout(next, 0);
        });
Severity: Major
Found in lib/emitter-queue.js and 1 other location - About 1 hr to fix
lib/emitter-queue.js on lines 34..40

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

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

  getAdjacentCorners() {
    return this.spatialQuery((board) => {
      return {
        collection: board.corners,
        radius: board.hexInfo.circumradius * 1.1,
Severity: Major
Found in lib/game-objects/hex-tile.js and 7 other locations - About 1 hr to fix
lib/game-objects/hex-corner.js on lines 31..39
lib/game-objects/hex-corner.js on lines 41..49
lib/game-objects/hex-corner.js on lines 51..59
lib/game-objects/hex-edge.js on lines 21..29
lib/game-objects/hex-edge.js on lines 31..39
lib/game-objects/hex-edge.js on lines 41..49
lib/game-objects/hex-tile.js on lines 25..33

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

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

  getAdjacentEdges() {
    return this.spatialQuery((board) => {
      return {
        collection: board.edges,
        radius: board.hexInfo.apothem * 1.1,
Severity: Major
Found in lib/game-objects/hex-edge.js and 7 other locations - About 1 hr to fix
lib/game-objects/hex-corner.js on lines 31..39
lib/game-objects/hex-corner.js on lines 41..49
lib/game-objects/hex-corner.js on lines 51..59
lib/game-objects/hex-edge.js on lines 21..29
lib/game-objects/hex-edge.js on lines 41..49
lib/game-objects/hex-tile.js on lines 25..33
lib/game-objects/hex-tile.js on lines 35..43

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

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

  getAdjacentTiles() {
    return this.spatialQuery((board) => {
      return {
        collection: board.tiles,
        radius: board.hexInfo.apothem * 2.1,
Severity: Major
Found in lib/game-objects/hex-tile.js and 7 other locations - About 1 hr to fix
lib/game-objects/hex-corner.js on lines 31..39
lib/game-objects/hex-corner.js on lines 41..49
lib/game-objects/hex-corner.js on lines 51..59
lib/game-objects/hex-edge.js on lines 21..29
lib/game-objects/hex-edge.js on lines 31..39
lib/game-objects/hex-edge.js on lines 41..49
lib/game-objects/hex-tile.js on lines 35..43

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

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

  getAdjacentCorners() {
    return this.spatialQuery((board) => {
      return {
        collection: board.corners,
        radius: board.hexInfo.circumradius * 1.1,
Severity: Major
Found in lib/game-objects/hex-corner.js and 7 other locations - About 1 hr to fix
lib/game-objects/hex-corner.js on lines 31..39
lib/game-objects/hex-corner.js on lines 51..59
lib/game-objects/hex-edge.js on lines 21..29
lib/game-objects/hex-edge.js on lines 31..39
lib/game-objects/hex-edge.js on lines 41..49
lib/game-objects/hex-tile.js on lines 25..33
lib/game-objects/hex-tile.js on lines 35..43

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

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

  getAdjacentEdges() {
    return this.spatialQuery((board) => {
      return {
        collection: board.edges,
        radius: board.hexInfo.circumradius * 0.6,
Severity: Major
Found in lib/game-objects/hex-corner.js and 7 other locations - About 1 hr to fix
lib/game-objects/hex-corner.js on lines 31..39
lib/game-objects/hex-corner.js on lines 41..49
lib/game-objects/hex-edge.js on lines 21..29
lib/game-objects/hex-edge.js on lines 31..39
lib/game-objects/hex-edge.js on lines 41..49
lib/game-objects/hex-tile.js on lines 25..33
lib/game-objects/hex-tile.js on lines 35..43

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

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

  getAdjacentTiles() {
    return this.spatialQuery((board) => {
      return {
        collection: board.tiles,
        radius: board.hexInfo.apothem * 1.1,
Severity: Major
Found in lib/game-objects/hex-edge.js and 7 other locations - About 1 hr to fix
lib/game-objects/hex-corner.js on lines 31..39
lib/game-objects/hex-corner.js on lines 41..49
lib/game-objects/hex-corner.js on lines 51..59
lib/game-objects/hex-edge.js on lines 21..29
lib/game-objects/hex-edge.js on lines 31..39
lib/game-objects/hex-tile.js on lines 25..33
lib/game-objects/hex-tile.js on lines 35..43

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

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 lib/emitter-queue.js and 1 other location - About 1 hr to fix
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 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

                Severity
                Category
                Status
                Source
                Language