QutBioacoustics/baw-server

View on GitHub
lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.rb

Summary

Maintainability
D
2 days
Test Coverage

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

    Class AudioBase has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

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

      Method clipping_check has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def clipping_check(source, info_flattened)
            # check for clipping, zero signal
            # only if duration less than 4 minutes
            four_minutes_in_sec = 4.0 * 60.0
            if (info_flattened[:media_type] == 'audio/wav' ||
      Severity: Minor
      Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.rb - About 1 hr to fix

        Method modify_worker has 31 lines of code (exceeds 25 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 1 hr to fix

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

              def check_sample_rate(target, modify_parameters = {}, source_info = {})
                if modify_parameters.include?(:sample_rate)
                  sample_rate = modify_parameters[:sample_rate].to_i
          
                  # source_info sample_rate_hertz should match modify_parameters original_sample_rate if both are supplied
          Severity: Minor
          Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.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 clipping_check has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def clipping_check(source, info_flattened)
                # check for clipping, zero signal
                # only if duration less than 4 minutes
                four_minutes_in_sec = 4.0 * 60.0
                if (info_flattened[:media_type] == 'audio/wav' ||
          Severity: Minor
          Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.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

          Method audio_tool_segment has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def audio_tool_segment(extension, audio_tool_method, source, source_info, target, modify_parameters)
          Severity: Minor
          Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.rb - About 45 mins to fix

            Method from_executables has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def self.from_executables(audio_defaults, logger, temp_dir, timeout_sec, opts = {})
            Severity: Minor
            Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.rb - About 35 mins to fix

              Method modify_wavpack has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def modify_wavpack(source, source_info, target, start_offset, end_offset)
              Severity: Minor
              Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.rb - About 35 mins to fix

                Method modify_mp3splt has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def modify_mp3splt(source, source_info, target, start_offset, end_offset)
                Severity: Minor
                Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.rb - About 35 mins to fix

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

                      def initialize(audio_defaults, logger, temp_dir, run_program, opts = {})
                  Severity: Minor
                  Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.rb - About 35 mins to fix

                    Method check_source has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def check_source(path)
                          raise Exceptions::FileNotFoundError, 'Source path was empty or nil' if path.nil? || (path.is_a?(String) && path.empty?)
                          path = Pathname(path)
                    
                          # Maybe worth resolving symlinks to a realpath, but currently does not cause any failures without
                    Severity: Minor
                    Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.rb - About 25 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

                    There are no issues that match your filters.

                    Category
                    Status