locomotivecms/mounter

View on GitHub

Showing 48 of 54 total issues

Class Page has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

      class Page < Base

        ## fields ##
        field :parent,            association: true
        field :title,             localized: true
Severity: Minor
Found in lib/locomotive/mounter/models/page.rb - About 3 hrs to fix

    Class ContentEntry has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

          class ContentEntry < Base
    
            ## fields ##
            field :_slug,               localized: true
            field :_position,           default: 0
    Severity: Minor
    Found in lib/locomotive/mounter/models/content_entry.rb - About 2 hrs to fix

      Method attributes_with_translations has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

            def attributes_with_translations
              {}.tap do |_attributes|
                self.class._fields.each do |name, options|
                  next if options[:association]
      
      
      Severity: Minor
      Found in lib/locomotive/mounter/fields.rb - About 2 hrs 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 16 (exceeds 5 allowed). Consider refactoring.
      Open

                def write
                  done = {}
      
                  # first new content types
                  self.not_persisted.each do |content_type|
      Severity: Minor
      Found in lib/locomotive/mounter/writer/api/content_types_writer.rb - About 2 hrs 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 16 (exceeds 5 allowed). Consider refactoring.
      Open

                def _write(page, done, already_done = false, with_children = true)
                  if self.safely_translated?(page)
                    write_page(page) unless already_done
                  else
                    self.output_resource_op page
      Severity: Minor
      Found in lib/locomotive/mounter/writer/api/pages_writer.rb - About 2 hrs 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 content_entries_with_relationships_to_hash has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

                def content_entries_with_relationships_to_hash
                  [].tap do |updates|
                    self.with_relationships.each do |(slug, content_entry)|
                      changes = {}
      
      
      Severity: Minor
      Found in lib/locomotive/mounter/writer/api/content_entries_writer.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 fetch has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

                def fetch
                  position, last_dirname = nil, nil
      
                  Dir.glob(File.join(self.root_dir, '**/*')).sort.each do |filepath|
                    next unless File.directory?(filepath) || filepath =~ /\.(#{Locomotive::Mounter::TEMPLATE_EXTENSIONS.join('|')})$/
      Severity: Minor
      Found in lib/locomotive/mounter/reader/file_system/pages_reader.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 write has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

                def write
                  return unless self.data?
      
                  self.each_locale do |locale|
                    self.output_locale
      Severity: Minor
      Found in lib/locomotive/mounter/writer/api/content_entries_writer.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 safe_fullpath has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

              def safe_fullpath(wildcard = true)
                if self.index_or_404?
                  self.slug
                else
                  base  = self.parent.safe_fullpath(wildcard)
      Severity: Minor
      Found in lib/locomotive/mounter/models/page.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 write has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

                def write
                  self.theme_assets_by_priority.each do |theme_asset|
                    # track it in the logs
                    self.output_resource_op theme_asset
      
      
      Severity: Minor
      Found in lib/locomotive/mounter/writer/api/theme_assets_writer.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 write_attributes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def write_attributes(attributes)
              return if attributes.blank?
      
              attributes.each do |name, value|
                unless self.class._fields.key?(name.to_sym) || self.respond_to?(:"#{name}=")
      Severity: Minor
      Found in lib/locomotive/mounter/fields.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 content_entry_to_params has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

                def content_entry_to_params(entry)
                  params = entry.to_params
      
                  entry.each_dynamic_field do |field, value|
                    unless field.is_relationship?
      Severity: Minor
      Found in lib/locomotive/mounter/writer/api/content_entries_writer.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 page_to_params has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

                def page_to_params(page, safe = false)
                  (safe ? page.to_safe_params : page.to_params).tap do |params|
                    # raw template
                    params[:raw_template] = self.replace_content_assets!(params[:raw_template])
      
      
      Severity: Minor
      Found in lib/locomotive/mounter/writer/api/pages_writer.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_template_for_each_locale has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

                def set_default_template_for_each_locale
                  self.items.values.each do |snippet|
                    default_template = snippet.template
      
                    next if default_template.blank?
      Severity: Minor
      Found in lib/locomotive/mounter/reader/file_system/snippets_reader.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 to_hash has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def to_hash(nested = true)
                # no need of _position and _visible (unless it's false)
                hash = super.delete_if { |k, v| k == '_position' || (k == '_visible' && v == true) }
      
                # also no need of the content type
      Severity: Minor
      Found in lib/locomotive/mounter/models/content_entry.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 fetch_from_content_entries has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

                def fetch_from_content_entries
                  self.mounting_point.content_entries.values.each do |content_entry|
                    content_entry.translated_in.each do |locale|
                      Locomotive::Mounter.with_locale(locale) do
                        # get the string, text, file fields...
      Severity: Minor
      Found in lib/locomotive/mounter/reader/file_system/content_assets_reader.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 write has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                def write
                  self.theme_assets_by_priority.each do |theme_asset|
                    # track it in the logs
                    self.output_resource_op theme_asset
      
      
      Severity: Minor
      Found in lib/locomotive/mounter/writer/api/theme_assets_writer.rb - About 1 hr to fix

        Method set_editable_elements has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

                def set_editable_elements(attributes)
                  return if attributes.blank?
        
                  self.editable_elements ||= []
        
        
        Severity: Minor
        Found in lib/locomotive/mounter/models/page.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 build_entry has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

                def build_entry(attributes)
                  ContentEntry.new(content_type: self).tap do |entry|
                    # set the link to the mounting point
                    entry.mounting_point = self.mounting_point
        
        
        Severity: Minor
        Found in lib/locomotive/mounter/models/content_type.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 writers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

                  def writers
                    [SiteWriter, SnippetsWriter, ContentTypesWriter, ContentEntriesWriter, TranslationsWriter, PagesWriter, ThemeAssetsWriter].tap do |_writers|
                      # modify the list depending on the parameters
                      if self.parameters
                        if self.parameters[:data] == false && !(self.parameters[:only].try(:include?, 'content_entries'))
        Severity: Minor
        Found in lib/locomotive/mounter/writer/api.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

        Severity
        Category
        Status
        Source
        Language