QutBioacoustics/baw-workers

View on GitHub
lib/baw-workers/harvest/single_file.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method run has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def run(file_info_hash, is_real_run, copy_on_success = false)

        file_info_hash.deep_symbolize_keys!

        project_id = file_info_hash[:project_id]
Severity: Major
Found in lib/baw-workers/harvest/single_file.rb - About 3 hrs to fix

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

          def run(file_info_hash, is_real_run, copy_on_success = false)
    
            file_info_hash.deep_symbolize_keys!
    
            project_id = file_info_hash[:project_id]
    Severity: Minor
    Found in lib/baw-workers/harvest/single_file.rb - About 45 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 get_new_audio_recording has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def get_new_audio_recording(file_path, project_id, site_id, audio_info_hash, security_info)
    Severity: Minor
    Found in lib/baw-workers/harvest/single_file.rb - About 35 mins to fix

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

            def rename_harvested_file(file_path, storage_target_paths)
              # rename file once it is copied to all destinations
              source_size = File.size(file_path)
      
              check_target_paths = storage_target_paths.select { |file| File.exists?(file) && File.file?(file) && File.size(file) == source_size }
      Severity: Minor
      Found in lib/baw-workers/harvest/single_file.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