locomotivecms/steam

View on GitHub

Showing 77 of 89 total issues

Method parse_date_time has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

          def parse_date_time(input, format = nil)
            return '' if input.blank?

            format    ||= I18n.t('time.formats.default')
            date_time = ::DateTime._strptime(input, format)
Severity: Minor
Found in lib/locomotive/steam/liquid/filters/date.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

Method build_page_to_xml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def build_page_to_xml(page)
        entry = { date: page.updated_at.to_date, links: [] }

        site.locales.each_with_index do |locale, index|
          page.__locale__ = locale
Severity: Minor
Found in lib/locomotive/steam/middlewares/sitemap.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 url_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def url_for(resource)
        return [resource, false] if resource.is_a?(String)

        _resource   = resource || {}
        page_or_url = find_page(_resource['type'], _resource['value']) || page_finder.find('404')
Severity: Minor
Found in lib/locomotive/steam/services/url_finder_service.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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

            def render(context)
              evaluate_attributes(context)

              service   = context.registers[:services].editable_element
              page      = fetch_page(context)
Severity: Minor
Found in lib/locomotive/steam/liquid/tags/editable/base.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 in_groups_of has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

          def in_groups_of(array, number, fill_with = nil)
            return array unless array.respond_to?(:all) || array.respond_to?(:each_slice)

            number        = number.to_i
            grouped_array = array.respond_to?(:all) ? array.all : array
Severity: Minor
Found in lib/locomotive/steam/liquid/filters/array.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 apply has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def apply(&block)
        if default
          @translations = Hash.new(yield(default))
        else
          each do |l, _value|
Severity: Minor
Found in lib/locomotive/steam/models/i18n_field.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 resize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def resize(source, geometry, convert = "")
        return get_url_or_path(source) if disabled? || geometry.blank?

        if file = fetch_file(source)
          transformed_file = file.thumb(geometry)
Severity: Minor
Found in lib/locomotive/steam/services/image_resizer_service.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 blocks_as_tree has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

          def blocks_as_tree
            [].tap do |root|
              parents = []

              build_blocks(@content['blocks']) do |block, previous_block|
Severity: Minor
Found in lib/locomotive/steam/liquid/drops/section.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 build has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def build(path)
        # keep the query string safe
        path.gsub!(/(\?+.+)$/, '')
        query_string = $1

Severity: Minor
Found in lib/locomotive/steam/services/theme_asset_url_service.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 limited has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def limited(entries)
          return [] if @limit == 0
          return entries if @offset == 0 && @limit.nil?

          subentries = entries.drop(@offset || 0)
Severity: Minor
Found in lib/locomotive/steam/adapters/memory/query.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 build_pages_to_xml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def build_pages_to_xml
        # we request the data based on the default locale
        page_repository.locale = site.default_locale

        page_repository.published.map do |page|
Severity: Minor
Found in lib/locomotive/steam/middlewares/sitemap.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 next_or_previous has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def next_or_previous(entry, asc_op, desc_op)
        return nil if entry.nil?

        with(entry.content_type)

Severity: Minor
Found in lib/locomotive/steam/repositories/content_entry_repository.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 load_tree has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

            def load_tree
              # load the core pages and layouts from the app/views/pages folder
              each_file do |filepath, fullpath, locale|
                if leaf = @pages_by_fullpath[fullpath]
                  update(leaf, filepath, fullpath, locale)
Severity: Minor
Found in lib/locomotive/steam/adapters/filesystem/yaml_loaders/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 _decode_order_by has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def _decode_order_by(arg)
          case arg
          when String
            if arg.include?(',')
              _decode_order_by(arg.split(','))
Severity: Minor
Found in lib/locomotive/steam/adapters/mongodb/query.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 build_body has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def build_body(options, context, html = true)
        key = html || html.nil? ? :html_body : :body

        document = (if handle = options.delete(:page_handle)
          parse_page(handle)
Severity: Minor
Found in lib/locomotive/steam/services/email_service.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 parse_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

          def parse_date(input, format = nil)
            return '' if input.blank?

            format  ||= I18n.t('date.formats.default')
            date    = ::Date._strptime(input, format)
Severity: Minor
Found in lib/locomotive/steam/liquid/filters/date.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 to_distance_in_seconds has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

          def to_distance_in_seconds(locale, distance_in_minutes, distance_in_seconds, include_seconds)
            return distance_in_minutes == 0 ?
                         locale.t(:less_than_x_minutes, count: 1) :
                         locale.t(:x_minutes, count: distance_in_minutes) unless include_seconds

Severity: Minor
Found in lib/locomotive/steam/liquid/filters/date.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