ithouse/lolita

View on GitHub

Showing 65 of 65 total issues

Method clear_models has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

      def clear_models
        Dir[Rails.root.join("app","models","*.rb")].each do |file_name|
          matched = false
          gsub_file file_name, /^\s*include\s+#{INCLUDE_MODULE}.*/ do |match|
            matched = true
Severity: Minor
Found in lib/generators/lolita/uninstall_generator.rb - About 4 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 use_default_format has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

        def use_default_format(value,*optional_values)
          if value
            if value.is_a?(String)
              @format ? (@format % value) : value
            elsif value.is_a?(Numeric)
Severity: Minor
Found in lib/lolita/support/formatter/rails.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

Class List has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

    class List < Lolita::Configuration::Base
      include Observable
      include Lolita::Builder

      attr_reader :initialized_attributes,:page_criteria
Severity: Minor
Found in lib/lolita/configuration/list.rb - About 3 hrs to fix

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

        def lolita_for *resources
          options = resources.extract_options!
    
          options[:as]          ||= @scope[:as]     if @scope[:as].present?
          options[:module]      ||= @scope[:module] if @scope[:module].present?
    Severity: Minor
    Found in lib/lolita/rails/routes.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

    Class Branch has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Branch
    
          attr_accessor :name,:object
          attr_reader :level,:options,:tree,:parent
          attr_writer :title
    Severity: Minor
    Found in lib/lolita/navigation/branch.rb - About 2 hrs to fix

      Method will_use_component has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

            def will_use_component component_name
              helpers_for_component(component_name) do |possible_component_name|
                @used_component_helpers||={}
                unless @used_component_helpers.include?(possible_component_name)
                  if path=component_helper_path(possible_component_name)
      Severity: Minor
      Found in lib/lolita/controllers/component_helpers.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 fix_rails_date_attributes has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

            def fix_rails_date_attributes attributes
              #{"created_at(1i)"=>"2011", "created_at(2i)"=>"4", "created_at(3i)"=>"19", "created_at(4i)"=>"16", "created_at(5i)"=>"14"}
              date_attributes = {}
              attributes.each_pair do |k,v|
                if k.to_s =~ /(.+)\((\d)i\)$/
      Severity: Minor
      Found in lib/lolita/controllers/rails_helpers.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 create has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

              def create(dbi,*args,&block)
      
                options = args ? args.extract_options! : {}
                dbi_field = options[:dbi_field]
                name = args[0] || options[:name] || (dbi_field ? dbi_field.name : nil)
      Severity: Minor
      Found in lib/lolita/configuration/factory/field.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 nested_options_for has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

            def nested_options_for(record)
              if self.parent
                association = self.association
                attr_name = [:one,:many_to_many].include?(association.macro) ? :id : association.foreign_key
                association_record = if association.through? && record.send(association.through)
      Severity: Minor
      Found in lib/lolita/configuration/nested_list.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 clear_models has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def clear_models
              Dir[Rails.root.join("app","models","*.rb")].each do |file_name|
                matched = false
                gsub_file file_name, /^\s*include\s+#{INCLUDE_MODULE}.*/ do |match|
                  matched = true
      Severity: Minor
      Found in lib/generators/lolita/uninstall_generator.rb - About 1 hr to fix

        Method extract_args has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

                def extract_args(*args)
                  if args && args.any?
                    options = args.extract_options! || {}
                    if args[0] && args[0].is_a?(self)
                      args[0]
        Severity: Minor
        Found in lib/lolita/builder.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 sort_params has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def sort_params(params)
                if @sortable
                  pairs = sort_pairs(params)
                  found_pair = false
                  pairs.each_with_index do|pair, index|
        Severity: Minor
        Found in lib/lolita/configuration/column.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 search has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def search(query, options = {})
                #TODO raise error or warn when there are lot of records and no index on field
                unless query.blank?
                  resources = self.klass.arel_table
                  content_fields = @dbi.fields.map{|field| field.type!="string" ? nil : field.name.to_sym}.compact
        Severity: Minor
        Found in lib/lolita/adapter/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

        Function apply_param_to_url has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        function apply_param_to_url(name,new_value,url){
          var value = (url.match(RegExp(name+"=([^&]*)(&|$)")) || [])
          if(new_value){
            if(value[0]){
              replace_value = !new_value ? "" : (name + "=" + new_value + value[2])
        Severity: Minor
        Found in app/assets/javascripts/lolita/main.js - 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 set_state_for has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def set_state_for(record)
                unless record.respond_to?(:read_state!)
                  class << record
        
                    def set_state(new_state)
        Severity: Minor
        Found in lib/lolita/adapter/common_helper.rb - About 1 hr to fix

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

                def map_reduce_search(content_fields,query)
                  keys = "[" + @dbi.fields.map{|f|
                    f.primary? || f.name.to_s.match(/^_/)  ? nil : "'#{f.name}'"
                  }.compact.join(",").to_s + "]"
                  content_keys = "[" + content_fields.map{|f| "'#{f.name}'"}.join(",").to_s + "]"
          Severity: Minor
          Found in lib/lolita/adapter/mongoid.rb - About 1 hr to fix

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

                def lolita_for *resources
                  options = resources.extract_options!
            
                  options[:as]          ||= @scope[:as]     if @scope[:as].present?
                  options[:module]      ||= @scope[:module] if @scope[:module].present?
            Severity: Minor
            Found in lib/lolita/rails/routes.rb - About 1 hr to fix

              Method add_to_navigation_tree has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def add_to_navigation_tree
                    tree = Lolita.navigation
                    if self.visible
                      if self.append_to
                        parent_branch = tree.branches.detect{|b| b.options[:system_name] == self.append_to}
              Severity: Minor
              Found in lib/lolita/mapping.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 active? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def active?(view)
                      resource = view.respond_to?(:resource_class) ? view.send(:resource_class) : nil rescue nil
                      request = view.send(:request)
                      self_active = if self.object.is_a?(Lolita::Mapping) && self.object && self.object.to == resource
                        true
              Severity: Minor
              Found in lib/lolita/navigation/branch.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 search has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def search(query, options = {})
                      unless query.blank?
                        content_fields = @dbi.fields.map{|field|
                          if field.type!="string" || field.name.match(/^_/)
                            nil
              Severity: Minor
              Found in lib/lolita/adapter/mongoid.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

              Severity
              Category
              Status
              Source
              Language