SpeciesFileGroup/taxonworks

View on GitHub
lib/queries/otu/filter.rb

Summary

Maintainability
D
1 day
Test Coverage

Class Filter has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Otu::Filter < Queries::Query

    # Query variables
    attr_accessor :geographic_area_ids, :shape
    attr_accessor :selection_objects
Severity: Minor
Found in lib/queries/otu/filter.rb - About 3 hrs to fix

    File filter.rb has 298 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Queries
    
      # TODO: Unify all and filter
      class Otu::Filter < Queries::Query
    
    
    Severity: Minor
    Found in lib/queries/otu/filter.rb - About 3 hrs to fix

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

          def author_scope
      
            r = ::Role.arel_table
      
            case and_or_select
      Severity: Minor
      Found in lib/queries/otu/filter.rb by rubocop

      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 author_scope has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def author_scope
      
            r = ::Role.arel_table
      
            case and_or_select
      Severity: Minor
      Found in lib/queries/otu/filter.rb - About 1 hr to fix

        Use verbatim_author.present? instead of !verbatim_author.blank?.
        Open

              !verbatim_author.blank?
        Severity: Minor
        Found in lib/queries/otu/filter.rb by rubocop

        This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

        Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

        Example: NotNilAndNotEmpty: true (default)

        # Converts usages of `!nil? && !empty?` to `present?`
        
        # bad
        !foo.nil? && !foo.empty?
        
        # bad
        foo != nil && !foo.empty?
        
        # good
        foo.present?

        Example: NotBlank: true (default)

        # Converts usages of `!blank?` to `present?`
        
        # bad
        !foo.blank?
        
        # bad
        not foo.blank?
        
        # good
        foo.present?

        Example: UnlessBlank: true (default)

        # Converts usages of `unless blank?` to `if present?`
        
        # bad
        something unless foo.blank?
        
        # good
        something if foo.present?

        TODO found
        Open

          # TODO: Unify all and filter
        Severity: Minor
        Found in lib/queries/otu/filter.rb by fixme

        TODO found
        Open

            # TODO: deprecate
        Severity: Minor
        Found in lib/queries/otu/filter.rb by fixme

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def matching_asserted_distribution_ids
              return nil if asserted_distribution_ids.empty?
              o = table
              ad = ::AssertedDistribution.arel_table
        
        
        Severity: Major
        Found in lib/queries/otu/filter.rb and 1 other location - About 2 hrs to fix
        lib/queries/otu/filter.rb on lines 326..348

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 90.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def matching_taxon_name_classification_ids
              return nil if taxon_name_classification_ids.empty?
              o = table
              tnc = ::TaxonNameClassification.arel_table
        
        
        Severity: Major
        Found in lib/queries/otu/filter.rb and 1 other location - About 2 hrs to fix
        lib/queries/otu/filter.rb on lines 351..373

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 90.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

            def merge_clauses
              clauses = [
                matching_biological_association_ids,
                matching_asserted_distribution_ids,
                matching_taxon_name_classification_ids,
        Severity: Minor
        Found in lib/queries/otu/filter.rb and 5 other locations - About 15 mins to fix
        lib/queries/biological_association/filter.rb on lines 26..40
        lib/queries/common_name/filter.rb on lines 37..51
        lib/queries/controlled_vocabulary_term/autocomplete.rb on lines 30..44
        lib/queries/person/filter.rb on lines 50..64
        lib/queries/taxon_name/autocomplete.rb on lines 69..83

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 26.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

            def all
              a = and_clauses
              b = merge_clauses
              if a && b
                b.where(a).distinct
        Severity: Minor
        Found in lib/queries/otu/filter.rb and 2 other locations - About 15 mins to fix
        lib/queries/georeference/filter.rb on lines 73..84
        lib/queries/identifier/filter.rb on lines 136..147

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 26.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Prefer single-quoted strings when you don't need string interpolation or special symbols.
        Open

              a = o.alias("a_")
        Severity: Minor
        Found in lib/queries/otu/filter.rb by rubocop

        Checks if uses of quotes match the configured preference.

        Example: EnforcedStyle: single_quotes (default)

        # bad
        "No special symbols"
        "No string interpolation"
        "Just text"
        
        # good
        'No special symbols'
        'No string interpolation'
        'Just text'
        "Wait! What's #{this}!"

        Example: EnforcedStyle: double_quotes

        # bad
        'Just some text'
        'No special chars or interpolation'
        
        # good
        "Just some text"
        "No special chars or interpolation"
        "Every string in #{project} uses double_quotes"

        Prefer single-quoted strings when you don't need string interpolation or special symbols.
        Open

              a = o.alias("a_")
        Severity: Minor
        Found in lib/queries/otu/filter.rb by rubocop

        Checks if uses of quotes match the configured preference.

        Example: EnforcedStyle: single_quotes (default)

        # bad
        "No special symbols"
        "No string interpolation"
        "Just text"
        
        # good
        'No special symbols'
        'No string interpolation'
        'Just text'
        "Wait! What's #{this}!"

        Example: EnforcedStyle: double_quotes

        # bad
        'Just some text'
        'No special chars or interpolation'
        
        # good
        "Just some text"
        "No special chars or interpolation"
        "Every string in #{project} uses double_quotes"

        Prefer single-quoted strings when you don't need string interpolation or special symbols.
        Open

              a = o.alias("a_")
        Severity: Minor
        Found in lib/queries/otu/filter.rb by rubocop

        Checks if uses of quotes match the configured preference.

        Example: EnforcedStyle: single_quotes (default)

        # bad
        "No special symbols"
        "No string interpolation"
        "Just text"
        
        # good
        'No special symbols'
        'No string interpolation'
        'Just text'
        "Wait! What's #{this}!"

        Example: EnforcedStyle: double_quotes

        # bad
        'Just some text'
        'No special chars or interpolation'
        
        # good
        "Just some text"
        "No special chars or interpolation"
        "Every string in #{project} uses double_quotes"

        Prefer single-quoted strings when you don't need string interpolation or special symbols.
        Open

              a = o.alias("a_")
        Severity: Minor
        Found in lib/queries/otu/filter.rb by rubocop

        Checks if uses of quotes match the configured preference.

        Example: EnforcedStyle: single_quotes (default)

        # bad
        "No special symbols"
        "No string interpolation"
        "Just text"
        
        # good
        'No special symbols'
        'No string interpolation'
        'Just text'
        "Wait! What's #{this}!"

        Example: EnforcedStyle: double_quotes

        # bad
        'Just some text'
        'No special chars or interpolation'
        
        # good
        "Just some text"
        "No special chars or interpolation"
        "Every string in #{project} uses double_quotes"

        There are no issues that match your filters.

        Category
        Status