voormedia/rails-erd

View on GitHub

Showing 35 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

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

          create_table "events", :force => true do |t|
            t.string   "title"
            t.text     "description"
            t.text     "introduction"
            t.text     "report"
        Severity: Minor
        Found in examples/applications/event_forms/schema.rb and 1 other location - About 1 hr to fix
        examples/applications/spree/schema.rb on lines 3..16

        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 47.

        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

          create_table "addresses", :force => true do |t|
            t.string   "firstname"
            t.string   "lastname"
            t.string   "address1"
            t.string   "address2"
        Severity: Minor
        Found in examples/applications/spree/schema.rb and 1 other location - About 1 hr to fix
        examples/applications/event_forms/schema.rb on lines 12..25

        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 47.

        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

        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

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

          create_table "images", :force => true do |t|
            t.string   "image_mime_type"
            t.string   "image_name"
            t.integer  "image_size"
            t.integer  "image_width"
        Severity: Minor
        Found in examples/applications/refinery/schema.rb and 1 other location - About 35 mins to fix
        examples/applications/gemcutter/schema.rb on lines 23..32

        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 35.

        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

        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

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

          create_table "linksets", :force => true do |t|
            t.integer  "rubygem_id"
            t.string   "home"
            t.string   "wiki"
            t.string   "docs"
        Severity: Minor
        Found in examples/applications/gemcutter/schema.rb and 1 other location - About 35 mins to fix
        examples/applications/refinery/schema.rb on lines 3..12

        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 35.

        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

        Severity
        Category
        Status
        Source
        Language