sentilo/sentilo

View on GitHub
sentilo-catalog-web/src/main/webapp/static/js/sentilo/component_detail.js

Summary

Maintainability
F
1 wk
Test Coverage

File component_detail.js has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var refreshIntervalMS = 1000 * 30;
var handlerId = undefined;
var selectedSensor = undefined;
var dataType = null;

    Function addLastSensorObservationToPanel has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    var addLastSensorObservationToPanel = function(panel, data) {
        if (data.dataType === 'AUDIO_LINK') {
            showAndLoadAudioPlayer(panel, data.value, data.formattedValue, data.sensor, data.sensorType, data.timestamp);
            stopPreviousRefresh();
        } else if (data.dataType === 'VIDEO_LINK') {

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

    function showBooleanDataChart(url, dataPanel, filters) {
        jsonGET(url, filters, function(data) {
            var chartAnchor = $('<div id="bool-chart" class="ct-chart ct-perfect-fourth ct-chart-centered-labels"></div>');
            $(dataPanel).html(chartAnchor);
            printBooleanChart(data, '#bool-chart', {height: 220, bottomPadding: 20});

      Function showNumericDataChart has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function showNumericDataChart(url, dataPanel, sensorType, unit, filters) {
          jsonGET(url, filters, function(data) {
              var chartAnchor = $('<div id="num-chart" class="ct-chart ct-perfect-fourth ct-chart-centered-labels"></div>');
              $(dataPanel).html(chartAnchor);
              printNumericalChart(data, sensorType, unit, '#num-chart', {height: 220, bottomPadding: 20});

        Function addLastSensorObservationToPanel has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var addLastSensorObservationToPanel = function(panel, data) {
            if (data.dataType === 'AUDIO_LINK') {
                showAndLoadAudioPlayer(panel, data.value, data.formattedValue, data.sensor, data.sensorType, data.timestamp);
                stopPreviousRefresh();
            } else if (data.dataType === 'VIDEO_LINK') {

          Function initComponentDetailVariables has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          var initComponentDetailVariables = function(url, dataUrl, ordersUrl, alarmsUrl, maxChartDate, type) {

            Function showNumericDataChart has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function showNumericDataChart(url, dataPanel, sensorType, unit, filters) {

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

              var retrieveActivity = function(placeholder, url, label) {
                  if (selectedSensor.dataType === 'LINK' || 
                      selectedSensor.dataType === 'AUDIO_LINK' || 
                      selectedSensor.dataType === 'IMAGE_LINK' || 
                      selectedSensor.dataType === 'VIDEO_LINK' || 

              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 refreshChartControlLabels has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              var refreshChartControlLabels = function(theNavData) {
                  
                  // This is a chart callback function
                  // When data is loaded onto chart, calls this function
                  // for update window labels

              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

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

              function showNumericDataChart(url, dataPanel, sensorType, unit, filters) {
                  jsonGET(url, filters, function(data) {
                      var chartAnchor = $('<div id="num-chart" class="ct-chart ct-perfect-fourth ct-chart-centered-labels"></div>');
                      $(dataPanel).html(chartAnchor);
                      printNumericalChart(data, sensorType, unit, '#num-chart', {height: 220, bottomPadding: 20});
              sentilo-catalog-web/src/main/webapp/static/js/sentilo/sensor_data.js on lines 49..114

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

              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

              function showBooleanDataChart(url, dataPanel, filters) {
                  jsonGET(url, filters, function(data) {
                      var chartAnchor = $('<div id="bool-chart" class="ct-chart ct-perfect-fourth ct-chart-centered-labels"></div>');
                      $(dataPanel).html(chartAnchor);
                      printBooleanChart(data, '#bool-chart', {height: 220, bottomPadding: 20});
              sentilo-catalog-web/src/main/webapp/static/js/sentilo/sensor_data.js on lines 116..181

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

              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 refreshChartControlLabels = function(theNavData) {
                  
                  // This is a chart callback function
                  // When data is loaded onto chart, calls this function
                  // for update window labels
              sentilo-catalog-web/src/main/webapp/static/js/sentilo/sensor_data.js on lines 209..222

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

              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 retrieveAlarms = function(placeholder, url) {
                  var ph = $(placeholder);
                  ph.empty();
                  jsonGET(url, [], function(data) {
                      for(var i = 0; i < data.length; i++) {
              sentilo-catalog-web/src/main/webapp/static/js/sentilo/component_detail.js on lines 63..72

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

              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 retrieveOrders = function(placeholder, url) {
                  var ph = $(placeholder);
                  ph.empty();
                  jsonGET(url, [], function(data) {
                      for(var i = 0; i < data.length; i++) {
              sentilo-catalog-web/src/main/webapp/static/js/sentilo/component_detail.js on lines 45..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 99.

              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 makeOrderLine = function(ph, order) {
                  ph.append('<div class="activity_text_element"><span class="label label-success">' + order.timestamp + '</span>&nbsp;' + order.order + '</div>');
              };
              sentilo-catalog-web/src/main/webapp/static/js/sentilo/component_detail.js on lines 41..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 51.

              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 makeAlarmLine = function(ph, alarm) {
                  ph.append('<div class="activity_text_element"><span class="label label-important">' + alarm.timestamp + '</span>&nbsp;' + alarm.message + '</div>');
              };
              sentilo-catalog-web/src/main/webapp/static/js/sentilo/component_detail.js on lines 59..61

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

              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

                              data.value = eval(data.value) ? messages.boolValues.trueValue.toUpperCase() : messages.boolValues.falseValue.toUpperCase();
              sentilo-catalog-web/src/main/webapp/static/js/sentilo/universal_map.js on lines 336..336

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

              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

              There are no issues that match your filters.

              Category
              Status