SpeciesFileGroup/taxonworks

View on GitHub
lib/queries/geographic_area/autocomplete.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method has too many lines. [36/25]
Open

      def autocomplete
        #t = Time.now
        pr_id = project_id.join(',') if project_id.present?

        return [] if query_string.blank?

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method autocomplete has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def autocomplete
        #t = Time.now
        pr_id = project_id.join(',') if project_id.present?

        return [] if query_string.blank?
Severity: Minor
Found in lib/queries/geographic_area/autocomplete.rb - About 1 hr to fix

    Method autocomplete has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def autocomplete
            #t = Time.now
            pr_id = project_id.join(',') if project_id.present?
    
            return [] if query_string.blank?
    Severity: Minor
    Found in lib/queries/geographic_area/autocomplete.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

    TODO found
    Open

          # TODO: use or_clauses

    Use 2 (not 3) spaces for indentation.
    Open

                   a = a.left_outer_joins(:asserted_distributions)

    This cop checks for indentation that doesn't use the specified number of spaces.

    See also the IndentationConsistency cop which is the companion to this one.

    Example:

    # bad
    class A
     def test
      puts 'hello'
     end
    end
    
    # good
    class A
      def test
        puts 'hello'
      end
    end

    Example: IgnoredPatterns: ['^\s*module']

    # bad
    module A
    class B
      def test
      puts 'hello'
      end
    end
    end
    
    # good
    module A
    class B
      def test
        puts 'hello'
      end
    end
    end

    There are no issues that match your filters.

    Category
    Status