locomotivecms/mounter

View on GitHub

Showing 48 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

    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

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

            def setter(name, value, options = {})
              if options[:localized]
                # keep track of the current locale
                self.add_locale(Locomotive::Mounter.locale)
      
      
      Severity: Minor
      Found in lib/locomotive/mounter/fields.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 sanitize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def sanitize
                # if no label_field_name provided, take the first field
                unless self.label_field_name
                  self.label_field_name = (self.fields || []).first.try(:name)
                end
      Severity: Minor
      Found in lib/locomotive/mounter/models/content_type.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