autotelik/datashift

View on GitHub

Showing 255 of 255 total issues

Method prepare_data has 34 lines of code (exceeds 25 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 1 hr to fix

    Method to_xls has 32 lines of code (exceeds 25 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 1 hr to fix

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

              def build_assignments(klass, include_instance_methods)
                begin
                  assignments[klass] = Catalogue.column_names(klass)
                rescue StandardError => x
                  raise DataShiftException, "Failed to process column_names for class #{klass} - #{x.message}"
      Severity: Minor
      Found in lib/datashift/model_methods/catalogue.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 export has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def export(file_name, export_records, options = {})
      
            @file_name = file_name
      
            records = [*export_records]
      Severity: Minor
      Found in lib/datashift/exporters/csv_exporter.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 file_set_field_by_map has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def file_set_field_by_map( file_name, fields, value_map, regex = nil )
      
            lines = []
            objects = []
      
      
      Severity: Minor
      Found in lib/datashift/file_definitions.rb - About 1 hr to fix

        Block has too many lines. [35/25]
        Open

        namespace :datashift do
        
          namespace :db do
        
            SYSTEM_TABLE_EXCLUSION_LIST = ['schema_migrations'].freeze

        This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

        Block has too many lines. [35/25]
        Open

                load_object_class.transaction do
                  sheet.each_with_index do |row, current_row_idx|
        
                    next if current_row_idx == headers.idx
        
        

        This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

        Method perform_load has 29 lines of code (exceeds 25 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 1 hr to fix

          Method get_record_by has 29 lines of code (exceeds 25 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 1 hr to fix

            Method insistent_belongs_to has 28 lines of code (exceeds 25 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 1 hr to fix

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

                  def export_with_associations(file_name, klass, export_records, options = {})
              
                    records = [*export_records]
              
                    state = DataShift::Configuration.call.with
              Severity: Minor
              Found in lib/datashift/exporters/excel_exporter.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

              Block has too many lines. [33/25]
              Open

                namespace :db do
              
                  SYSTEM_TABLE_EXCLUSION_LIST = ['schema_migrations'].freeze
              
                  desc 'Purge the current database'

              This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

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

                def to_hash_object
              
                  h = {}
              
                  gsub(/[{}]/, '').split(',').each do |e|
              Severity: Minor
              Found in lib/datashift/core_ext/string.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 activate_sheet has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def activate_sheet(term)
              
                    if @workbook
                      x = term.is_a?(String) ? @workbook.getSheetIndex(term.to_java(java.lang.String)) : term
                      @sheet = worksheet(x)
              Severity: Minor
              Found in lib/datashift/applications/jexcel_file.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 process_missing_records has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def process_missing_records( missing_records )
                    unless missing_records.empty?
                      FileUtils.mkdir_p('MissingAttachmentRecords') unless File.directory?('MissingAttachmentRecords')
              
                      puts "WARNING : #{missing_records.size} of #{loading_files_cache.size} files could not be attached to a #{load_object_class}"
              Severity: Minor
              Found in lib/datashift/loaders/paperclip/attachment_loader.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 active_worksheet has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def active_worksheet(term = nil)
                    if @workbook
                      if term.nil?
                        @sheet ||= @workbook.getSheetAt(@current_sheet_index)
                      else
              Severity: Minor
              Found in lib/datashift/applications/jexcel_file_extensions.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 record_to_column has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def record_to_column(record, json = false)
              
                    return '' if record.nil? || (record.respond_to?(:each) && record.empty?)
              
                    # :only and :except options can be used to limit the attributes included
              Severity: Minor
              Found in lib/datashift/column_packer.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 parse_headers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def parse_headers( sheet, header_row_idx = 0 )
              
                    headers = DataShift::Headers.new(:excel, header_row_idx)
              
                    header_row = sheet.row(header_row_idx)
              Severity: Minor
              Found in lib/datashift/excel_base.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

              Block has too many lines. [32/25]
              Open

              String.class_eval do
                # Convert DSL string forms into a hash
                # e.g
                #
                #  "{:name => 'autechre'}" =>   Hash['name'] = autechre'
              Severity: Minor
              Found in lib/datashift/core_ext/string.rb by rubocop

              This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

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

                  def method_missing(method, *args, &block)
                    # puts @excel.class, method, args.inspect
              
                    if @excel.respond_to?(method)
                      @excel.send(method, *args, &block)
              Severity: Minor
              Found in lib/datashift/applications/excel.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

              Severity
              Category
              Status
              Source
              Language