SpontaneousCMS/spontaneous

View on GitHub
lib/spontaneous/data_mapper/content_model/associations.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method belongs_to_content has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def belongs_to_content(name, opts = {})
          opts[:association]    = :many_to_one
          opts[:dataset_method] = "#{name}_dataset"
          opts[:add_method]     = "#{name}="
          opts[:load_method]    = "load_#{opts[:association]}_association".to_sym
Severity: Minor
Found in lib/spontaneous/data_mapper/content_model/associations.rb - About 1 hr to fix

    Method has_many_content has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def has_many_content(name, opts = {})
              opts[:association]    = :one_to_many
              opts[:dataset_method] = "#{name}_dataset"
              opts[:load_ps_method] = "load_#{name}_association_prepared_statement".to_sym
              opts[:ps_method]      = "#{name}_prepared_statement".to_sym
    Severity: Minor
    Found in lib/spontaneous/data_mapper/content_model/associations.rb - About 1 hr to fix

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

              def belongs_to_content(name, opts = {})
                opts[:association]    = :many_to_one
                opts[:dataset_method] = "#{name}_dataset"
                opts[:add_method]     = "#{name}="
                opts[:load_method]    = "load_#{opts[:association]}_association".to_sym
      Severity: Minor
      Found in lib/spontaneous/data_mapper/content_model/associations.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 define_proxy_association has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def define_proxy_association(association, proxy_methods, name, opts = {}, &block)
      Severity: Minor
      Found in lib/spontaneous/data_mapper/content_model/associations.rb - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status