locomotivecms/steam

View on GitHub

Showing 77 of 89 total issues

Method build_httpparty_options has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def build_httpparty_options(options, method)
        _options = {}

        # data: body (POST/PUT/PATCH) or query (GET)
        _options[method == 'get' ? :query : :body] = options[:data] if options[:data]
Severity: Minor
Found in lib/locomotive/steam/services/external_api_service.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 editor_settings_lookup has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def editor_settings_lookup(root)
      return if root.nodelist.blank?

      previous_node = nil
      new_nodelist  = []
Severity: Minor
Found in lib/locomotive/steam/liquid/tags/concerns/section.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 _url_for has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def _url_for(page, locale = nil, prefix_default_locale = nil)
        locale          = locale&.to_sym
        _locale         = (locale || current_locale).to_sym
        default_locale  = site.default_locale.to_sym
        same_locale     = _locale == default_locale
Severity: Minor
Found in lib/locomotive/steam/services/url_builder_service.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 fill_presets has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

          def fill_presets(definition)
            if definition.key?('default') && definition.key?('presets')
              definition['presets'].each_with_index do |preset_definition, preset_index|
                next unless preset_definition.delete('use_default') == true

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

          def set_default_values(definition)
            content = definition['default']

            return if content.nil?

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

          def evaluate_attributes(context)
            @attributes = context[attributes_var_name] || {} if attributes_var_name.present?

            HashWithIndifferentAccess.new.tap do |hash|
              attributes.each do |key, value|
Severity: Minor
Found in lib/locomotive/steam/liquid/tags/with_scope.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 apply_transformation has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            def apply_transformation(url, context)
              # resize image with the image_resizer service?
              if (format = attributes[:resize]).present?
                options = []

Severity: Minor
Found in lib/locomotive/steam/liquid/tags/editable/file.rb - About 1 hr to fix

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

              def localized_date(input, *args)
                return '' if input.blank?
    
                format, locale = args
    
    
    Severity: Minor
    Found in lib/locomotive/steam/liquid/filters/date.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 _prepare has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def _prepare(fields, &block)
              fields.each do |field|
                name      = field.name.to_s
                operator  = @operators[name]
                _name     = operator ? "#{name}.#{operator}" : name
    Severity: Minor
    Found in lib/locomotive/steam/repositories/content_entry_repository.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 build_templatized_page_to_xml has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def build_templatized_page_to_xml(page)
            content_type = repositories.content_type.find(page.content_type_id)
    
            repositories.content_entry.with(content_type).all({ _visible: true }).map do |content_entry|
              _content_entry  = Locomotive::Steam::Decorators::I18nDecorator.new(content_entry, locale)
    Severity: Minor
    Found in lib/locomotive/steam/middlewares/sitemap.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 decode_symbol_operators has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def decode_symbol_operators(criterion)
              criterion.dup.tap do |_criterion|
                criterion.each do |key, value|
                  next unless key.is_a?(String)
    
    
    Severity: Minor
    Found in lib/locomotive/steam/adapters/mongodb/query.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 transform_sections_content has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

              def transform_sections_content(page, locale)
                [:sections_dropzone_content, :sections_content].each do |name|
                  if content = page[name][locale]
                    return unless content.is_a?(String)
    
    
    Severity: Minor
    Found in lib/locomotive/steam/adapters/filesystem/sanitizers/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 json has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

              def json(input, fields = [])
                if fields && fields.is_a?(String)
                  fields = fields.split(',').map(&:strip)
                end
    
    
    Severity: Minor
    Found in lib/locomotive/steam/liquid/filters/json.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 _path_combinations has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def _path_combinations(segments, can_include_template = true)
            return nil if segments.empty?
            segment = segments.shift
    
            (can_include_template ? [segment, WILDCARD] : [segment]).map do |_segment|
    Severity: Minor
    Found in lib/locomotive/steam/services/page_finder_service.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 load_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

                def load_data
                  Dir.glob(File.join(data_path, '**', '*.json')).each do |filepath|
                    filepath  =~ /#{data_path}\/([a-z]+)\//
                    data      = safe_json_file_load(filepath)
                    locale    = $1.to_sym
    Severity: Minor
    Found in lib/locomotive/steam/adapters/filesystem/yaml_loaders/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

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

                def build_field(name, attributes, position)
                  attributes.tap do |attributes|
                    attributes[:_id]      = name.to_s
                    attributes[:name]     = name.to_s
                    attributes[:type]     = (attributes[:type] || 'string').to_s.downcase
    Severity: Minor
    Found in lib/locomotive/steam/adapters/filesystem/yaml_loaders/content_type.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 render_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

                def render_path(context, &block)
                  evaluate_attributes(context, lax: true)
    
                  set_vars_from_context(context)
    
    
    Severity: Minor
    Found in lib/locomotive/steam/liquid/tags/concerns/path.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 location has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def location(state, query = '')
            location = params[:"#{state}_callback"] || (entry_submissions_path? ? '/' : request.path_info)
    
            if query.blank?
              location
    Severity: Minor
    Found in lib/locomotive/steam/middlewares/entry_submission.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 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

    Severity
    Category
    Status
    Source
    Language