greenbell/fulltext_searchable

View on GitHub

Showing 8 of 8 total issues

Method fulltext_dependent_models has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

        def fulltext_dependent_models(columns=nil)
          columns ||= fulltext_columns
          if columns.is_a? Hash
            columns = Array.wrap(columns)
          end
Severity: Minor
Found in lib/fulltext_searchable/active_record.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 collect_fulltext_keywords has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def collect_fulltext_keywords(target, columns)
        result = []
        return result unless target
        if columns.is_a? Hash
          columns = Array.wrap(columns)
Severity: Minor
Found in lib/fulltext_searchable/active_record.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 match has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def match(phrase, options={})
      options = options.symbolize_keys
      phrase = phrase.split(/[\s ]/) if phrase.is_a? String
      phrase.map!{|word| word.gsub(BOOLEAN_META_CHARACTER_REGEXP, '')}
      phrase.reject!(&:blank?)
Severity: Minor
Found in app/models/fulltext_index.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 match has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def match(phrase, options={})
      options = options.symbolize_keys
      phrase = phrase.split(/[\s ]/) if phrase.is_a? String
      phrase.map!{|word| word.gsub(BOOLEAN_META_CHARACTER_REGEXP, '')}
      phrase.reject!(&:blank?)
Severity: Minor
Found in app/models/fulltext_index.rb - About 1 hr to fix

    Method fulltext_dependent_models has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def fulltext_dependent_models(columns=nil)
              columns ||= fulltext_columns
              if columns.is_a? Hash
                columns = Array.wrap(columns)
              end
    Severity: Minor
    Found in lib/fulltext_searchable/active_record.rb - About 1 hr to fix

      Method collect_fulltext_keywords has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def collect_fulltext_keywords(target, columns)
              result = []
              return result unless target
              if columns.is_a? Hash
                columns = Array.wrap(columns)
      Severity: Minor
      Found in lib/fulltext_searchable/active_record.rb - About 1 hr to fix

        Method save_fulltext_index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def save_fulltext_index
                if self.fulltext_index
                  if !fulltext_index.text.empty? && (!defined?(@fulltext_change) || @fulltext_change)
                    FulltextIndex.update(self)
                  else
        Severity: Minor
        Found in lib/fulltext_searchable/active_record.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 rebuild_all has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def rebuild_all
              if connection.tables.include?(FulltextSearchable::TABLE_NAME)
                connection.drop_table FulltextSearchable::TABLE_NAME
              end
              connection.create_fulltext_index_table
        Severity: Minor
        Found in app/models/fulltext_index.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

        Severity
        Category
        Status
        Source
        Language