autotelik/datashift

View on GitHub

Showing 67 of 255 total issues

Method perform_load has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

    def perform_load( options = {} )

      allow_empty_rows = DataShift::Loaders::Configuration.call.allow_empty_rows

      logger.info "Starting bulk load from Excel : #{file_name}"
Severity: Minor
Found in lib/datashift/loaders/excel_loader.rb - About 7 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 results_to_sheet has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

    def results_to_sheet( results, sheet, mappings = nil, header = true)
      numrows = results.length
      sheet_name = sheet

      if numrows == 0
Severity: Minor
Found in lib/datashift/applications/jexcel_file_extensions.rb - About 7 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 perform_load has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    def perform_load( _options = {} )
      require 'csv'

      raise "Cannot load - failed to create a #{klass}" unless load_object

Severity: Minor
Found in lib/datashift/loaders/csv_loader.rb - About 5 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 map_inbound_headers has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    def map_inbound_headers(klass, columns)

      # If klass not in Dictionary yet, add to dictionary all possible operators on klass
      # which can be used to map headers and populate an object of type klass
      model_methods_collection = ModelMethods::Manager.catalog_class(klass)
Severity: Minor
Found in lib/datashift/binder.rb - About 4 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 split_on has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    def split_on( file_name, field, options = {} )

      regex = options[:filter] ? Regexp.new(options[:filter]) : nil

      log :debug, "Using REGEX: #{regex.inspect}" if regex
Severity: Minor
Found in lib/datashift/file_definitions.rb - About 4 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 call has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

      def self.call(load_object, value, method_binding)

        # there are times when we need to save early, for example before assigning to
        # has_and_belongs_to associations which require the load_object has an id for the join table

Severity: Minor
Found in lib/datashift/populators/has_many.rb - About 3 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 prepare_from_yaml has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def prepare_from_yaml(yaml, locale_key = 'data_flow_schema')

      @yaml_data = yaml

      raise "Bad YAML syntax  - No key #{locale_key} found in #{yaml}" unless yaml[locale_key]
Severity: Minor
Found in lib/datashift/mapping/data_flow_schema.rb - About 3 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 insistent_belongs_to has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def insistent_belongs_to(method_binding, record, value )

      operator = method_binding.operator

      klass = method_binding.model_method.operator_class
Severity: Minor
Found in lib/datashift/populators/populator.rb - About 3 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 get_record_by has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def get_record_by(klazz, field, search_term, split_on = ' ', options = {})

      split_on_prefix = options[:add_prefix]

      find_search_term = split_on_prefix ? "#{split_on_prefix}#{search_term}" : search_term
Severity: Minor
Found in lib/datashift/querying.rb - About 3 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 assign has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def assign(method_binding, record)

      model_method = method_binding.model_method

      operator = model_method.operator
Severity: Minor
Found in lib/datashift/populators/populator.rb - About 3 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 prepare_data has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def prepare_data(method_binding, data)

      raise NilDataSuppliedError, 'No method_binding supplied for prepare_data' unless method_binding

      @original_data = data
Severity: Minor
Found in lib/datashift/populators/populator.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 to_xls has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def to_xls(items = [])

        @excel = ExcelFile.new(items[0].class.name)

        @excel.create_row(0)
Severity: Minor
Found in lib/datashift/applications/jexcel_file_extensions.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

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

  class JExcelFile

    include RubyPoiTranslations
    extend RubyPoiTranslations

Severity: Minor
Found in lib/datashift/applications/jexcel_file.rb - About 2 hrs to fix

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

          def perform_load(options = {} )
    
            raise 'The class that attachments belongs to has not been set (:attach_to_klass)' unless @attach_to_klass
    
            raise "The field to search for attachment's owner has not been set (:attach_to_find_by_field)" unless @attach_to_find_by_field
    Severity: Minor
    Found in lib/datashift/loaders/paperclip/attachment_loader.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 class_source_to_operators has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def class_source_to_operators(config: DataShift::Configuration.call)
    
          raise SourceIsNotAClass, 'Cannot parse source for headers - source must be a Class' unless source.is_a?(Class)
    
          # TODO: This collection can now be sorted
    Severity: Minor
    Found in lib/datashift/headers.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 require_libraries has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.require_libraries
    
        loader_libs = %w[lib]
    
        # Base search paths - these will be searched recursively
    Severity: Major
    Found in lib/datashift.rb - About 2 hrs to fix

      Method perform_load has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def perform_load( options = {} )
      
            allow_empty_rows = DataShift::Loaders::Configuration.call.allow_empty_rows
      
            logger.info "Starting bulk load from Excel : #{file_name}"
      Severity: Major
      Found in lib/datashift/loaders/excel_loader.rb - About 2 hrs to fix

        Method prepare_from_yaml has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def prepare_from_yaml(yaml, locale_key = 'data_flow_schema')
        
              @yaml_data = yaml
        
              raise "Bad YAML syntax  - No key #{locale_key} found in #{yaml}" unless yaml[locale_key]
        Severity: Minor
        Found in lib/datashift/mapping/data_flow_schema.rb - About 2 hrs to fix

          Method perform_load has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def perform_load( _options = {} )
                require 'csv'
          
                raise "Cannot load - failed to create a #{klass}" unless load_object
          
          
          Severity: Minor
          Found in lib/datashift/loaders/csv_loader.rb - About 1 hr to fix

            Method require_libraries has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.require_libraries
            
                loader_libs = %w[lib]
            
                # Base search paths - these will be searched recursively
            Severity: Minor
            Found in lib/datashift.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