opf/openproject

View on GitHub
lib_static/plugins/acts_as_searchable/lib/acts_as_searchable.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method search has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

          def search(tokens, projects = nil, options = {})
            tokens = Array(tokens)
            projects = [] << projects unless projects.nil? || projects.is_a?(Array)

            find_order = "#{searchable_options[:order_column]} " + (options[:before] ? "DESC" : "ASC")
Severity: Minor
Found in lib_static/plugins/acts_as_searchable/lib/acts_as_searchable.rb - About 2 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 search has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          def search(tokens, projects = nil, options = {})
            tokens = Array(tokens)
            projects = [] << projects unless projects.nil? || projects.is_a?(Array)

            find_order = "#{searchable_options[:order_column]} " + (options[:before] ? "DESC" : "ASC")
Severity: Minor
Found in lib_static/plugins/acts_as_searchable/lib/acts_as_searchable.rb - About 1 hr to fix

    Method acts_as_searchable has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def acts_as_searchable(options = {})
              return if included_modules.include?(Redmine::Acts::Searchable::InstanceMethods)
    
              cattr_accessor :searchable_options
              self.searchable_options = options
    Severity: Minor
    Found in lib_static/plugins/acts_as_searchable/lib/acts_as_searchable.rb - About 55 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 searchable_column_conditions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

              def searchable_column_conditions
                searchable_options[:columns].map do |column|
                  name, scope = column.is_a?(Hash) ? column.values_at(:name, :scope) : column
                  match_condition = "(#{Arel.sql(name)} ILIKE ?)"
    
    
    Severity: Minor
    Found in lib_static/plugins/acts_as_searchable/lib/acts_as_searchable.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