sterrym/smithycms

View on GitHub

Showing 12 of 20 total issues

Class Page has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

      class Page < Base
        delegate :title, :depth, :permalink, :root, :site, :to => '_source'

        def breadcrumbs
          self._source.ancestors.where(["id != ?", root]).map(&:to_liquid)
Severity: Minor
Found in lib/smithy/liquid/drops/page.rb - About 2 hrs to fix

    Method initialize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

            def initialize(tag_name, markup, tokens)
              @options = { :id => 'nav', :depth => 1, :class => '', :active_class => 'on', :include_root => false }
              if markup =~ Syntax
                @source = ($1 || 'site').gsub(/"|'/, '')
                markup.scan(::Liquid::TagAttributes) do |key, value|
    Severity: Minor
    Found in lib/smithy/liquid/tags/nav.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 pages has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def pages
          unless @pages
            return unless self.parent
            @pages = self.parent.children
            @pages = @pages.except(:order).order(sort_sql) unless sort_sql.nil?
    Severity: Minor
    Found in app/models/smithy/page_list.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 sanitize_config has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def sanitize_config
            {
              elements: %w(
                p div ul ol li blockquote pre h1 h2 h3 h4 h5 h6 object
                hr param
    Severity: Minor
    Found in lib/smithy/formatter.rb - About 1 hr to fix

      Method create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def create
            @page.duplicate_content_from(params[:page][:copy_content_from]) if params[:page][:copy_content_from].present? && @page.valid?
            @page.save
            flash.notice = "Your page was created #{@page.published? ? 'and published' : 'as a draft'}" if @page.persisted?
            respond_with @page do |format|
      Severity: Minor
      Found in app/controllers/smithy/pages_controller.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 set_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def set_name
              if self.uploaded_file_url?
                self.name = File.basename(self.uploaded_file_url, '.*').titleize unless self.name?
              elsif self.file.present?
                self.name = File.basename(self.file_filename, '.*').titleize unless self.name?
      Severity: Minor
      Found in app/models/smithy/asset.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 content_block_attributes_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def content_block_attributes_for(content_block_type)
              attributes_method = "#{content_block_type.underscore}_attributes".to_sym
              if self.respond_to?(attributes_method)
                public_send(attributes_method)
              else
      Severity: Minor
      Found in app/models/smithy/permitted_params.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 write_child_list_items? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                def write_child_list_items?(parent, depth)
                  return false unless parent.present? && !parent.leaf?
                  return true if @source == 'site-section' && @page.self_and_ancestors.include?(parent)
                  depth > @options[:depth] ? false : true
                end
      Severity: Minor
      Found in lib/smithy/liquid/tags/nav.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 normalize_friendly_id has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def normalize_friendly_id(value) # normalize_friendly_id overrides the default creator for friendly_id
            return "/" if self.parent.blank?
            value = self.permalink? ? self.permalink.parameterize : value.to_s.parameterize
            [(self.parent.present? && !self.parent.root? ? self.parent.path : nil), value].join('/').downcase
          end
      Severity: Minor
      Found in app/models/smithy/page.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 register has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def register(content_block)
                return unless ActiveRecord::Base.connection.table_exists?(Smithy::ContentBlock.table_name)
                return unless ActiveRecord::Base.connection.table_exists?(content_block.table_name)
                content_block_name = content_block.to_s.demodulize
                @@content_blocks << content_block_name unless @@content_blocks.include?(content_block_name)
      Severity: Minor
      Found in lib/smithy/content_blocks/registry.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 render_list_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def render_list_item(item, depth)
                item_id = "#{@options[:id]}-#{item.permalink}"
                href = item.url
                label = item.title
                css_class = " class=\"#{@options[:active_class]}\"" if (@page && @page.id == item.id) || (@controller && [item.path, item.external_link].include?(@controller.request.path))
      Severity: Minor
      Found in lib/smithy/liquid/tags/nav.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 asset_preview_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def asset_preview_link(asset_id)
            asset = Smithy::Asset.find_by_id(asset_id)
            return unless asset
            link_to attachment_url(asset, :file) do
              if asset.file_type == :image
      Severity: Minor
      Found in app/helpers/smithy/assets_helper.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