autotelik/datashift

View on GitHub

Showing 255 of 255 total issues

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

    def create_worksheet( options = {} )
      sheet_name = options[:name]

      @workbook = HSSFWorkbook.new if @workbook.nil?

Severity: Minor
Found in lib/datashift/applications/jexcel_file.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 create_paperclip_attachment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def create_paperclip_attachment(klass, attachment_path, options = {})

      has_attached_file_attribute = options[:has_attached_file_name] ? options[:has_attached_file_name].to_sym : :attachment

      attachment_file = get_file(attachment_path)
Severity: Minor
Found in lib/datashift/loaders/paperclip/datashift_paperclip.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

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

        load_object_class.transaction do
          logger.info "Processing #{parsed_file.size} rows"

          parsed_file.each_with_index do |row, i|

Severity: Minor
Found in lib/datashift/loaders/csv_loader.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.

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

    task :purge, [:exclude_system_tables] => [:environment] do |_t, args|
      require 'highline/import'

      agree('WARNING: In Production database, REALLY PURGE ? [y]:') if Rails.env.production?

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. [29/25]
Open

        columns.each do |col_str|
          # split into usable parts ; size:large or colour:red,green,blue
          field, find_by_values = Querying.where_field_and_values(method_binding, col_str )

          raise "Cannot perform DB find by #{field}. Expected format key:value" unless field && find_by_values

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. [29/25]
Open

          sheet.each_with_index do |row, current_row_idx|

            next if current_row_idx == headers.idx

            # Excel num_rows seems to return all 'visible' rows, which appears to be greater than the actual data rows

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

    def create_attachment(klass, attachment_path, record = nil, attach_to_record_field = nil, options = {})
Severity: Minor
Found in lib/datashift/loaders/paperclip/image_loading.rb - About 35 mins to fix

    Method file_set_field has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def file_set_field( file_name, field, old_value, new_value, regex = nil )
    Severity: Minor
    Found in lib/datashift/file_definitions.rb - About 35 mins to fix

      Method get_record_by! has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def get_record_by!(klazz, field, search_terms, split_on = ' ', options = {} )
      Severity: Minor
      Found in lib/datashift/querying.rb - About 35 mins to fix

        Method get_record_by has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def get_record_by(klazz, field, search_term, split_on = ' ', options = {})
        Severity: Minor
        Found in lib/datashift/querying.rb - About 35 mins to fix

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

                ActiveRecord::Base.connection.tables.each do |table|
          
                  modules.each do |m|
                    @klass = DataShift::MapperUtils.table_to_arclass(table, m)
                    break if(@klass)
          Severity: Minor
          Found in lib/tasks/generate.thor 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.

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

                ActiveRecord::Base.connection.tables.each do |table|
          
                  modules.each do |m|
                    @klass = DataShift::MapperUtils.table_to_arclass(table, m)
                    break if(@klass)
          Severity: Minor
          Found in lib/tasks/export.thor 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 add_comment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def add_comment( cell, text )
                raise 'Please supply valid HSSFCell' unless cell.respond_to?('setCellComment')
                return if @sheet.nil?
          
                patriarch = @patriarchs[@sheet.getSheetName]
          Severity: Minor
          Found in lib/datashift/applications/jexcel_file_extensions.rb - About 35 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 autosize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def autosize(column = nil)
                return if @sheet.nil?
                if column.is_a? Integer
                  @sheet.autoSizeColumn(column)
                else
          Severity: Minor
          Found in lib/datashift/applications/jexcel_file_extensions.rb - About 35 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 bind_headers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def bind_headers( headers )
          
                logger.info("Binding #{headers.size} inbound headers to #{load_object_class.name}")
          
                begin
          Severity: Minor
          Found in lib/datashift/loaders/loader_base.rb - About 35 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

          Avoid too many return statements within this method.
          Open

                when HSSFCell::CELL_TYPE_BLANK    then return ''
          Severity: Major
          Found in lib/datashift/applications/ruby_poi_translations.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  when HSSFCell::CELL_TYPE_BOOLEAN  then return cell.getBooleanCellValue
            Severity: Major
            Found in lib/datashift/applications/ruby_poi_translations.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    when HSSFCell::CELL_TYPE_ERROR    then return cell.getErrorCellValue
              Severity: Major
              Found in lib/datashift/applications/ruby_poi_translations.rb - About 30 mins to fix

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

                    def export_with_associations(file_name, klass, records, options = {})
                
                      state = DataShift::Configuration.call.with
                
                      DataShift::Configuration.call.with = :all
                Severity: Minor
                Found in lib/datashift/exporters/csv_exporter.rb - About 25 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 export has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def export(file, export_records, options = {})
                      records = [*export_records]
                
                      if records.blank?
                        logger.warn('Excel Export - No objects supplied for export - no file written')
                Severity: Minor
                Found in lib/datashift/exporters/excel_exporter.rb - About 25 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