QutBioacoustics/baw-server

View on GitHub

Showing 257 of 257 total issues

Class Core has 46 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Core
    class << self
      # Get a hash with symbols, names, action words for the available levels.
      # @return [Hash]
      def levels_hash
Severity: Minor
Found in app/modules/access/core.rb - About 6 hrs to fix

    Method csv_query has 146 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.csv_query(user, project, site, audio_recording, start_offset, end_offset, timezone_name)
        # NOTE: if other modifications are made to the default_scope (like acts_as_paranoid does),
        # manually constructed queries like this need to be updated to match
        # (search for ':deleted_at' to find the relevant places)
    
    
    Severity: Major
    Found in app/models/audio_event.rb - About 5 hrs to fix

      Method validate_filter_settings has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate_filter_settings(value)
            validate_hash(value)
      
            # Common filter settings
      
      
      Severity: Minor
      Found in app/modules/filter/validate.rb - About 5 hrs 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 check_request_parameters has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_request_parameters(audio_recording, request_params)
            original_duration = audio_recording.duration_seconds
      
            # offsets
            start_offset = nil
      Severity: Minor
      Found in app/modules/api/media_metadata.rb - About 4 hrs 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

      File ability.rb has 366 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class Ability
        include CanCan::Ability
      
        # Define abilities for user.
        # @param [User] user
      Severity: Minor
      Found in app/models/ability.rb - About 4 hrs to fix

        Method download has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

          def download
            params_cleaned = CleanParams.perform(audio_event_download_params)
        
            is_authorized = false
        
        
        Severity: Minor
        Found in app/controllers/audio_events_controller.rb - About 4 hrs 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

        Class Ability has 36 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Ability
          include CanCan::Ability
        
          # Define abilities for user.
          # @param [User] user
        Severity: Minor
        Found in app/models/ability.rb - About 4 hrs to fix

          Method logged_csv_line has 104 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                    def logged_csv_line(file_path, exists, moved_path = nil,
                                        compare_hash = nil, api_result_hash = nil,
                                        api_response = nil, review_level = :none_all_good,
                                        audio_recording_id)
                      csv_headers = [
          Severity: Major
          Found in lib/gems/baw-workers/lib/baw_workers/jobs/audio_check/csv_helper.rb - About 4 hrs to fix

            Method modify has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
            Open

                def modify(source, target, modify_parameters = {})
                  source = Pathname(source)
                  target = Pathname(target)
                  raise ArgumentError, "Source is not a wav file: : #{source}" unless source.extname == '.wav'
                  raise ArgumentError, "Target is not a png file: : #{target}" unless target.extname == '.png'
            Severity: Minor
            Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/spectrogram.rb - About 4 hrs 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 logged_csv_line has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            Open

                      def logged_csv_line(file_path, exists, moved_path = nil,
                                          compare_hash = nil, api_result_hash = nil,
                                          api_response = nil, review_level = :none_all_good,
                                          audio_recording_id)
                        csv_headers = [
            Severity: Minor
            Found in lib/gems/baw-workers/lib/baw_workers/jobs/audio_check/csv_helper.rb - About 3 hrs 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 filter_settings has 95 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.filter_settings
                {
                  valid_fields: [:id, :name, :description, :creator_id,
                                 :created_at,
                                 :updater_id,
            Severity: Major
            Found in app/models/project.rb - About 3 hrs to fix

              File audio_base.rb has 310 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              module BawAudioTools
                class AudioBase
                  attr_reader :audio_defaults, :logger, :temp_dir, :timeout_sec,
                              :audio_ffmpeg, :audio_mp3splt, :audio_sox,
                              :audio_wavpack, :audio_shntool, :audio_waveform,
              Severity: Minor
              Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.rb - About 3 hrs to fix

                Method filter_settings has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.filter_settings
                    {
                      valid_fields: [:id, :name, :description, :notes, :creator_id,
                                     :created_at, :updater_id, :updated_at, :deleter_id, :deleted_at, :region_id],
                      render_fields: [:id, :name, :description, :notes, :creator_id,
                Severity: Major
                Found in app/models/site.rb - About 3 hrs to fix

                  Method poll_resque_and_media has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def poll_resque_and_media(expected_files, _media_type, _media_request_params, wait_max, job_id:, poll_delay: 0.4)
                        poll_locations = prepare_locations(expected_files)
                        existing_files = []
                        resque_status = nil
                  
                  
                  Severity: Minor
                  Found in app/modules/media_poll.rb - About 3 hrs 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

                  File core.rb has 296 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  module Access
                    # Basic level, user, and access methods.
                    class Core
                      class << self
                        # Get a hash with symbols, names, action words for the available levels.
                  Severity: Minor
                  Found in app/modules/access/core.rb - About 3 hrs to fix

                    Method make_listen_path has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def make_listen_path(value = nil, start_offset_sec = nil, end_offset_sec = nil)
                          return '/listen' if value.blank?
                    
                          # obtain audio recording id
                          ar_id = if value.is_a?(AudioRecording)
                    Severity: Minor
                    Found in app/modules/api/custom_url_helpers.rb - About 3 hrs 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 menu_definition has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def menu_definition
                        current_user = controller.current_user
                    
                        items = NAV_MENU
                    
                    
                    Severity: Minor
                    Found in app/helpers/global_menu_helper.rb - About 3 hrs 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 exclusive_attributes has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def exclusive_attributes
                        has_user = user.blank? ? 0 : 1
                        allows_logged_in = allow_logged_in == true ? 1 : 0
                        allows_anon = allow_anonymous == true ? 1 : 0
                        exclusive_set = has_user + allows_logged_in + allows_anon
                    Severity: Minor
                    Found in app/models/permission.rb - About 2 hrs 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 modify_worker has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def modify_worker(source_info, source, target, modify_parameters = {})
                          if source_info[:media_type] == 'audio/wavpack'
                            # convert to wave and segment
                            audio_tool_segment('wav', :modify_wavpack, source, source_info, target, modify_parameters)
                          elsif source_info[:media_type] == 'audio/x-waac'
                    Severity: Minor
                    Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.rb - About 2 hrs 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 check_integrity_output has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def check_integrity_output(execute_msg)
                          #stdout = execute_msg[:stdout]
                          stderr = execute_msg[:stderr]
                    
                          result = {
                    Severity: Minor
                    Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.rb - About 2 hrs 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