sentilo/sentilo

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

Summary

Maintainability
D
3 days
Test Coverage

File media_players.js has 280 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var isAdmin = false;
$(document).ready(function() {
    isAdmin = $("body").hasClass("sntl-admin");
});

    Function showAndLoadAudioPlayer has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function showAndLoadAudioPlayer(panel, link, extendedLink, sensor, sensorType, timestamp) {
        
        // Add sensor & type
        $(panel).append('<span class="player-sensor-info">' + sensor + '</span><br class="player-sensor-info"/><span class="player-sensor-info">' + sensorType + '</span><br class="player-sensor-info"/><br class="player-sensor-info"/>');
        $(panel).append('<span class="player-sensor-value-link">' + link + '</span>');

      Function showJson has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function showJson(panel, value, timestamp) {
      
          $(panel)
              .jsonPresenter('destroy')
              .jsonPresenter({ json: jQuery.parseJSON(value) })

        Function showFile has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function showFile(panel, link, extendedLink, filename, sensor, sensorType, timestamp) {
        Severity: Major
        Found in sentilo-catalog-web/src/main/webapp/static/js/sentilo/media_players.js - About 50 mins to fix

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

          function showAndLoadAudioPlayer(panel, link, extendedLink, sensor, sensorType, timestamp) {
          Severity: Minor
          Found in sentilo-catalog-web/src/main/webapp/static/js/sentilo/media_players.js - About 45 mins to fix

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

            function showAndLoadVideoPlayer(panel, link, extendedLink, sensor, sensorType, timestamp) {
            Severity: Minor
            Found in sentilo-catalog-web/src/main/webapp/static/js/sentilo/media_players.js - About 45 mins to fix

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

              function showImage(panel, link, extendedLink, sensor, sensorType, timestamp) {
              Severity: Minor
              Found in sentilo-catalog-web/src/main/webapp/static/js/sentilo/media_players.js - About 45 mins to fix

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

                function showLink(panel, link, sensor, sensorType, timestamp) {
                Severity: Minor
                Found in sentilo-catalog-web/src/main/webapp/static/js/sentilo/media_players.js - About 35 mins to fix

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

                      var img = $('<img id="link-image" />').attr('src', extendedLink)
                      .on('load', function() {
                          if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
                              img.attr('src', getErrorImage());
                              $("#image-wrapper").html(img);
                  sentilo-catalog-web/src/main/webapp/static/js/sentilo/universal_map.js on lines 1070..1080

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

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

                      wavesurfer.on('audioprocess', function() {
                          $("#ellapsed-time").html(wavesurfer.getCurrentTime().toFixed(3) + 's / ' + wavesurfer.getDuration().toFixed(3) + 's');
                      });
                  sentilo-catalog-web/src/main/webapp/static/js/sentilo/media_players.js on lines 87..89
                  sentilo-catalog-web/src/main/webapp/static/js/sentilo/universal_map.js on lines 951..953
                  sentilo-catalog-web/src/main/webapp/static/js/sentilo/universal_map.js on lines 955..957

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

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

                      wavesurfer.on('interaction', function() {
                          $("#ellapsed-time").html(wavesurfer.getCurrentTime().toFixed(3) + 's / ' + wavesurfer.getDuration().toFixed(3) + 's');
                      });
                  sentilo-catalog-web/src/main/webapp/static/js/sentilo/media_players.js on lines 83..85
                  sentilo-catalog-web/src/main/webapp/static/js/sentilo/universal_map.js on lines 951..953
                  sentilo-catalog-web/src/main/webapp/static/js/sentilo/universal_map.js on lines 955..957

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

                  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

                      if (wavesurfer && wavesurfer !== null && wavesurfer !== 'undefined') {
                          wavesurfer.stop();
                          wavesurfer.empty();
                          wavesurfer.destroy();
                          wavesurfer.unAll();
                  sentilo-catalog-web/src/main/webapp/static/js/sentilo/media_players.js on lines 20..25

                  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

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

                      if (wavesurfer && wavesurfer !== null && wavesurfer !== 'undefined') {
                          wavesurfer.stop();
                          wavesurfer.empty();
                          wavesurfer.destroy();
                          wavesurfer.unAll();
                  sentilo-catalog-web/src/main/webapp/static/js/sentilo/media_players.js on lines 158..163

                  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

                      actionButtonsGrp.append($('<a class="btn" href="#" id="expand-all"><i class="icon-resize-full"></i></a>')
                          .on('click', function() {
                              $(panel).jsonPresenter('expandAll');
                          })
                      );
                  sentilo-catalog-web/src/main/webapp/static/js/sentilo/media_players.js on lines 408..412

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

                  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

                      actionButtonsGrp.append($('<a class="btn" href="#" id="collapse-all"><i class="icon-resize-small"></i></a>')
                          .on('click', function() {
                              $(panel).jsonPresenter('collapseAll');
                          })
                      );
                  sentilo-catalog-web/src/main/webapp/static/js/sentilo/media_players.js on lines 415..419

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

                  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