grrrisu/Simulator

View on GitHub

Showing 15 of 15 total issues

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

    socket.on('net-status', (data) => {
      let status_css = "";
      if(data.key == 'server_connected'){
        status_css = "alert-success";
      } else {
Severity: Major
Found in examples/node/game_of_life/game.js and 1 other location - About 2 hrs to fix
examples/node/monitor/game.js on lines 67..75

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

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

    socket.on('net-status', (data) => {
      let status_css = "";
      if(data.key == 'server_connected'){
        status_css = "alert-success";
      } else {
Severity: Major
Found in examples/node/monitor/game.js and 1 other location - About 2 hrs to fix
examples/node/game_of_life/game.js on lines 24..32

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

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 dispatch has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  dispatch(socket) {
    socket.on_connect_error( (data) => {
      $('#net-status').html('<div class="message alert alert-danger">middleware not available</div>');
    });

Severity: Minor
Found in examples/node/monitor/game.js - About 1 hr to fix

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

        $('#button-start').on('click', (e) => {
          e.preventDefault();
          let message = {"scope": "game_of_life", "action": "start"}
          this.socket.send_message(message);
        });
    Severity: Major
    Found in examples/node/game_of_life/controller.js and 1 other location - About 1 hr to fix
    examples/node/game_of_life/controller.js on lines 28..32

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

    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

        $('#button-stop').on('click', (e) => {
          e.preventDefault();
          let message = {"scope": "game_of_life", "action": "stop"}
          this.socket.send_message(message);
        });
    Severity: Major
    Found in examples/node/game_of_life/controller.js and 1 other location - About 1 hr to fix
    examples/node/game_of_life/controller.js on lines 22..26

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

    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 connect has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.connect = function(server, socket_file){
    
      const io = require('socket.io')(server);
    
      let player_id = null;
    Severity: Minor
    Found in node/lib/web_socket.js - About 1 hr to fix

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

          $('#monitor-unsubscribe').on('click', function(e){
            e.preventDefault();
            let action = {"scope": "monitor", "action": "unsubscribe"}
            socket.send_message(action);
          });
      Severity: Major
      Found in examples/node/monitor/monitor_controller.js and 4 other locations - About 1 hr to fix
      examples/node/monitor/monitor_controller.js on lines 18..22
      examples/node/monitor/monitor_controller.js on lines 24..28
      examples/node/monitor/monitor_controller.js on lines 30..34
      examples/node/monitor/monitor_controller.js on lines 42..46

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

      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 5 locations. Consider refactoring.
      Open

          $('#monitor-snapshot').on('click', function(e){
            e.preventDefault();
            let action = {"scope": "monitor", "action": "snapshot"}
            socket.send_message(action);
          });
      Severity: Major
      Found in examples/node/monitor/monitor_controller.js and 4 other locations - About 1 hr to fix
      examples/node/monitor/monitor_controller.js on lines 18..22
      examples/node/monitor/monitor_controller.js on lines 24..28
      examples/node/monitor/monitor_controller.js on lines 30..34
      examples/node/monitor/monitor_controller.js on lines 36..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 61.

      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 5 locations. Consider refactoring.
      Open

          $('#button-wait').on('click', function(e){
            e.preventDefault();
            let action = {"scope": "example", "action": "wait"}
            socket.send_message(action);
          });
      Severity: Major
      Found in examples/node/monitor/monitor_controller.js and 4 other locations - About 1 hr to fix
      examples/node/monitor/monitor_controller.js on lines 18..22
      examples/node/monitor/monitor_controller.js on lines 30..34
      examples/node/monitor/monitor_controller.js on lines 36..40
      examples/node/monitor/monitor_controller.js on lines 42..46

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

      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 5 locations. Consider refactoring.
      Open

          $('#button-crash').on('click', function(e){
            e.preventDefault();
            let action = {"scope": "example", "action": "crash"}
            socket.send_message(action);
          });
      Severity: Major
      Found in examples/node/monitor/monitor_controller.js and 4 other locations - About 1 hr to fix
      examples/node/monitor/monitor_controller.js on lines 24..28
      examples/node/monitor/monitor_controller.js on lines 30..34
      examples/node/monitor/monitor_controller.js on lines 36..40
      examples/node/monitor/monitor_controller.js on lines 42..46

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

      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 5 locations. Consider refactoring.
      Open

          $('#monitor-subscribe').on('click', function(e){
            e.preventDefault();
            let action = {"scope": "monitor", "action": "subscribe"}
            socket.send_message(action);
          });
      Severity: Major
      Found in examples/node/monitor/monitor_controller.js and 4 other locations - About 1 hr to fix
      examples/node/monitor/monitor_controller.js on lines 18..22
      examples/node/monitor/monitor_controller.js on lines 24..28
      examples/node/monitor/monitor_controller.js on lines 36..40
      examples/node/monitor/monitor_controller.js on lines 42..46

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

      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 bind_event has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        bind_event(socket) {
          $('#button-reverse').on('click', function(e){
            e.preventDefault();
            let action = {"scope": "example", "action": "reverse", "args": "hello world"}
            socket.send_message(action);
      Severity: Minor
      Found in examples/node/monitor/monitor_controller.js - About 1 hr to fix

        Method around_position has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def around_position x, y
                # Array[] handles negative index until -size
                if (0...width) === x && (0...height) === y
                  [x, y]
                else
        Severity: Minor
        Found in lib/sim/matrix/globe.rb - 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 render has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          render(){
        
            let chartPalette = new Rickshaw.Color.Palette( { scheme: this.palette } );
        
            this.chart = new Rickshaw.Graph( {
        Severity: Minor
        Found in examples/node/monitor/monitor_chart.js - About 1 hr to fix

          Method deep_transform_keys has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def deep_transform_keys(&block)
              result = {}
              each do |key, value|
                result[yield(key)] =  if value.is_a?(Hash)
                                        value.deep_transform_keys(&block)
          Severity: Minor
          Found in lib/ext/hash.rb - 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