QutBioacousticsResearchGroup/bioacoustic-workbench

View on GitHub

Showing 93 of 184 total issues

Method generate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def self.generate(source, target, modify_parameters)
    raise ArgumentError, "Target path for spectrogram generation already exists: #{target}." unless !File.exist?(target)

    # sample rate
    sample_rate_param = modify_parameters.include?(:sample_rate) ? modify_parameters[:sample_rate].to_i : 11025
Severity: Minor
Found in lib/modules/spectrogram.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

Method create_raw_query has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create_raw_query

    recordings_search = AudioRecording.scoped

    if self.invalid?
Severity: Minor
Found in app/models/saved_search/saved_search_store.rb - About 1 hr to fix

    Method modify_sox has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.modify_sox(source, target, modify_parameters = {})
        raise ArgumentError, "Source is not a mp3 or wav file: #{File.basename(source)}" unless source.match(/\.mp3|\.wav$/)
        raise ArgumentError, "Target is not a mp3 or wav file: : #{File.basename(target)}" unless target.match(/\.mp3|\.wav$/)
        raise ArgumentError, "Source does not exist: #{File.basename(source)}" unless File.exists? source
        raise ArgumentError, "Target exists: #{File.basename(target)}" unless !File.exists? target
    Severity: Minor
    Found in lib/modules/audio_sox.rb - About 1 hr to fix

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

                      var updatePlayer = function () {
                          $player.jPlayer({
                              // Flash fallback for outdated browser not supporting HTML5 audio/video tags
                              // http://jplayer.org/download/
                              swfPath: 'assets/',
      Severity: Minor
      Found in app/assets/javascripts/angular/directives/directives.js - About 1 hr to fix

        Function radioInputType has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    link: function radioInputType(scope, element, attr) {
                        // make the name unique, if not defined
                        if (baw.angularCopies.isUndefined(attr.name)) {
                            element.attr('name', Number.Unique());
                        }
        Severity: Minor
        Found in app/assets/javascripts/angular/directives/directives.js - About 1 hr to fix

          Method modify_wavpack has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.modify_wavpack(source, target, modify_parameters = {})
              raise ArgumentError, "Source is not a wavpack file: #{File.basename(source)}" unless source.match(/\.wv$/)
              raise ArgumentError, "Target is not a wav file: : #{File.basename(target)}" unless target.match(/\.wav$/)
              raise ArgumentError "Source and Target are the same file: #{File.basename(target)}" unless source != target
          
          Severity: Minor
          Found in lib/modules/audio_wavpack.rb - About 1 hr to fix

            Function getLowestCountItem has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                        $scope.getLowestCountItem = function (containingObject) {
                            console.log('called $scope.getLowestCountItem', containingObject);
                            // find minimum
                            var minCount = null;
                            angular.forEach(containingObject, function (value, key) {
            Severity: Minor
            Found in app/assets/javascripts/angular/controllers/experiments.js - About 1 hr to fix

              Function verifyPreface has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                          $scope.verifyPreface = function verifyPreface() {
                              $scope.errors.length = 0;
              
                              if ($scope.results.consented !== true) {
                                  $scope.errors.push("You must consent to participate in this experiment.");
              Severity: Minor
              Found in app/assets/javascripts/angular/controllers/experiments.js - About 1 hr to fix

                Function SiteCtrl has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function SiteCtrl($scope, $resource, $routeParams, Project, Site, AudioRecording, AudioEvent) {
                    var siteResource = Site;
                    var routeArgs = {siteId: $routeParams.siteId};
                
                    $scope.downloadAnnotationLink = AudioEvent.csvLink({siteId: $routeParams.siteId});
                Severity: Minor
                Found in app/assets/javascripts/angular/controllers/sites.js - About 1 hr to fix

                  Function Annotation has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      baw.Annotation = function Annotation(localIdOrResource, audioRecordingId) {
                  
                          var localId = typeof(localIdOrResource) === "number" ? localIdOrResource : undefined;
                          var resource;
                          if (localIdOrResource instanceof Object && localIdOrResource.constructor.name == "Resource") {
                  Severity: Minor
                  Found in app/assets/javascripts/angular/models/annotation.js - About 1 hr to fix

                    Function PhotoCtrl has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function PhotoCtrl($scope, $resource, $routeParams, Photo) {
                    
                        var photoResource = Photo;
                        var routeArgs = {photoId: $routeParams.photoId};
                    
                    Severity: Minor
                    Found in app/assets/javascripts/angular/controllers/photos.js - About 1 hr to fix

                      Function calculateFlashes has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                                  function calculateFlashes() {
                      
                                      // work out the scale of flash cards that need to be shown
                                      var adjustedPPS = PPS * $scope.stepResults.compression,
                                          segmentDuration = $scope.SPECTROGRAM_WIDTH / adjustedPPS;
                      Severity: Minor
                      Found in app/assets/javascripts/angular/controllers/experiments.js - About 1 hr to fix

                        Method tags_are_strings has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def tags_are_strings
                            if self.tags.is_a?(Array)
                              unless self.tags.blank?
                                self.tags.each do |tag|
                                  unless tag.is_a?(String)
                        Severity: Minor
                        Found in app/models/saved_search/saved_search_store_body.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

                        Method copy_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def copy_file(source_path,full_move_paths)
                              unless source_path.nil? || full_move_paths.size < 1
                                success = []
                                fail = []
                        
                        Severity: Minor
                        Found in lib/external/audio_harvester.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

                        Method facebook_info has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def facebook_info(raw)
                        
                            facebook_name = raw.info.include?(:name) ? raw.info.name : ''
                            facebook_nickname = raw.info.include?(:nickname) ? raw.info.nickname : ''
                            facebook_any_name = facebook_name.blank? ? (facebook_nickname.blank? ? '' : facebook_nickname) : facebook_name
                        Severity: Minor
                        Found in app/controllers/api/callbacks_controller.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

                        Method params_are_hashes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def params_are_hashes
                            self.pre_params = SavedSearchStorePre.new(self.pre_params) if self.pre_params.is_a?(Hash)
                            self.body_params = SavedSearchStoreBody.new(self.body_params) if self.body_params.is_a?(Hash)
                            self.post_params = SavedSearchStorePost.new(self.post_params) if self.post_params.is_a?(Hash)
                        
                        
                        Severity: Minor
                        Found in app/models/saved_search/saved_search_store.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 mousemove has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            var mousemove = function (e) {
                        
                                var $thisMouseMove = $(this);
                                var dataMouseMove = $thisMouseMove.data('drawboxes');
                        
                        
                        Severity: Minor
                        Found in lib/assets/javascripts/jquery.drawabox.js - About 1 hr to fix

                          Method initialize has 9 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def initialize(host, port, config_file_name, login_email, login_password, endpoint_create, endpoint_login, endpoint_record_move, base_dir)
                          Severity: Major
                          Found in lib/external/audio_harvester.rb - About 1 hr to fix

                            Method create_audio_segment has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def self.create_audio_segment(modify_parameters = {})
                                # first check if a cached audio file matches the request
                                target_file = Cache::cached_audio_file modify_parameters
                                target_existing_paths = Cache::existing_paths(Cache::cached_audio_storage_paths,target_file)
                            
                            Severity: Minor
                            Found in lib/modules/file_cacher.rb - About 1 hr to fix

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

                                  baw.angularCopies = new (function Angular() {
                                      this.fixedEncodeURIComponent = function fixedEncodeURIComponent(str) {
                                          str = str || "";
                                          return encodeURIComponent(str)
                                              .replace(/!/g, '%21')
                              Severity: Minor
                              Found in lib/assets/javascripts/functions.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language