QutBioacoustics/baw-workers

View on GitHub
lib/baw-workers/audio_check/work_helper.rb

Summary

Maintainability
D
3 days
Test Coverage

Method run_single has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

      def run_single(existing_file, audio_params, is_real_run)
        # get existing file info and comparisons between expected and actual
        existing_file_info = @file_info.audio_info(existing_file)

        @logger.debug(@class_name) {
Severity: Minor
Found in lib/baw-workers/audio_check/work_helper.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 run_single has 104 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def run_single(existing_file, audio_params, is_real_run)
        # get existing file info and comparisons between expected and actual
        existing_file_info = @file_info.audio_info(existing_file)

        @logger.debug(@class_name) {
Severity: Major
Found in lib/baw-workers/audio_check/work_helper.rb - About 4 hrs to fix

    File work_helper.rb has 304 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module BawWorkers
      module AudioCheck
        class WorkHelper
    
          def initialize(logger, file_info, api_comm)
    Severity: Minor
    Found in lib/baw-workers/audio_check/work_helper.rb - About 3 hrs to fix

      Method compare_info has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

            def compare_info(existing_file, existing_file_info, audio_params)
              correct = :pass
              wrong = :fail
      
              bit_rate_bps_delta = 10000 # due to difference for asf files of 1300-2000 bps (set large to catch only very different bit rates)
      Severity: Minor
      Found in lib/baw-workers/audio_check/work_helper.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 run has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def run(audio_params, is_real_run)
              # validate params
              audio_params_sym = BawWorkers::AudioCheck::WorkHelper.validate(audio_params)
      
              if is_real_run
      Severity: Major
      Found in lib/baw-workers/audio_check/work_helper.rb - About 2 hrs to fix

        Method run has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

              def run(audio_params, is_real_run)
                # validate params
                audio_params_sym = BawWorkers::AudioCheck::WorkHelper.validate(audio_params)
        
                if is_real_run
        Severity: Minor
        Found in lib/baw-workers/audio_check/work_helper.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 compare_info has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def compare_info(existing_file, existing_file_info, audio_params)
                correct = :pass
                wrong = :fail
        
                bit_rate_bps_delta = 10000 # due to difference for asf files of 1300-2000 bps (set large to catch only very different bit rates)
        Severity: Minor
        Found in lib/baw-workers/audio_check/work_helper.rb - About 1 hr to fix

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

                def rename_file(existing_file, file_name_utc, is_real_run)
          
                  # create all needed information
                  existing_path = existing_file
                  existing_name = File.basename(existing_path)
          Severity: Minor
          Found in lib/baw-workers/audio_check/work_helper.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 rename_file has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def rename_file(existing_file, file_name_utc, is_real_run)
          
                  # create all needed information
                  existing_path = existing_file
                  existing_name = File.basename(existing_path)
          Severity: Minor
          Found in lib/baw-workers/audio_check/work_helper.rb - About 1 hr to fix

            Method log_csv_line has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def log_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)
            Severity: Major
            Found in lib/baw-workers/audio_check/work_helper.rb - About 1 hr to fix

              There are no issues that match your filters.

              Category
              Status