artirix/browsercms

View on GitHub

Showing 87 of 119 total issues

Method input has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def input(_wrapper_options = nil)
    # New blocks will not have their attachments created yet.
    object.ensure_attachment_exists if object.respond_to?(:ensure_attachment_exists)

    # Need to explictly use correct id (i.e. image_block_file) rather than the autogenerated one (i.e. image_block_attachments_attributes_0_attachment_name)
Severity: Minor
Found in app/inputs/file_picker_input.rb - About 1 hr to fix

    Method inherited has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.inherited(subclass)
          super if defined? super
        ensure
          subclass.class_eval do
            extend Cms::PolymorphicSingleTableInheritance
    Severity: Minor
    Found in app/models/cms/portlet.rb - About 1 hr to fix

      Method copy_connectors has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def copy_connectors(options={})
          logger.debug { "Copying connectors from Page #{id} v#{options[:from_version_number]} to v#{options[:to_version_number]}." }
      
          c_found = connectors.for_page_version(options[:from_version_number]).order("#{Cms::Connector.table_name}.container, #{Cms::Connector.table_name}.position").to_a
          logger.debug { "Found connectors #{c_found}" }
      Severity: Minor
      Found in app/models/cms/page.rb - About 1 hr to fix

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

            def index
              @have_external_users = Cms::ExternalUser.count > 0
        
              query, conditions = [], []
        
        
        Severity: Minor
        Found in app/controllers/cms/users_controller.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 update_connected_pages has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                def update_connected_pages
                  # If this is versioned, then we need make new versions of all the pages this is connected to
                  if self.class.versioned?
                    #logger.info "..... Updating connected pages for #{self.class} #{id} v#{version}"
        
        
        Severity: Minor
        Found in lib/cms/behaviors/connecting.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 move_connector has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def move_connector(connector, direction)
            transaction do
              raise "Connector is nil" unless connector
              raise "Direction is nil" unless direction
              orientation = direction[/_/] ? "#{direction.sub('_', ' the ')} of" : "#{direction} within"
        Severity: Minor
        Found in app/models/cms/page.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 assign_parent_if_needed has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def assign_parent_if_needed
                unless parent || parent_id
                  new_parent = Cms::Section.with_path(self.class.path).first
        
                  unless new_parent
        Severity: Minor
        Found in lib/cms/concerns/can_be_addressable.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 render_portlet has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def render_portlet(name)
              portlets = Portlet.all(:conditions => ["name = ?", name.to_s])
              if portlets.size > 1
                edit_mode? ? "ERROR: Multiple Portlets with name '#{name}'" : nil
              elsif portlets.empty?
        Severity: Minor
        Found in app/helpers/cms/page_helper.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 set_template has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.set_template(args)
            if args.include?("-m")
              index = args.index("-m")
              if args[index + 1] == "demo"
                args[index + 1] = template("demo.rb")
        Severity: Minor
        Found in lib/command_line.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 menu_button has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def menu_button(label, path, options={})
              return '' unless path.present?
        
              defaults = {
                  enabled: true,
        Severity: Minor
        Found in app/helpers/cms/ui_elements_helper.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 live? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                def live?
                  if self.class.versioned?
                    unless persisted?
                      return false
                    end
        Severity: Minor
        Found in lib/cms/behaviors/publishing.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 write_attribute_with_dynamic_attributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def write_attribute_with_dynamic_attributes(attr_name, value)
                attr_name = attr_name.to_s
                exec_if_related attr_name do |model|
                  value_field = dynamic_options[model.name][:value_field]
                  @save_dynamic_attr ||= []
        Severity: Minor
        Found in lib/cms/behaviors/dynamic_attributes.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 acts_as_cms_user has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def acts_as_cms_user(options = {})
                  include InstanceMethods
        
                  # Adding a cms_group method to each person object that returns a list of
                  # CMS Groups the user belongs to.  Can be set with an array, proc, or
        Severity: Minor
        Found in lib/cms/acts/cms_user.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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def create
              return render_not_implemented if readonly?
        
              if create_block
                after_create_on_success
        Severity: Minor
        Found in app/controllers/cms/content_block_controller.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 method_missing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def method_missing(method_name, *args)
              if md = method_name.to_s.match(/^create_(.+)$/)
                klass = model_class(md[1])
                self.create(klass.name, args[0], args[1] || {})
              elsif @data && @data.has_key?(method_name)
        Severity: Minor
        Found in lib/cms/data_loader.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 move_to has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def move_to(section, position)
            #logger.info "Moving Section Node ##{id} to Section ##{sec.id} Position #{pos}"
            transaction do
              if self.parent != section.node
                remove_from_list
        Severity: Minor
        Found in app/models/cms/section_node.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 submit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def submit
              find_form_and_populate_entry
              if @entry.save
                if @form.show_text?
                  show_content_as_page(@form)
        Severity: Minor
        Found in app/controllers/cms/form_entries_controller.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 create_or_update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def create_or_update
                  logger.debug { "#{self.class}#create_or_update called. Published = #{!!publish_on_save}" }
                  self.skip_callbacks = false
                  unless different_from_last_draft?
                    logger.debug { "No difference between this version and last. Skipping save" }
        Severity: Minor
        Found in lib/cms/behaviors/versioning.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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def update
              return render_not_implemented if readonly?
        
              if update_block
                after_update_on_success
        Severity: Minor
        Found in app/controllers/cms/content_block_controller.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 in_section? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def in_section?(section_or_section_name)
            found = false
            ancestors.each do |a|
              if section_or_section_name.is_a?(String)
                if a.name == section_or_section_name
        Severity: Minor
        Found in app/models/cms/page.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

        Severity
        Category
        Status
        Source
        Language