colonizers/colonizers

View on GitHub

Showing 51 of 126 total issues

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 packages/colonizers-core/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 packages/colonizers-core/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(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 packages/colonizers-core/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 animate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    DieModel.prototype.animate = function(sequence) {
      var numNumbers = sequence.length;
      var state = 'die';
    
      if (numNumbers % 2 === 0) {
    Severity: Minor
    Found in packages/colonizers-client/lib/components/d6.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 packages/colonizers-core/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

    Avoid too many return statements within this function.
    Open

      return this.players.find(player => player.id === userId);
    Severity: Major
    Found in packages/colonizers-client/lib/model/index.js - About 30 mins to fix

      Function render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        render(options, tileset) {
          var tileStyle = tileset.tiles[options.type];
          var tileSpacing = tileset.board.tilespacing || 8;
          var hexagonOpts = this.getHexOptions(
            tileStyle,
      Severity: Minor
      Found in packages/colonizers-client/lib/game/hex-tile.js - About 25 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 onTurnStart has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      UserInterface.prototype.onTurnStart = function() {
        if (!this.viewModel.myTurn) {
          return;
        }
      
      
      Severity: Minor
      Found in packages/colonizers-client/lib/user-interface.js - About 25 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 register has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.register = function(server, options, next) {
        server.route({
          method: 'GET',
          path: '/logout',
          config: {
      Severity: Minor
      Found in packages/colonizers/server/web/login/index.js - About 25 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 defineObservableProperty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function defineObservableProperty(obj, propertyName, value) {
        var isComputed = typeof value === 'function';
        var isArray = Array.isArray(value);
        var observable;
      
      
      Severity: Minor
      Found in packages/colonizers-client/lib/game/observable-properties.js - About 25 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 defineObservableProperties has a Cognitive Complexity of 6 (exceeds 5 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 25 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