voormedia/rails-erd

View on GitHub

Showing 18 of 35 total issues

File schema.rb has 505 lines of code (exceeds 250 allowed). Consider refactoring.
Open

ActiveRecord::Schema.define(:version => 20100923162011) do

  create_table "addresses", :force => true do |t|
    t.string   "firstname"
    t.string   "lastname"
Severity: Major
Found in examples/applications/spree/schema.rb - About 1 day to fix

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

        class Relationship
          N = Cardinality::N
    
          class << self
            def from_associations(domain, associations) # @private :nodoc:
    Severity: Minor
    Found in lib/rails_erd/domain/relationship.rb - About 2 hrs to fix

      Method calculate_tax has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.calculate_tax(order, rates=default_rates)
          return 0 if rates.empty?
          # note: there is a bug with associations in rails 2.1 model caching so we're using this hack
          # (see https://rails.lighthouseapp.com/projects/8994/tickets/785-caching-models-fails-in-development)
          cache_hack = rates.first.respond_to?(:tax_category_id)
      Severity: Minor
      Found in examples/applications/spree/models/calculator/vat.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 Domain has 23 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Domain
          class << self
            # Generates a domain model object based on all loaded subclasses of
            # <tt>ActiveRecord::Base</tt>. Make sure your models are loaded before calling
            # this method.
      Severity: Minor
      Found in lib/rails_erd/domain.rb - About 2 hrs to fix

        Method relationship_style has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

                def relationship_style(relationship)
                  {}.tap do |options|
                    options[:style] = :dotted if relationship.indirect?
        
                    options[:arrowsize] = 0.7
        Severity: Minor
        Found in lib/rails_erd/diagram/graphviz.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 relationship_style has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

                def relationship_style(relationship)
                  {}.tap do |options|
                    options[:style] = :dotted if relationship.indirect?
        
                    # Cardinality is "look-across".
        Severity: Minor
        Found in lib/rails_erd/diagram/graphviz.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 relationship_style has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

                def relationship_style(relationship)
                  {}.tap do |options|
                    options[:style] = :dotted if relationship.indirect?
        
                    # Participation is "look-here".
        Severity: Minor
        Found in lib/rails_erd/diagram/graphviz.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 recurse_into_relationships has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def recurse_into_relationships(entity, max_level, current_level = 0)
              return [] unless entity
              return [] if max_level == current_level
        
              relationships = entity.relationships.reject{|r| r.indirect? || r.recursive?}
        Severity: Minor
        Found in lib/rails_erd/diagram.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 normalize_value has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def normalize_value(key, value)
              case key
              # <symbol>[,<symbol>,...] | false
              when :attributes
                if value == false
        Severity: Minor
        Found in lib/rails_erd/config.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 type_description has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def type_description
                type.to_s.dup.tap do |desc|
                  desc << " #{limit_description}" if limit_description
                  desc << " ∗" if mandatory? && !primary_key? # Add a hair space + low asterisk (Unicode characters)
                  desc << " U" if unique? && !primary_key? && !foreign_key? # Add U if unique but non-key
        Severity: Minor
        Found in lib/rails_erd/domain/attribute.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 filtered_entities has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def filtered_entities
              @domain.entities.reject { |entity|
                options.exclude.present? && [options.exclude].flatten.map(&:to_sym).include?(entity.name.to_sym) or
                options[:only].present? && entity.model && ![options[:only]].flatten.map(&:to_sym).include?(entity.name.to_sym) or
                !options.inheritance && entity.specialized? or
        Severity: Minor
        Found in lib/rails_erd/diagram.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 calculate_tax_on has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.calculate_tax_on(product_or_variant)
            vat_rates = default_rates
        
            return 0 if vat_rates.nil?
            return 0 unless tax_category = product_or_variant.is_a?(Product) ? product_or_variant.tax_category : product_or_variant.product.tax_category
        Severity: Minor
        Found in examples/applications/spree/models/calculator/vat.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 check_model_validity has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def check_model_validity(model)
              if model.abstract_class? || model.table_exists?
                if model.name.nil?
                  raise "is anonymous class"
                else
        Severity: Minor
        Found in lib/rails_erd/domain.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 relationship_style has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def relationship_style(relationship)
                  {}.tap do |options|
                    options[:style] = :dotted if relationship.indirect?
        
                    # Closed arrows for to/from many.
        Severity: Minor
        Found in lib/rails_erd/diagram/graphviz.rb - About 45 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 use_os_x_fonts? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.use_os_x_fonts?
              host = RbConfig::CONFIG['host_os']
              return true if host == "darwin"
        
              if host.include? "darwin"
        Severity: Minor
        Found in lib/rails_erd/config.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 start has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def start
                path = Choice.rest.first || Dir.pwd
                options = Choice.choices.each_with_object({}) do |(key, value), opts|
                  if key.start_with? "no_"
                    opts[key.gsub("no_", "").to_sym] = !value
        Severity: Minor
        Found in lib/rails_erd/cli.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 load_application has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def load_application
              $stderr.puts "Loading application in '#{File.basename(path)}'..."
              environment_path = "#{path}/config/environment.rb"
              require environment_path
        
        
        Severity: Minor
        Found in lib/rails_erd/cli.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

        Method delegate_belongs_to has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def delegate_belongs_to(association, *attrs)
              opts = attrs.extract_options!
              initialize_association :belongs_to, association, opts
              attrs = get_association_column_names(association) if attrs.empty?
              attrs.concat get_association_column_names(association) if attrs.delete :defaults
        Severity: Minor
        Found in examples/applications/spree/lib/delegate_belongs_to.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

        Severity
        Category
        Status
        Source
        Language