locomotivecms/wagon

View on GitHub

Showing 32 of 42 total issues

File cli.rb has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'thor'
require 'thor/runner'

module Locomotive
  module Wagon
Severity: Minor
Found in lib/locomotive/wagon/cli.rb - About 4 hrs to fix

    Method template has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def template
            %{
    <DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    Severity: Major
    Found in lib/locomotive/wagon/middlewares/error_page.rb - About 3 hrs to fix

      Method parse has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse(chars)
              curlies, escaping = 0, false
              chars.map do |char|
                if escaping
                  escaping = false
      Severity: Minor
      Found in lib/locomotive/wagon/tools/glob.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 decode_json_attribute has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def decode_json_attribute(attributes, name, &block)
            value = attributes.delete(name)
      
            return if value.blank?
      
      

      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 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def parse(chars)
              curlies, escaping = 0, false
              chars.map do |char|
                if escaping
                  escaping = false
      Severity: Minor
      Found in lib/locomotive/wagon/tools/glob.rb - About 1 hr to fix

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

              def smoosh(chars)
                [].tap do |out|
                  until chars.empty?
                    char = chars.shift
                    if char == "*" and chars.first == "*"
        Severity: Minor
        Found in lib/locomotive/wagon/tools/glob.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_page has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def write_page(page, locale = nil)
              instrument :writing, label: "#{page.fullpath} (#{locale})"
        
              filepath = data_path(page, locale)
        
        

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

              def persist(decorated_entity)
                _attributes = decorated_entity.to_hash
          
                # push the picture only if there is no existing remote picture
                _attributes.delete(:picture) if remote_site['picture_url'].present?

          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_content_entries has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def fetch_content_entries(content_type, &block)
                page = 1
                while page do
                  entries, _next_page = {}, nil
          
          

          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_json has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                    def to_json
                      self._list.map do |template|
                        # puts template.klass.class_options.inspect
                        # puts class_options_to_json
                        path = template.klass.source_root ? File.expand_path(template.klass.source_root) : nil
          Severity: Minor
          Found in lib/locomotive/wagon/generators/site.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 connection_information has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def connection_information
                if information = read_deploy_settings(self.env, self.path)
                  # the deployment env exists and contains all the information we need to move on
                  information
                else
          Severity: Minor
          Found in lib/locomotive/wagon/commands/push_command.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 prepare_value_for_hash has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def prepare_value_for_hash(value)
                if value.is_a?(Array) && value.any? { |v| v.respond_to?(:__attributes__) }
                  value.map(&:to_hash)
                elsif value.is_a?(Array) && value.empty?
                  nil # reset the array
          Severity: Minor
          Found in lib/locomotive/wagon/decorators/concerns/to_hash_concern.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 check_path! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def check_path!(path = nil)
                    path ||= options['path']
          
                    path = path == '.' ? Dir.pwd : File.expand_path(path)
          
          
          Severity: Minor
          Found in lib/locomotive/wagon/cli.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 extract_fields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def extract_fields(fields)
                    fields.map do |raw_attributes|
                      name, type, label, required, localized, target_content_type_slug  = raw_attributes.split(':')
          
                      OpenStruct.new(
          Severity: Minor
          Found in lib/locomotive/wagon/generators/content_type.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 replace_asset_urls has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def replace_asset_urls(content)
                return '' if content.blank?
          
                _content = content.dup
          
          

          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/wagon/tools/styled_yaml.rb - About 45 mins to fix

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

                    def list_templates
                      force_color_if_asked(options)
                      require 'locomotive/wagon/generators/site'
                      require File.expand_path(options[:lib]) if options[:lib]
                      if Locomotive::Wagon::Generators::Site.empty?
            Severity: Minor
            Found in lib/locomotive/wagon/cli.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 fetch_content_types has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def fetch_content_types(&block)
                  api_client.content_types.all.each do |content_type|
                    content_type.attributes['localized_names'] = content_type.fields.map { |f| f['localized'] ? f['name'] : nil }.compact
                    content_type.attributes['urls_names'] = content_type.fields.map { |f| %w(file string text).include?(f['type']) ? f['name'] : nil }.compact
                    yield(content_type)

            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 select_options_yaml has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def select_options_yaml(options)
                  return if options.blank?
            
                  ordered_options = options.sort { |option| option['position'] }
            
            

            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 delete has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def self.delete(env, path, resource, slug, shell)
            Severity: Minor
            Found in lib/locomotive/wagon.rb - About 35 mins to fix
              Severity
              Category
              Status
              Source
              Language