hardpixel/active-content

View on GitHub

Showing 5 of 5 total issues

Method has_related has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def has_related(name, field, options={})
        assoc_type = "#{name}".classify.constantize.base_class.to_s
        assoc_opts = { as: :relatable, class_name: ActiveContent.config.relation_class_name, autosave: true, dependent: :destroy }
        assoc_proc = -> { where field: field }

Severity: Minor
Found in lib/active_content/relatable.rb - About 1 hr to fix

    Method has_attachment has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def has_attachment(name, field, options={})
            assoc_opts = { as: :attachable, class_name: ActiveContent.config.attachment_class_name, autosave: true, dependent: :destroy }
            assoc_proc = -> { where field: field }
    
            multiple = options.delete(:multiple)
    Severity: Minor
    Found in lib/active_content/attachable.rb - About 1 hr to fix

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

            def has_profile(options={})
              include ActiveDelegate
      
              assoc_class    = options.delete(:class_name) || ActiveContent.config.profile_class_name
              image_uploader = options.delete(:uploader) || ActiveContent.config.profile_image_uploader
      Severity: Minor
      Found in lib/active_content/profileable.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 has_uploader has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def has_uploader(name=nil)
              mount_uploader :file, name
      
              define_method :mime_type do
                @mime_type ||= MIME::Types[file.content_type].first
      Severity: Minor
      Found in lib/active_content/uploadable.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 has_related has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def has_related(name, field, options={})
              assoc_type = "#{name}".classify.constantize.base_class.to_s
              assoc_opts = { as: :relatable, class_name: ActiveContent.config.relation_class_name, autosave: true, dependent: :destroy }
              assoc_proc = -> { where field: field }
      
      
      Severity: Minor
      Found in lib/active_content/relatable.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

      Severity
      Category
      Status
      Source
      Language