QutBioacoustics/baw-server

View on GitHub
app/modules/api/custom_url_helpers.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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 make_listen_path has 28 lines of code (exceeds 25 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 1 hr to fix

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

        def make_library_path(ar_value = nil, ae_value = nil)
          return '/library' if ar_value.nil? && ae_value.nil?
    
          ar_id, ae_id = nil
    
    
    Severity: Minor
    Found in app/modules/api/custom_url_helpers.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 make_site_annotations_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def make_site_annotations_path(project_value, site_value)
          project_id = project_value.is_a?(Project) ? project_value.id : project_value.to_i
          site_id = site_value.is_a?(Site) ? site_value.id : site_value.to_i
          site_tz = site_value.is_a?(Site) && !site_value.rails_tz.blank? ? site_value.rails_tz : 'UTC'
          data_request_path(selected_project_id: project_id, selected_site_id: site_id, selected_timezone_name: site_tz)
    Severity: Minor
    Found in app/modules/api/custom_url_helpers.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 make_visualise_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def make_visualise_path(value)
          raise ArgumentError, 'Must provide project or site' if value.blank?
    
          link = '/visualize?'
    
    
    Severity: Minor
    Found in app/modules/api/custom_url_helpers.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