QutBioacoustics/baw-server

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

Summary

Maintainability
D
1 day
Test Coverage

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

File audio_ffmpeg.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module BawAudioTools
  # Used to manipulate the ffmpeg command line tool
  class AudioFfmpeg
    ERROR_FRAME_SIZE_1 = 'Could not find codec parameters for stream [0-9]+ \\(Audio\\: [a-zA-Z0-9]+\\, [0-9]+ channels\\, [a-zA-Z0-9]+\\)\\: unspecified frame size'
    ERROR_FRAME_SIZE_2 = 'Failed to read frame size: Could not seek to [0-9]+\\.'
Severity: Minor
Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.rb - About 2 hrs to fix

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

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

          def codec_calc(target)
            # high quality codec settings
            # https://trac.ffmpeg.org/wiki/GuidelinesHighQualityAudio
      
            # http://trac.ffmpeg.org/wiki/TheoraVorbisEncodingGuide
      Severity: Minor
      Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.rb - About 1 hr to fix

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

            def parse_ffprobe_output(source, execute_msg)
              # ffprobe std err contains info (separate on first equals(=))
        
              result = {}
              ffprobe_current_block_name = ''
        Severity: Minor
        Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.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 modify_command has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def modify_command(source, source_info, target, start_offset = nil, end_offset = nil, channel = nil, sample_rate = nil)
              raise Exceptions::FileNotFoundError, "Source does not exist: #{source}" unless File.exist? source
              raise Exceptions::FileAlreadyExistsError, "Target exists: #{target}" if File.exist? target
              raise ArgumentError, "Source and Target are the same file: #{target}" if source == target
        
        
        Severity: Minor
        Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.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 modify_command has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def modify_command(source, source_info, target, start_offset = nil, end_offset = nil, channel = nil, sample_rate = nil)
        Severity: Major
        Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.rb - About 50 mins to fix

          Method check_integrity_item has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def check_integrity_item(hash)
                return nil if hash.blank?
          
                return nil if hash[:id].starts_with?('graph')
                return nil if hash[:id].starts_with?('audio format')
          Severity: Minor
          Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.rb - About 35 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 arg_offsets has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def arg_offsets(start_offset, end_offset)
                cmd_arg = ''
          
                # start offset
                # -ss Seek to given time position in seconds. hh:mm:ss[.xxx] syntax is also supported.
          Severity: Minor
          Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.rb - About 35 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

          Avoid too many return statements within this method.
          Open

                  return nil
          Severity: Major
          Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return nil if hash[:description].starts_with?('parser not found for')
            Severity: Major
            Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return nil if hash[:description].starts_with?('max_analyze_duration')
              Severity: Major
              Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.rb - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status