locomotivecms/mounter

View on GitHub

Showing 54 of 54 total issues

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

        def to_params
          params = self.filter_attributes %w(title parent_id slug redirect_url redirect_type handle listed is_layout
            allow_layout published searchable cache_strategy
            response_type position templatized seo_title meta_description meta_keywords)

Severity: Minor
Found in lib/locomotive/mounter/models/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 _write_layouts has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

          def _write_layouts(pages, done)
            if pages['layouts']
              _write(pages['layouts'], done, false, false)

              layouts = pages.values.find_all { |page| page.fullpath =~ /^layouts\// }
Severity: Minor
Found in lib/locomotive/mounter/writer/api/pages_writer.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_slug has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def set_slug
          self.translated_in.each do |locale|
            Locomotive::Mounter.with_locale(locale) do
              # first attempt from the label
              if self._slug.blank?
Severity: Minor
Found in lib/locomotive/mounter/models/content_entry.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 localize_fullpath has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def localize_fullpath(locales = nil)
          locales ||= self.translated_in
          _parent_fullpath  = self.parent.try(:fullpath)
          _fullpath, _slug  = self.fullpath.try(:clone), self.slug.to_s.clone

Severity: Minor
Found in lib/locomotive/mounter/models/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 sanitize_select_options has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

          def sanitize_select_options(options)
            [].tap do |array|
              if options.is_a?(Hash)
                options.each do |locale, values|
                  values.each_with_index do |value, position|
Severity: Minor
Found in lib/locomotive/mounter/reader/file_system/content_types_reader.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 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

          def write(local_path)
            status    = :skipped
            asset     = self.build_asset(local_path)
            response  = self.remote_assets[asset.filename]

Severity: Minor
Found in lib/locomotive/mounter/writer/api/content_assets_writer.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 read has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def read
            super

            # get the site from the API
            site = self.get(:current_site)
Severity: Minor
Found in lib/locomotive/mounter/reader/api/site_reader.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_response has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def apply_response(content_type, response)
            return if content_type.nil? || response.nil?

            content_type._id = response['id']
            content_type.klass_name = response['klass_name']
Severity: Minor
Found in lib/locomotive/mounter/writer/api/content_types_writer.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 write_page has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def write_page(page, path = '')
            self.output_resource_op page

            # Note: we assume the current locale is the default one
            page.translated_in.each do |locale|
Severity: Minor
Found in lib/locomotive/mounter/writer/file_system/pages_writer.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 scalar has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def scalar value, anchor, tag, plain, quoted, style
Severity: Minor
Found in lib/locomotive/mounter/utils/yaml.rb - About 45 mins to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                rescue ApiWriteException => e
                  message = e.message
                  message = message.map do |attribute, errors|
                    "      #{attribute} => #{[*errors].join(', ')}\n".colorize(color: :red)
                  end.join("\n") if message.respond_to?(:keys)
    Severity: Minor
    Found in lib/locomotive/mounter/writer/api/base.rb and 1 other location - About 40 mins to fix
    lib/locomotive/mounter/writer/api/base.rb on lines 72..79

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 38.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                rescue ApiWriteException => e
                  message = e.message
                  message = message.map do |attribute, errors|
                    "      #{attribute} => #{[*errors].join(', ')}\n".colorize(color: :red)
                  end.join("\n") if message.respond_to?(:keys)
    Severity: Minor
    Found in lib/locomotive/mounter/writer/api/base.rb and 1 other location - About 40 mins to fix
    lib/locomotive/mounter/writer/api/base.rb on lines 94..107

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 38.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

          def self.update(resource_name, id, attributes, locale = nil, attribute_names = nil)
    Severity: Minor
    Found in lib/locomotive/mounter/engine_api.rb - About 35 mins to fix

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

                def write
                  if self.site.persisted?
                    self.check_locales! unless self.force? # requirements
      
                    if self.force?
      Severity: Minor
      Found in lib/locomotive/mounter/writer/api/site_writer.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 dynamic_getter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def dynamic_getter(name)
                field = self.content_type.find_field(name)
                value = self.localized_dynamic_attribute_value(field)
      
                case field.type
      Severity: Minor
      Found in lib/locomotive/mounter/models/content_entry.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 localized_dynamic_attribute_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def localized_dynamic_attribute_value(field)
                if field.is_a?(String)
                  field = self.content_type.find_field(field)
                end
      
      
      Severity: Minor
      Found in lib/locomotive/mounter/models/content_entry.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 write_page has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

                def write_page(page)
                  locale = Locomotive::Mounter.locale
      
                  return unless page.translated_in?(locale)
      
      
      Severity: Minor
      Found in lib/locomotive/mounter/writer/api/pages_writer.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 write_snippet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

                def write_snippet(snippet)
                  locale = Locomotive::Mounter.locale
      
                  return unless snippet.translated_in?(locale)
      
      
      Severity: Minor
      Found in lib/locomotive/mounter/writer/api/snippets_writer.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 to_yaml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def to_yaml
                fields = %w(title slug redirect_url redirect_type handle published listed allow_layout is_layout searchable cache_strategy response_type position seo_title meta_description meta_keywords)
      
                _attributes = self.attributes.delete_if do |k, v|
                  !fields.include?(k.to_s) || (!v.is_a?(FalseClass) && v.blank?)
      Severity: Minor
      Found in lib/locomotive/mounter/models/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 fetch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.fetch(resource_name, query = {}, locale = nil, attribute_names = nil)
              params = { query: query || {} }
              params[:query][:locale] = locale if locale
      
              url       = "/#{resource_name}.json"
      Severity: Minor
      Found in lib/locomotive/mounter/engine_api.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