QutBioacoustics/baw-server

View on GitHub
app/modules/filter/subset.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

    def compose_range_options_node(node, hash)
      unless hash.is_a?(Hash)
        raise CustomErrors::FilterArgumentError,
          "Range filter must be {'from': 'value', 'to': 'value'} or {'interval': 'value'} got #{hash}"
      end
Severity: Minor
Found in app/modules/filter/subset.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 compose_not_range has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def compose_not_range(table, column_name, allowed, from, to)
Severity: Minor
Found in app/modules/filter/subset.rb - About 35 mins to fix

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

        def compose_range(table, column_name, allowed, from, to)
    Severity: Minor
    Found in app/modules/filter/subset.rb - About 35 mins to fix

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

          def compose_range_string_node(node, range_string)
            validate_node_or_attribute(node)
      
            range_regex = /(\[|\()(.*),(.*)(\)|\])/i
            matches = range_string.match(range_regex)
      Severity: Minor
      Found in app/modules/filter/subset.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