locomotivecms/steam

View on GitHub

Showing 89 of 89 total issues

Method apply_metafields_samples has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def apply_metafields_samples(entity)
            entity.metafields_schema&.each do |namespace|
              namespace[:fields].each do |field|
                next unless field[:sample].present?

Severity: Minor
Found in lib/locomotive/steam/adapters/filesystem/sanitizers/site.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 extract_locale has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def extract_locale
        # Regarding the index page (basically, "/"), we've to see if we could
        # guess the locale from the headers the browser sends to us.
        locale = if is_index_page? && !site.bypass_browser_locale
          locale_from_params || locale_from_cookie || locale_from_header
Severity: Minor
Found in lib/locomotive/steam/middlewares/locale.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 redirect_url has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def redirect_url
        if apply_redirection?
          if site.prefix_default_locale
            path_with_locale if locale_not_mentioned_in_path?
          else
Severity: Minor
Found in lib/locomotive/steam/middlewares/locale_redirection.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def initialize(repository_klass, scope, adapter, options = {}, &block)
Severity: Minor
Found in lib/locomotive/steam/models/associations/referenced.rb - About 35 mins to fix

    Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def initialize(message, template_name, source, line_number, original_backtrace)
    Severity: Minor
    Found in lib/locomotive/steam/errors.rb - About 35 mins to fix

      Method association has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def association(type, name, repository_klass, options = nil, &block)
      Severity: Minor
      Found in lib/locomotive/steam/models/mapper.rb - About 35 mins to fix

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

                  def safe_value(value, type = 'string')
                    case type
                    when 'boolean'
                      ['1', 'true', true].include?(value) ? true : false
                    else
        Severity: Minor
        Found in lib/locomotive/steam/liquid/drops/metafields.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 prepare_attributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def prepare_attributes(content_type, attributes)
                select_field_names = content_type.fields.selects.map(&:name)
        
                attributes.each do |key, value|
                  next unless value.is_a?(String)
        Severity: Minor
        Found in lib/locomotive/steam/services/content_entry_service.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 parse_snippet_template has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                  def parse_snippet_template(template_name)
                    source = if template_name.include?('{{')
                      template_name
                    else
                      snippet = services.snippet_finder.find(template_name)
        Severity: Minor
        Found in lib/locomotive/steam/liquid/tags/nav.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 each_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                    def each_file(&block)
                      Dir.glob(File.join(path, '**', '*')).each do |filepath|
                        next unless is_liquid_file?(filepath)
        
                        relative_path = get_relative_path(filepath)
        Severity: Minor
        Found in lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.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 parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                  def parse(tokens)
                    # look for editable elements (only used by the Engine)
                    # In the next version of Locomotive (v5), we won't support the editable elements
                    # NOTE: it doesn't support dynamically choosen template
                    template_name = template_name_expr.respond_to?(:name) ? template_name_expr.name : template_name_expr
        Severity: Minor
        Found in lib/locomotive/steam/liquid/tags/snippet.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 value_to_id has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def value_to_id(value, target_id)
                  return values_to_ids(value, target_id) if value.kind_of?(Array)
        
                  _value = if value.is_a?(Hash)
                    value['_id'] || value[:_id]
        Severity: Minor
        Found in lib/locomotive/steam/repositories/content_entry_repository.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 find_dynamic_url_redirection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def find_dynamic_url_redirection(redirections_hash)
                number_of_segments = requested_url.split('/').size
        
                # attempt to find the first dynamic route which matches
                redirections_hash.each do |route, redirection|
        Severity: Minor
        Found in lib/locomotive/steam/middlewares/url_redirection.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 translate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def translate(input, options = {})
                locale  = options['locale'] || self.current_locale
                scope   = options.delete('scope')
                key     = scope.present? ? "#{scope.gsub('.', '_')}_#{input}" : input
        
        
        Severity: Minor
        Found in lib/locomotive/steam/services/translator_service.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 fetch_page has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def fetch_page
                page = site.routes.present? ? fetch_page_from_routes : nil
        
                # if we don't find it from the site routes, try with the paths
                page ||= fetch_page_from_paths
        Severity: Minor
        Found in lib/locomotive/steam/middlewares/page.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 find_page has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def find_page(type, value)
                case type
                when 'page'
                  page_finder.find_by_id(value)
                when 'content_entry'
        Severity: Minor
        Found in lib/locomotive/steam/services/url_finder_service.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 _call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def _call
                if cacheable?
                  key = cache_key
        
                  # TODO: only for debugging
        Severity: Minor
        Found in lib/locomotive/steam/middlewares/cache.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 value_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def value_for(entry, name, conditions = {})
                return nil if entry.nil?
        
                if field = content_type.fields_by_name[name]
                  value = entry.send(name)
        Severity: Minor
        Found in lib/locomotive/steam/repositories/content_entry_repository.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 order_by has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def order_by
              if (order_by = self[:order_by]).present?
                # from Filesystem -> string, from MongoDB -> array (string transformed by Engine)
                name, direction = order_by.respond_to?(:each) ? order_by : order_by.split
                { name.to_sym => direction || 'asc' }
        Severity: Minor
        Found in lib/locomotive/steam/entities/content_type_field.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_parts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                  def _build_parts(pagination, path, page, hellip_break)
                    if pagination['current_page'] == page
                      pagination['parts'] << no_link(page)
                    elsif is_page_a_bound?(pagination, page)
                      pagination['parts'] << link(page, page, path)
        Severity: Minor
        Found in lib/locomotive/steam/liquid/tags/paginate.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

        Severity
        Category
        Status
        Source
        Language