autotelik/datashift

View on GitHub

Showing 67 of 255 total issues

Method file_set_field_by_map has a Cognitive Complexity of 15 (exceeds 5 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

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 15 (exceeds 5 allowed). Consider refactoring.
Open

      def self.call(record, value, operator)

        logger.debug("Attempting Brute force assignment of value #{value} => [#{operator}]")

        return if(attempt(record, value, operator))
Severity: Minor
Found in lib/datashift/populators/insistent_assignment.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 map_inbound_headers has 47 lines of code (exceeds 25 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 1 hr to fix

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

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

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

          Method populate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.populate(klass, options = {} )
          
                  raise "Cannot find operators supplied klass nil #{klass}" if klass.nil?
          
                  register(klass)
          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 determine_operator_class has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def determine_operator_class
          
                if operator_for(:has_many) || operator_for(:belongs_to) || operator_for(:has_one)
          
                  result = klass.reflect_on_association(operator)
          Severity: Minor
          Found in lib/datashift/model_methods/model_method.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 create_import_config has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def create_import_config(klass_or_name, options = {})
          
                klass = MapperUtils.ensure_class(klass_or_name)
          
                @key = 'data_flow_schema'
          Severity: Minor
          Found in lib/datashift/generators/config_generator.rb - About 1 hr to fix

            Method export_with_associations has 35 lines of code (exceeds 25 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

              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

                    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

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language